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
485
votes
15 answers

Vim and Ctags tips and tricks

I have just installed Ctags (to help with C++ development) with my Vim (or rather gVim), and would like to find out your favorite commands, macros, shortcuts, tips that go along with it... Share your best arsenal. What other Vim add-ons you would…
Sasha
465
votes
34 answers

What are the benefits of learning Vim?

As a programmer I spend a lot of hours at the keyboard and I've been doing it for the last 12 years, more or less. If there's something I've never gotten used to during all this time, it's these annoying and almost unconscious constant…
Trap
  • 12,050
  • 15
  • 55
  • 67
463
votes
22 answers

Renaming the current file in Vim

How should I rename my current file in Vim? For example: I am editing person.html_erb_spec.rb I would like it renamed to person.haml_spec.rb I would like to continue editing person.haml_spec.rb How would I go about doing this, elegantly?
Sam Saffron
  • 128,308
  • 78
  • 326
  • 506
453
votes
12 answers

Replace tabs with spaces in vim

I would like to convert tab to spaces in gVim. I added the following line to my _vimrc: set tabstop=2 It works to stop at two spaces but it still looks like one tab key is inserted (I tried to use the h key to count spaces afterwards). I'm not sure…
David.Chu.ca
  • 37,408
  • 63
  • 148
  • 190
448
votes
12 answers

Paste in insert mode?

Is it possible to paste in insert mode in Vim?
Amir Rachum
  • 76,817
  • 74
  • 166
  • 248
448
votes
4 answers

How to comment in Vim's config files: ".vimrc"?

How do I add a comment in Vim's configuration files, like .vimrc?
alexchenco
  • 53,565
  • 76
  • 241
  • 413
447
votes
15 answers

Vim: insert the same characters across multiple lines

Sometimes I want to edit a certain visual block of text across multiple lines. For example, I would take a text that looks like this: name comment phone email And make it look like…
hobbes3
  • 28,078
  • 24
  • 87
  • 116
446
votes
9 answers

How do I close all open tabs at once?

If I have 10 tabs opened, I have to close each one using ":q" separately. How can I close them all at once?
Srikanth
  • 11,780
  • 23
  • 72
  • 92
439
votes
12 answers

Changing Vim indentation behavior by file type

Could someone explain to me in simple terms the easiest way to change the indentation behavior of Vim based on the file type? For instance, if I open a Python file it should indent with 2 spaces, but if I open a Powershell script it should use 4…
EBGreen
  • 36,735
  • 12
  • 65
  • 85
429
votes
16 answers

Vim 80 column layout concerns

The way I do 80-column indication in Vim seems incorrect:set columns=80. At times I also set textwidth, but I want to be able to see and anticipate line overflow with the set columns alternative. This has some unfortunate side effects: I can't set…
cdleary
  • 69,512
  • 53
  • 163
  • 191
427
votes
2 answers

vim and NERD Tree extension - adding a file

When using the vim editor with the NERDTree plugin to navigate through the tree of your project, is there an easy way to create a new source code file under the currently highlighted directory? Currently I go into my shell, add the file and then…
Daniel
  • 16,026
  • 18
  • 65
  • 89
414
votes
14 answers

How to save and restore multiple different sessions in Vim?

Depending on my task in Vim I have several tabs open. How can I save different sessions for later use?
Jogusa
  • 5,530
  • 5
  • 24
  • 23
405
votes
25 answers

How do I run a terminal inside of Vim?

I am used to Emacs, but I am trying out Vim to see which one I like better. One thing that I like about Emacs is the ability to run a terminal inside Emacs. Is this possible inside of Vim? I know that you can execute commands from Vim, but I would…
Evan
  • 5,925
  • 6
  • 33
  • 35
401
votes
22 answers

Move entire line up and down in Vim

In Notepad++, I can use Ctrl + Shift + Up / Down to move the current line up and down. Is there a similar command to this in Vim? I have looked through endless guides, but have found nothing. If there isn't, how could I bind the action to that key…
user4812
  • 5,942
  • 9
  • 30
  • 35
397
votes
36 answers

Why should I use an IDE?

In another question, Mark speaks highly of IDEs, saying "some people still just dont know "why" they should use one...". As someone who uses vim for programming, and works in an environment where most/all of my colleagues use either vim or emacs…
Simon Howard
  • 8,999
  • 5
  • 28
  • 21