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

3704 questions
589
votes
5 answers

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

Can you edit your .vimrc file and reload it without having to restart Vim?
ivo
  • 6,001
  • 3
  • 16
  • 5
477
votes
5 answers

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] to open files from command prompt and not from within Vim. split windows vertically or/and horizontally in separate tabs
Andrei Chikatilo
  • 5,069
  • 4
  • 17
  • 14
278
votes
7 answers

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 statusbar?
Jonas
  • 26,874
  • 52
  • 105
  • 125
263
votes
9 answers

In vim, how can I quickly switch between tabs?

In gnome-terminal, I can just press Alt + (1, 2, 3, etc.) to switch to specific tabs. I can also use Ctrl + (PgUp / PgDn) to cycle through tabs (admittedly less convenient, but it can be remapped). If I want to use vim tabs instead of gnome-terminal…
Matthew
  • 14,496
  • 18
  • 73
  • 119
223
votes
3 answers

How to delete all lines that do NOT contain a certain word in Vim?

In vim I can delete all lines that contain the word "price" with this :g /price/d How can I delete all lines that do NOT contain the word "price"?
digitaljoel
  • 2,603
  • 3
  • 19
  • 17
209
votes
5 answers

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 you do a new find and replace over the same selection?
labyrinth
  • 2,546
  • 2
  • 17
  • 15
179
votes
5 answers

How to run Unix commands from within Vim?

How can I run Unix commands while I'm inside vim?
funk-shun
  • 2,593
  • 3
  • 21
  • 15
165
votes
6 answers

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 afterwards. Why is that? This question was explicitly about…
DevSolar
  • 4,440
  • 5
  • 29
  • 38
150
votes
3 answers

Git on Mac: How to set Nano as the default text editor?

When I'm using Git on Mac and need to do a rebase, the Vim editor kicks in by default. I would prefer Nano – could someone please explain how to reconfigure Git to make it use Nano for rebase?
Dimitri Vorontzov
145
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
  • 2
  • 6
  • 8
142
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
  • 3
  • 14
  • 9
137
votes
3 answers

vim freezes inside tmux

I’m using split panes in tmux – one being vim, the other being a 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 happens only with tmux.  My only…
Ondrej Slinták
  • 1,623
  • 5
  • 15
  • 17
135
votes
14 answers

What's the easiest way to delete Vim swapfiles I've already recovered from?

Sometimes Vim crashes and leaves me a swapfile. That's awesome. Then I open the file I was editing and Vim asks me if I want to recover. I do, thanks. When it's done, Vim tells me, You may want to delete the .swp file now. Why, yes, I do. How…
Peeja
  • 2,839
  • 5
  • 25
  • 21
133
votes
6 answers

How do I 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 line the first line How could I do this in Vim?
Jichao
  • 7,145
  • 12
  • 52
  • 62
125
votes
4 answers

How does one switch between windows on VIM?

I'm using both Vim and MacVim (or well, trying to). I installed the Tagbar plugin but find it impossible to switch to the actual Tagbar window to make my selection. I've been reading loads about window switching in VIM, found a lot of default…
Naatan
  • 1,345
  • 2
  • 13
  • 13
1
2 3
99 100