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

26806 questions
4269
votes
10 answers

How do I exit the Vim editor?

I'm stuck and cannot escape. It says: "type :quit to quit VIM" But when I type that it simply appears in the object body.
jclancy
  • 40,614
  • 5
  • 25
  • 32
2811
votes
29 answers

How do I make Git use the editor of my choice for commits?

I would prefer to write my commit messages in Vim, but it is opening them in Emacs. How do I configure Git to always use Vim? Note that I want to do this globally, not just for a single project.
brasskazoo
  • 68,343
  • 22
  • 59
  • 74
2252
votes
33 answers

Indent multiple lines quickly in vi

It should be trivial, and it might even be in the help, but I can't figure out how to navigate it. How do I indent multiple lines quickly in vi?
Allain Lalonde
  • 85,857
  • 67
  • 175
  • 234
2128
votes
11 answers

How to replace a character by a newline in Vim

I'm trying to replace each , in the current file by a new line: :%s/,/\n/g But it inserts what looks like a ^@ instead of an actual newline. The file is not in DOS mode or anything. What should I do? If you are curious, like me, check the question…
Vinko Vrsalovic
  • 244,143
  • 49
  • 315
  • 361
2059
votes
32 answers

Vim clear last search highlighting

After doing a search in Vim, I get all the occurrences highlighted. How can I disable that? I now do another search for something gibberish that can't be found. Is there a way to just temporarily disable the highlight and then re-enable it when…
Gabriel Solomon
  • 26,777
  • 15
  • 55
  • 76
1777
votes
15 answers

How to do case insensitive search in Vim

I'd like to search for an upper case word, for example COPYRIGHT in a file. I tried performing a search like: /copyright/i # Doesn't work but it doesn't work. I know that in Perl, if I give the i flag into a regex it will turn the regex into a…
Haiyuan Zhang
  • 36,164
  • 38
  • 101
  • 131
1745
votes
20 answers

How to duplicate a whole line in Vim?

How do I duplicate a whole line in Vim in a similar way to Ctrl+D in IntelliJ IDEA/ Resharper or Ctrl+Alt+↑/↓ in Eclipse?
sumek
  • 24,063
  • 10
  • 50
  • 64
1523
votes
9 answers

How does the vim "write with sudo" trick work?

Many of you have probably seen the command that allows you to write on a file that needs root permission, even when you forgot to open vim with sudo: :w !sudo tee % The thing is that I don't get what is exactly happening here. I have already…
Doppelganger
  • 17,749
  • 7
  • 28
  • 28
1331
votes
11 answers

Tab key == 4 spaces and auto-indent after curly braces in Vim

How do I make vi-Vim never use tabs (converting spaces to tabs, bad!), makes the tab key == 4 spaces, and automatically indent code after curly brace blocks like Emacs does? Also, how do I save these settings so I never have to input them…
mmcdole
  • 86,293
  • 60
  • 181
  • 221
1318
votes
24 answers

Turning off auto indent when pasting text into vim

I am making the effort to learn Vim. When I paste code into my document from the clipboard, I get extra spaces at the start of each new line: line line line I know you can turn off auto indent but I can't get it to work because I have some…
Rimian
  • 32,654
  • 13
  • 106
  • 109
1312
votes
49 answers

What's a quick way to comment/uncomment lines in Vim?

I have a Ruby code file open in vi, there are lines commented out with #: class Search < ActiveRecord::Migration def self.up # create_table :searches do |t| # t.integer :user_id # t.string :name # t.string :all_of # …
Ethan
  • 52,651
  • 60
  • 180
  • 231
1278
votes
15 answers

How do I move to end of line in Vim?

I know how to generally move around in command mode, specifically, jumping to lines, etc. But what is the command to jump to the end of the line that I am currently on?
salt.racer
  • 20,273
  • 14
  • 41
  • 50
1226
votes
3 answers

What is the difference between the remap, noremap, nnoremap and vnoremap mapping commands in Vim?

What is the difference between the remap, noremap, nnoremap and vnoremap mapping commands in Vim?
Chetan
  • 41,886
  • 27
  • 101
  • 142
1191
votes
12 answers

Redefine tab as 4 spaces

My current setting assumes 8 spaces; how could I redefine it?
Ricky
  • 30,941
  • 36
  • 85
  • 129
1177
votes
5 answers

What is the in a .vimrc file?

I see in many .vimrc files, and I am wondering what does it mean? What is it used for? Just a general overview of the purpose and usage would be great.
Bob Martens
  • 12,142
  • 3
  • 14
  • 9
1
2 3
99 100