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

183
votes
2answers
51k views

How do you reload your .vimrc file without restarting vim?

Can you edit your .vimrc file in vim, and reload it without restarting vim?
130
votes
5answers
64k views

How to open files in vertically/horizontal split windows in Vim from the command line

There must be a way, something like this: vim -[option] <file-list> to open files from command prompt and not from within Vim. split windows vertically or/and horizontally in separate tabs ...
67
votes
14answers
7k views

Why arrow keys are not recommended in Vim

"Never use arrow keys in Vim!" I heard this from a random speaker, but didn't have the chance to ask him why. Also, if you don't use the arrow keys, how can you move the cursor in the Insert ...
51
votes
4answers
20k views

The best way to make MacVim's vim (console, not mvim) the default instead of Mac OS X's vim?

I installed MacVim using homebrew. (brew install macvim). If I call mvim from cmd, it opens the GUI MacVim. I would like to make vim call the MacVim's Vim ...
43
votes
3answers
4k views

How do you reuse a visual mode selection?

Often when editing code, I'll select a block in visual mode and do a search and replace over the block. After I make the changes, however, it leaves visual mode. How do a new find and replace over the ...
40
votes
2answers
24k views

How do I find the encoding of the current buffer in vim?

Say I am editing some file with vim (or gvim). I have no idea about the file's encoding and I want to know whether it is in UTF-8 or ISO-8859-1 or whatever? Can I somehow tell vim to show me what ...
39
votes
6answers
19k views

Mac OS X Terminal: mouse support?

Is there a native option (ie. without installing extra soft/package/plugins) to enable mouse support in the Terminal app? Actually, I'm using a lot vim with the option set mouse=a (activating mouse ...
35
votes
3answers
18k views

How to show the current column in the statusbar in vim?

I would like to show the current column in the statusbar, as is common in many other text editors. E.g. it's good to know if you are around column 80 or above. How to show the current column in the ...
33
votes
8answers
19k views

How can I open a file read-only from command line with emacs/vi/vim

Is there a way to tell emacs/vi/vim (from the command line) that I want to view the file in view-mode or read-only. I know how to open a file as read only if emacs/vi/vim is already running.
33
votes
2answers
9k views

How to start vim without executing /etc/vimrc?

On my Linux server at work, the admins did not install cscope, and I installed it from source in my home directory and added it to the $PATH. The trouble is, the /etc/vimrc has a reference to ...
32
votes
3answers
17k views

256 color support for vim background in tmux

while using vim within tmux I can see that 256 color support is enabled. with $tput colors However changing the colorscheme in vim while in tmux will change the colorscheme on a per line basis but ...
28
votes
12answers
2k views

Vim: How do you efficiently search for text?

Whenever you want to search for text in vim you would type / and then the string you are looking for. However, when the string is a long one, and you want to do this multiple times, is there a way to ...
28
votes
3answers
20k views

selecting text tmux copy-mode

I run tmux in VI mode. VI-like navigation in copy-mode works fine. However, I can't select any text. Neither v nor V doesn't switch to VI-like text selecting mode. What am I missing? By the way, is ...
28
votes
9answers
22k views

How can I get (g)Vim to display the character count of the current file?

I like to write tutorials and articles for a programming forum I frequent. This forum has a character limit per post. I've used Notepad++ in the past to write posts and it keeps a live character ...
27
votes
3answers
13k views

How do I open a blank new file in a split in Vim?

Must be something super obvious, but I can't figure out, and Google is not helping out either.
25
votes
3answers
14k views

How to add a command in vim editor?

If suppose my source code file name is "foo.c". While editing and debugging i always execute this command:- :!gcc -g foo.c -o foo;gdb foo Can I add a custom command to Vim such that If i type ...
24
votes
5answers
4k views

Invoking vi through find | xargs breaks my terminal. Why?

When invoking vim through find | xargs, like this: find . -name "*.txt" | xargs vim you get a warning about Input is not from a terminal and a terminal with pretty much broken behaviour ...
24
votes
4answers
4k views

How reverse selected lines order in vim?

For example, if I have four lines as follows: the first line the second line the third line the fourth line I want to reverse them to the fourth line the third line the second ...
23
votes
1answer
7k views

How to get vim to open multiple files into tabs at once

Is it possible to get vim to open multiple files into tabs, similar to the way the args <path> command will open multiple files into buffers? Doing something like :tabe ./* results in the error ...
22
votes
7answers
15k views

How to remove this symbol “^@” with vim?

I have some files that are corrupted with this symbol: ^@ It's not part of the string; it's not searchable. How do I substitute this symbol with nothing, or how do I delete this symbol? Here ...
21
votes
2answers
7k views

vim cut and paste history

When I'm 'cutting' in vim, I believe there are registers that keep a history of all the recent things I've cut. How do I access those registers? For example, let's say I cut each one of these words ...
21
votes
2answers
6k views

How to get shift+arrows and ctrl+arrows working in Vim in tmux?

This is all in iTerm2 on OS X. I used to have export TERM='xterm-256color' in my .bashrc. This meant Vim in tmux did use 256 colors. And once I added set -g xterm-keys on then keyboard ...
21
votes
2answers
3k views

Slight delay when switching modes in vim using tmux or screen

Switching to and from insert mode in Vim is no longer instantaneous since I use tmux. After pressing Esc in insert mode, it takes a noticeable amount of time to actually get out of insert mode. After ...
21
votes
1answer
2k views

How can I select an html tag's content in Vim?

Is it possible to select an html tag's content in Vim? For example: <p>I am a silly butterfly</p> I would like to select "I am a silly butterfly"! I know that you can use vi" to select ...
21
votes
2answers
1k views

Use vim to edit ANY text on Linux

I come from the Mac world, where I use http://www.hogbaysoftware.com/products/quickcursor to edit text from anywhere in Vim. Is there anything like that on Linux ? I'm already using "It's All Text" ...
20
votes
6answers
8k views

Vim: How to synchronize NERDTree with current opened tab file path?

When I open a new tab with different path from the previous file in VIM, NERDTree will still remains the same directory hierarchy of the previous file. Is there a sync shortcut to change the current ...
20
votes
2answers
5k views

How do I change until the next underscore in VIm?

If I have this text in vim, and my cursor is at the first character: www.foo.com I know that I can do: cw to change up to the first period, because a word (lowercase w) ends at any punctuation OR ...
20
votes
2answers
6k views

Is there an “include” procedure in vimrc?

I have some configuration in my vimrc. Some generic ones, and some other really specific. I would like to share this config with some co workers, but a lot of them don't need these specific ones. ...
20
votes
4answers
2k views

Vim - select text highlighted by search?

In vim, I often perform searches to hop to a word or phrase instead of navigating there with h/j/k/l. Then I hit n to hop between occurrences. Say I've got this text: Time flies like an arrow; fruit ...
19
votes
7answers
8k views

How do I open the directory of the current open file?

If I open a file with vim dir/to/my/file.c how can I easily open the directory dir/to/my in vim's filebrowser?
19
votes
7answers
4k views

How to make VIM settings computer-dependent in .vimrc?

I share my VIM configuration file between several computers. However, I want some settings to be specific for certain computers. For example, font sizes on the high-res laptop should be different to ...
19
votes
3answers
6k views

How can I keep the code formated as original source when I paste them to vim?

When I copy some code from webpages and paste it to VIM,I find it becomes a mess style like a ladder as follows xxxxxx xxxxxx xxxxxx xxxxxxxxxx Since it messed so regularly so I ...
19
votes
2answers
4k views

Reload .vimrc in Vim without restart

It bothers me when I wrote something into .vimrc and I have to close it first and open to get my changes be applied. Is there a way of reload .vimrc in Vim without closing it? E.g. I've added set nu ...
19
votes
3answers
37k views

How to install vim.full in Ubuntu?

I've installed Ubuntu Server but I have only vim.basic? How do i install vim.full? Tried with aptitude install vim but it said it's always installed. Because vim is a soft link to vim.basic.
19
votes
6answers
1k views

How can I discard my undo history in vim?

Undo is nice to have in Vim. But sometimes, at a known good point, I want to erase my undo history - to be able to use u to undo individual changes, but only back to a certain point. (For instance, ...
18
votes
10answers
2k views

Moving (efficiently) vertically in Vim

When I want to reach to a certain part of a word in Vim (horizontally) I simply press w, b, f or t (something). Is there a good way of doing this vertically? For instance, I want to get to a certain ...
18
votes
3answers
7k views

How do I customize zsh's vim mode?

Ok, so I finally made the great change. In my .zshenv, I changed my EDITOR: export EDITOR=vim There are a couple of questions I have that are so minor that I didn't want to start separate ...
18
votes
3answers
22k views

Vim: show line feeds & carriage-return

How can I display line feeds and/or carriage-return characters in vi/vim? I know that set list shows all the whitespace characters (?), it also replaces tabs \t etc (but that's not what I want). ...
17
votes
8answers
7k views

VIM: “sudo vim bad_idea”?

An irc-user in #Vim urged me not to use Sudo with Vim like: sudo vim bad_idea When I am doing things in locations such as /var/www/, I cannot write without it. So not-using sudo becomes a problem. ...
17
votes
2answers
3k views

vim freezes inside tmux

I'm using split panes in tmux - one being vim, other shell. Sometimes, around once a day, vim freezes. I can move between panes, perform any tmux commands, just vim doesn't react to anything. This ...
17
votes
3answers
3k views

copy-paste not working in MacVim when launched in tmux

MacVim's copy-paste stops working when I launch it from a tmux terminal (on zsh). If I exit tmux and then launch MacVim copy-past works. Any idea how to fix this?
17
votes
3answers
4k views

Using the vim split command from the command line to get 4 quater splits

I want to open four vim files on the command line: vim file1 file2 file3 But I would like each file to be opened in a separate split: vim -c "split file1" -c "split file2" -c "split file3" file4 ...
17
votes
4answers
10k views

vimdiff: Jump to next difference inside line?

vimdiff is very handy for comparing files. However, I often use it on files with long lines and relatively few differences inside the lines. vimdiff will correctly highlight differences inside a line ...
16
votes
7answers
10k views

Vimperator copy/pasting

I'm trying out Vimperator. I mainly wanted it for the hjkl scrolling, and I like its "hint" system for following links. These two features are really all I need; I think. I don't mind the other ...
16
votes
3answers
9k views

How to setup a line length marker in vim/gvim?

Some GUI text editors have a vertical line which serves as line length marker (it helps keeping lines shorter than 80 chars in source code files). Is is possible to have something similar in ...
16
votes
2answers
2k views

How can I make the Sign Column show up all the time even if no Signs have been added to it?

I've just added the Git Gutter plugin for Vim which shows lines added/modified/deleted according to git diff. It uses the Sign Column to show characters next to each line. At the moment the column ...
15
votes
10answers
3k views

Good vim tutorial? [closed]

I've constantly heard good things about vim, and now I'm intrigued. The only thing that's putting me off is it's irregular keyboard controls. Does anyone know of any good beginners tutorials for vim?
15
votes
4answers
7k views

How do I edit an existing buffer in a new tab in vim?

Suppose I have started vim like this: vim foo bar Now I decide that I want each of those files in its own tab. Is there a way to do that without exiting vim and adding the -p option to my command ...
15
votes
4answers
4k views

Make VIM display a line at the edge of the set textwidth

Most of the text editors/IDEs that I use these days have a feature where it can display a line at a certain character length in the text buffer. It's useful when you want to keep lines of text under ...
15
votes
3answers
9k views

Mousing and Page-Up/Down in Terminal for Mac OS X

Compared to *nix, Terminal.app seems pretty lame. How can I get it to: Send Page-Up/Down to an application, instead of just scrolling the terminal output Mouse around in vim. set mouse=a isn't ...