Vim is a highly configurable text editor built to enable efficient text editing. It is an improved version of the vi editor.

learn more… | top users | synonyms

12
votes
3answers
4k views

How can I distinguish current operating system in my .vimrc?

I use Vim on both OS X and Windows, with almost identical configuration. I would like to be able to use the same .vimrc on the two operating systems, but there are a couple of things I need to ...
12
votes
4answers
11k views

How to exit help in vim

I just used the help files in vim and now I am stuck in help. :q Exits the entire program and I am getting tired of having to close and reopen vim every time I use help. I would prefer a command that ...
12
votes
3answers
9k views

Vim: how to paste a block of text at the end of multiple lines?

Say I have a block of text like this: // Comment1 // Comment2 // Comment3 And I want to append each of these lines to the end of 3 corresponding lines of code: foo = 1; bar = 2; baz = 3; So ...
12
votes
2answers
6k views

How do I only dp or do just the lines, not the entire block in Vim diff?

I'm currently using MacVim (Snapshot 64) "Split Diff by..." menu option. The file is Django's my settings.py from version 1.3.1 to a fresh file from version 1.4. (Open the image on a separate ...
12
votes
2answers
3k views

Multimarkdown table formatting in Vim

I've recently moved from using TextMate to using Vim a lot more (because I split my time between Mac and Linux). One thing I miss is the wonderful MultiMarkdown bundle which, amongst other features, ...
12
votes
2answers
4k views

How to open the doc file for a vim plugin?

I just downloaded the Rails vim plugin from here. One of the file that it contain is a doc file that will be extracted to ~/.vim/doc/rails.txt How do I open the content of this help file in vim ? I ...
12
votes
4answers
4k views

Count highlighted string length in VIM

I wonder is there a way to count highlighted symbols in vim (including white spaces)? UPDATE It shows rows count if my selection is on multiple rows. I need symbols count.
12
votes
4answers
2k views

In vim, how do I make the left and right arrow keys change line?

In vim, my arrow keys work correctly, moving up, down, left, and right as expected, with one exception. At the beginning of a line, left arrow does nothing, instead of going to the last character of ...
12
votes
1answer
4k views

How can I tell Vim to show ANSI escape codes properly?

I'm trying to view and edit a file in Vim, but this file has ANSI escape codes: ^[[1m[0.05s elapsed, 00:00:13 total]^[[0m How can I tell Vim to interpret them properly instead of just showing the ...
12
votes
1answer
379 views

vimperator: Using external editor (e.g., vim) to edit Stack Overflow text

Utilities like vimperator allow editing content of HTML form fields in an external editor. With vimperator there is shortcut Ctrl+I which, when in an edit box, opens the text in an external editor. ...
12
votes
2answers
2k views

How to set background color for Vim's active window only?

A small but visually pleasing feature, and slightly adding to usability, I'd like to have Vim use different background color for the active window. Here's a sketch of what I am after: Normally ...
12
votes
4answers
714 views

How can I keep a buffer list per window in Vim?

I'm surprised that I haven't been able to find an answer to this, but maybe I'm missing something obvious: is it possible to keep a buffer list per window? I often have around 4 splits, and each one ...
11
votes
4answers
6k views

Remove VIM search highlight

After a search I've done, all the matches for the respective query remain highlighted and it's annoying. This happens even after I close the respective file (normal behavior?). How to I remove this?
11
votes
6answers
2k views

vim : toggle number with relativenumber

with setl nu! I can toggle number (on/off), similar with relativenumber setl rnu! how I can toggle {off,number,relativenumber} ?
11
votes
3answers
7k views

Mouse cursor in Terminal?

I use Mac OS X Terminal.app. But the answer to this would probably apply to any typical UNIX-ish terminal emulator in a graphical environment. Question -- what do I do to: Use my mouse cursor to ...
11
votes
6answers
6k views

Vim configuration slow in Terminal & iTerm2 but not in MacVim

Ideally, I want to use Vim from Terminal or iTerm2. However, it becomes unbearably slow so I had to resort to using MacVim. There is nothing wrong with MacVim, however my workflow would be much ...
11
votes
7answers
3k views

vim multiuser editing?

With vim, can two users edit the same file at the same time?
11
votes
4answers
3k views

Can I get the Vim Ctrlp plugin to ignore a specific folder in one project?

The Vim Ctrlp plugin has a way to globally ignore certain folder names. Eg: let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$' However, I have an ignore rule that's specific to one project. I ...
11
votes
1answer
3k views

Automatically close NERDtree when opening file

I have installed NERDtree 4.1.0. I have mapped <leader>n to :NERDTreeToggle<CR>. I would like to use this in a way where I can press <leader>n, then locate the deisred file in the ...
11
votes
1answer
4k views

How do I unset a specific vim command?

set listchars=tab:>-,trail:_ I tried to unset the above command this way: unset listchars=tab:>-,trail:_ But only get: E492: Not an editor command: unset listchars=tab:>-,trail:_ What'...
11
votes
1answer
2k views

Why can Vim open large files faster than some other text editors?

When opening large log files (well, not that large, but 80mb is still a lot of text!), I've always used Vim since it loads them almost instantly. Other text editors like Notepad, Notepad++, etc will ...
11
votes
1answer
2k views

How to refresh vim layout when split

After setting up some splits/vsplits and resizing gvim or the console running vim, splitter positions are not updated. Is there a way to force updating splitter positions (by retaining them in the ...
11
votes
3answers
5k views

How do I enable syntax highlighting for .bash_aliases in vim?

I'm working on reorganizing my .bashrc. I moved my aliases to .bash_aliases (which is sourced by .bashrc, but I can't figure out how to enable syntax highlighting for this file. vim seems unable to ...
11
votes
3answers
2k views

How to break long lines in vim?

I have a quite big text file formed of blocks like Short line. Really long line. Short line. separated by empty lines, and I would like to use vim (on Linux) to break down the long lines and obtain ...
11
votes
5answers
9k views

Always use :set paste, Is it a good idea?

In a terminal vim, pasting clipboard data often messes up the code indent. I just knew if I uses :set paste the indent is not broken. Though, after pasting data, should I do :set nopaste again? What ...
11
votes
3answers
14k views

Configure VIM for copy and paste keyboard shortcuts from system buffer in Ubuntu?

How do I configure VIM for using Ctrl-c to copy and Ctrl-v to paste from system buffer in Ubuntu?
11
votes
1answer
2k views

Vim Ignores Aliases

If I map a command in vim using something like map <f4> :! pdflatex %<cr> Vim will ignore my alias for pdflatex (something like alias pdflatex='pdflatex --temp-dir=something'). Is it ...
11
votes
3answers
2k views

Repeat last normal mode command, including moves, in Vim

In Vim, with ., I can repeat the last normal mode command; for example: dd. deletes a line twice. But, if I type 5j. the cursor does't move 10 lines down. How do I repeat the last normal mode ...
11
votes
1answer
2k views

List all filetype plugins known to Vim

I want to list all filetypes Vim recognizes from its runtimepath. For example: ada arc c clojure common-lisp elisp go python How can I do it?
11
votes
2answers
5k views

Fuzzy find within file in Vim

I love using the Command-T plugin in Vim to do fuzzy searches for filenames. I like it so much that I've started to want to do the same fuzzy searches for arbitrary strings within an open buffer. For ...
11
votes
3answers
6k views

Can I use vim to open a huge file effectively?

sometime I need to open a several GB log file, now I need to use tail to get suitable part but that is very tedious. Can I just use vim to open it directly? Currently vim will occupy a lot memory ...
11
votes
2answers
4k views

Why does Vim ignore files in ~/.vim/after/ftplugin?

I seem to have a problem with my local Vim configuration but I'm not sure what it is. I need to override some filetype-specific settings. As per multiple tutorials/howtos, I created ~/.vim/after/...
11
votes
4answers
6k views

Mac OS X: how to open vim in terminal when double click on a file

I have defined my own custom vim file type with highlighting etc. I would like to open it using the terminal based vim when I double click on it. I am using mac os x. Any pointers on how to start ...
11
votes
3answers
6k views

Can I use the `<cmd>` key in terminal Vim at all?

Following on from my other recent question: How do I map <cmd>-<shift>-f to run Ack plugin in Vim? Is is possible to use the <cmd> key in Vim at all? If Vim doesn't recognise the ...
11
votes
2answers
143 views

vi / vim abrumpt buffer movements within window

When using :set wrap in vi/vim, the contents of an entire wrapped line are placed in the display buffer upon moving the cursor into a new line, even when navigating through a file by display line (gj/...
10
votes
2answers
2k views

GNU Screen - Removing vim window after quit

I use urxvt with GNU screen with X11 on my mac. I like it a lot. My only issue, is that when I quit vim, it puts the shell prompt underneath the vim window. This isn't a huge issue, but it ...
10
votes
5answers
2k views

Highlighting a search term without moving the cursor

Using Vim, I sometimes find myself staring at a section of source code for a while and suddenly want some variable on the screen to pop out. That's easy: /<var> which highlights them all. My ...
10
votes
7answers
3k views

Vim - Adding empty line between lines

How do I insert a blank line between every non-blank lines? eg. from line 1 line 2 line 3 line 4 line 5 to line 1 line 2 line 3 line 4 line 5
10
votes
6answers
3k views

Using Vim key bindings in Onenote

I found ViEmu, which allows you to use Vim key bindings in Visual Studio and certain Office applications. Does anyone know of similar software for using Vim key bindings in Microsoft Onenote? Free or ...
10
votes
5answers
9k views

What could cause strange characters in Vim?

I'm have this really strange problem in Vim using the NERD tree plugin, where, as you can see in the picture, the characters are showing up very strange. Where there is the ahat, ~V 3/4 it should be |-...
10
votes
5answers
12k views

How to jump to the beginning or end of line in vim + OS X

In terminal I can do this by pressing shift+home and shift+end, but it doesn't seem to work in vim. Home and end keys scroll terminal window only. I would like to jump in edit mode.
10
votes
4answers
4k views

How can I test for plugins and only include them if they exist in .vimrc?

In my .vimrc I am trying to use ftplugin and obviously use some commands relating to that under the assumption that it was loaded successfully. However, I have now encountered a few old machines that ...
10
votes
1answer
3k views

How can I hide the insert status in vim?

I want to hide -- INSERT -- from the status line.
10
votes
1answer
4k views

In Vim, what's an elegant way to grab output from the command-line?

If I'm in Vim and want to get some output from the command-line and tack it onto my current file, I can run this: :! echo "foo" >> % That will append "foo" to my current file, and I'll have ...
10
votes
2answers
682 views

How to read Vim keystroke syntax?

I'm trying to learn Vim and I'm seeing a lot of documentation use syntax like <C-v>. Is there a general guide on how to read this correctly? I've attached an example SO post below that uses ...
10
votes
6answers
6k views

Custom vim highlighting

I am editing some xml right now and I have been leaving myself some comments of things to come back to. Like this <!-- Question: bla bla --> I am editing with vim right now and I would like ...
10
votes
2answers
2k views

how do I copy/paste in vim ex mode

I'm increasingly frustrated by typing this :%s/some_really_long_string/some_other_really_really_long_string_that_may_or_may_not_related_to_the_first_one/gc Is there any way to copy/paste those ...
10
votes
5answers
4k views

Can I use perl regular expressions in the vim command line?

I want to use perl regular expressions on the vim command line. For example, to capitalize the words on the current line, you could type: :s/(\w+)/\u$1/g
10
votes
3answers
3k views

How to run Vim command from the shell?

This might be a dumb question, but bear with me. I'm automating some of the usual stuff I do when setting up a new work environment, and would like to automate the Vim command :BundleInstall (for ...
10
votes
2answers
4k views

how to make vim's auto-complete behave like bash's default auto-complete?

When you type :e some/path/file<Tab> if there are several matches, vim just picks the first one and you have to cycle through the rest of them with the Tab key. (pretty much like the behavior of ...