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 Logo

Vim stands for Vi IMproved. 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

3739 questions
604
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,151
  • 3
  • 18
  • 5
498
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
301
votes
8 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
  • 28,660
284
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
  • 15,036
248
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,863
222
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,686
190
votes
6 answers

How to run Unix commands from within Vim?

How can I run Unix commands while I'm inside vim?
funk-shun
  • 2,753
169
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,940
168
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,560
163
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
151
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
  • 639
147
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
  • 3,009
143
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…
143
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,237
134
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…
1
2 3
99 100