Questions tagged [vim]

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

Vim stands for Vi IMproved. Vim is a configurable text editor. It is an improved version of the vi editor.

Vim Logo

From the Vim website:

Vim is a highly configurable text editor built to enable efficient text editing. It is an improved version of the editor distributed with most UNIX systems.

Vim is often called a "programmer's editor," and so useful for programming that many consider it an entire IDE. It's not just for programmers, though. Vim is perfect for all kinds of text editing, from composing email to editing configuration files.

The most confusing aspect of Vim (and vi) is that it is a modal editor, meaning that it has different modes. In Normal mode, dd would delete a line, but in Insert mode, dd simply inserts dd into the text.

Free Vim books

Documentation

Screencasts

Online resources

Plugins

3717 questions
147
votes
14 answers

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 mode?
Mike Lee
  • 649
141
votes
4 answers

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.
hakanensari
  • 2,167
122
votes
4 answers

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 to ~/.vimrc and I want line numbers to appear for…
Nemoden
  • 2,477
119
votes
11 answers

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?
JtR
  • 1,899
115
votes
8 answers

How to search for selected text in Vim?

I'm aware that I can use / followed by a regex to search something. And I can use ? to search backwards. And I can use n and N to repeat the search forward and backward. There are also two nice shortcuts: * or # will search for the word under the…
96
votes
9 answers

Can I disable continuation of comments to the next line in Vim?

In Vim, if I'm typing a comment in a code file, and I hit Enter, it automatically makes the newline a comment, too. For instance, in a Ruby file: # I manually typed the pound at the start of this line and hit enter. # This line formatted itself this…
Nathan Long
  • 26,565
88
votes
2 answers

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 consecutively 'Hello' 'World' 'And' 'Vim' Note…
user4941
  • 1,227
87
votes
2 answers

How to get back to insert mode in VIM when you accidentally hit C-x C-s

Given this vim session: % vim test-file.txt iHello there!C-x C-s How do I get back to insert/command mode again? (C-x C-s means Control-x Control-s, not sure if it's normal vi terminology for keyboard shortcuts) I know there's some way to get out…
gaqzi
  • 1,308
84
votes
4 answers

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 white space cW to change the whole address, because…
Nathan Long
  • 26,565
83
votes
4 answers

How do I tell what syntax file is being used?

Vim is syntax highlighting my file in a funny way, and I want to know what syntax file is responsible for this behaviour. How do I find out what syntax files vim has loaded?
58
votes
2 answers

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. Instead of editing a bunch of different vimrc, I…
57
votes
8 answers

Auto-reloading a file in VIM as soon as it changes on disk

Assuming that a file doesn't have unsaved changes in the VIM buffer, I'd like it to reload automatically if the file changes on disk. The most frequent use case for this is when I update the working copy in which the file resides. How can I achieve…
GJ.
  • 9,843
56
votes
2 answers

How can I switch from forward to backward search in Vim?

In Vim, I know that / will search forward from the cursor, with n and N repeating the search forward and backward, respectively. I also know that ? will search backward from the cursor, with n and N repeating the search backward and forward,…
Nathan Long
  • 26,565
55
votes
8 answers

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 can close help and return me to the program I am…
Joseph
  • 839
55
votes
2 answers

Reload file in vim

When I have a file open in vim, in this case a log file, I'd like to trigger a refresh and load any file changes into my existing vim session. I often use tail -f on log files, but as I'm using java and tomcat, the log messages are too much for…
mcgyver5
  • 1,101
1
2 3
49 50