Questions tagged [vim]

Vim is a free and open-source modal text editor available for most major platforms. It allows high efficiency in many text editing tasks but has a steep learning curve. To learn the basics, run ":help vimtutor". For non-programming questions please use https://vi.stackexchange.com/ instead.

Vim is a free and open source text editor with a steep learning curve that leads to high efficiency in many tasks related to text editing. If you wish to start with Vim, run :help vimtutor in Vim or run the vimtutor command in shell, which will teach you basic commands.

Vim is a highly configurable text editor built to enable efficient text editing. It is an improved version of the vi editor distributed with most UNIX systems and is available on a large number of other systems including Win32, MS-DOS, OS X, AMIGA, OS/2, Cygwin and many more. Vim is written by Bram Moolenaar.

Vim is often called a "programmer's editor," and is 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.

Before you ask

  • If your question is not about programming, consider posting Vim related questions at the dedicated Vim Stack Exchange site.
  • Vim has an extensive help system that will often address your questions. Type :help <subject> within Vim to search for help on a particular subject; for instance: :help search. The help documentation is also available online.
  • Search Stack Overflow for similar or duplicate questions.

Free Vim books

Vim books

Documentation

Tutorial

See also

License/charityware

Vim is Charityware. You can use and copy it as much as you like, but you are encouraged to make a donation for needy children in Uganda. Please see |kcc| below or visit the ICCF web site, available at these URLs:

Related tags

27998 questions
703
votes
16 answers

How do I fix the indentation of an entire file in Vi?

In Vim, what is the command to correct the indentation of all the lines? Often times I'll copy and paste code into a remote terminal and have the whole thing messed up. I want to fix this in one fell swoop.
mmcdole
  • 91,488
  • 60
  • 186
  • 222
693
votes
8 answers

To switch from vertical split to horizontal split fast in Vim

How can you switch your current windows from horizontal split to vertical split and vice versa in Vim? I did that a moment ago by accident but I cannot find the key again.
Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
651
votes
7 answers

"Find next" in Vim

To search forward in Vim for cake, I'd type /cake, but the cursor jumps to the first match when I press return. Is there a Vim command analogous to "find next"?
Yktula
  • 14,179
  • 14
  • 48
  • 71
638
votes
15 answers

What does the ^M character mean in Vim?

I keep getting the ^M character in my .vimrc and it breaks my configuration.
Max
  • 6,383
  • 3
  • 15
  • 6
584
votes
3 answers

Changing case in Vim

Is there a command in Vim that changes the case of the selected text?
Amir Rachum
  • 76,817
  • 74
  • 166
  • 248
582
votes
11 answers

Find and replace strings in vim on multiple lines

I can do :%s///g for replacing a string across a file, or :s/// to replace in current line. How can I select and replace words from selective lines in vim? Example: replace text from…
Anshul Goyal
  • 73,278
  • 37
  • 149
  • 186
574
votes
22 answers

Where is my .vimrc file?

I have been using Vim, and I would really like to save my settings. The problem I am having is that I cannot find my .vimrc file, and it is not in the standard /home/user/.vimrc location. How might I find this file?
Eman
  • 6,383
  • 4
  • 23
  • 29
567
votes
8 answers

How can I make my match non greedy in vim?

I have a big HTML file that has lots of markup that looks like this:

stuff here

I'm trying to do a Vim search-and-replace…
Mark Biek
  • 146,731
  • 54
  • 156
  • 201
565
votes
10 answers

How do I close a single buffer (out of many) in Vim?

I open several files in Vim by, for example, running vim a/*.php which opens 23 files. I then make my edit and run the following twice :q which closes all my buffers. How can you close only one buffer in Vim?
Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
538
votes
30 answers

In Vim is there a way to delete without putting text in the register?

Using Vim I often want to replace a block of code with a block that I just yanked. But when I delete the block of code that is to be replaced, that block itself goes into the register which erases the block I just yanked. So I've got in the habit of…
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
521
votes
38 answers

Convert ^M (Windows) line breaks to normal line breaks

Vim shows ^M on every line ending. How do I replace this with a normal line break in a file opened in Vim?
ByteNirvana
  • 5,640
  • 4
  • 21
  • 20
512
votes
15 answers

Using Caps Lock as Esc in Mac OS X

How do I make Caps Lock work like Esc in Mac OS X?
indentation
  • 9,895
  • 6
  • 21
  • 14
508
votes
11 answers

How to get the list of all installed color schemes in Vim?

Is there a way to get a list of all installed color schemes in Vim? That would make very easy to select one without looking at the .vim directory.
tunnuz
  • 23,338
  • 31
  • 90
  • 128
501
votes
14 answers

How to insert text at beginning of a multi-line selection in vi/Vim

In Vim, how do I insert characters at the beginning of each line in a selection? For instance, I want to comment out a block of code by prepending // at the beginning of each line assuming my language's comment system doesn't allow block…
Jordan Parmer
  • 36,042
  • 30
  • 97
  • 119
500
votes
16 answers

Move cursor to end of file in vim

When I want the cursor to go to the end of the file (i.e. the end of the last line) in Vim, I have to type six keystrokes: G$a - which translates to ESC + Shiftg + Shift4 + a on my keyboard layout. How can I do this more efficiently? Since I…
user1322720