Most Popular

1500 questions
110
votes
4 answers

How can I show relative line numbers?

A lot of vim commands can take a number referring to the number of lines that the command will act on. Is it possible to show the line numbers relative to the current line? Something like the following: 3: some text here 2: more text 1: This is the…
Nick J Adams
  • 1,265
  • 2
  • 8
  • 11
106
votes
2 answers

How can I find out what is set to? And is it possible to remap ?

How can I figure out which key is set as my , and how do I remap it?
krampstudio
  • 1,245
  • 2
  • 9
  • 7
104
votes
2 answers

What is the purpose of swap files?

When I edit files, Vim tends to create files named .filename.swp, which I find annoying. From vim -h, I see that the -n option suppresses the creation of swap files. Is there a vimrc directive that I can use to disable swap files by default? What…
200_success
  • 9,549
  • 5
  • 51
  • 64
103
votes
4 answers

How can I yank (copy) the single character on which the cursor rests?

I know many ways to copy things: yiw = yank in current word yaw = yank all word (includes a trailing space) yy = yank the current line 3yy = yank three lines starting at the current one yap = yank all paragraph (includes trailing newline) I can…
Christopher Bottoms
  • 3,772
  • 6
  • 22
  • 33
103
votes
10 answers

How can I clear word highlighting in the current document (e.g. such as after searching for a word)?

When you search for a word in a file with something like /console.log, all of the instances of console.log are highlighted. When you're no longer interested in these, the highlighting can be distracting. My current strategy for removing the…
drs
  • 3,028
  • 3
  • 23
  • 27
102
votes
4 answers

List known filetypes

How can I get a list of the names of filetypes that vim currently knows about? I want to be able to do this so that when vim doesn't automatically detect a filetype I can try some of the filetypes vim knows about that may be similar and see if they…
Praxeolitic
  • 2,468
  • 2
  • 15
  • 28
99
votes
2 answers

Close and unload a buffer without exiting Vim

Often, I'll load some information into a temporary buffer, and then close it with :clo!. But this hides the buffer rather than unloading it entirely, even though I have nohidden set. I find this tiresome since I get an extra confirmation when I…
Kevin
  • 1,093
  • 1
  • 7
  • 8
95
votes
3 answers

Open filename under cursor like gf, but in a new tab (or split)?

The normal mode command gf go to a file with the path the cursor currently is at. But it does so in the current window, replacing the current text. That means you need to navigate back explicitly to go to the back later, and that you need to write…
Volker Siegel
  • 2,157
  • 2
  • 18
  • 21
95
votes
9 answers

How to execute shell commands silently?

:! can be used to execute a command in the shell. But this "takes over" my terminal and fills it with stdout of that particular command. How do I execute a command in the background that only notifies me on a non-zero exit code?
OrangeTux
  • 3,566
  • 3
  • 20
  • 27
92
votes
6 answers

Is there an easy way to close a scratch buffer/preview window?

One of the plugins I have installed (probably Supertab) provides a nice view of documentation for the currently highlighted item in the completion menu: The (apparently) scratch buffer remains open even after I exit the completion (by pressing…
muru
  • 24,838
  • 8
  • 82
  • 143
92
votes
6 answers

Vim search replace all files in current (project) folder

One of the open questions I have about Vim is if there is a way to perform a search/replace in the current project (bear with me if I use this notion inherited from other editors). For instance, let's assume I want to search my project files for a…
Simone Carletti
  • 1,210
  • 1
  • 10
  • 9
88
votes
9 answers

Fastest way to switch to a buffer in Vim?

One way to select a buffer in Vim could be to browse the buffers list, using standard commands as :ls, or with some external plugin / vimscript code to browse a list in a window. Let's say I want to jump to a buffer directly, as fast as possible. To…
Giorgio Robino
  • 2,044
  • 2
  • 17
  • 30
87
votes
4 answers

How do I fix the status bar symbols in the Airline plugin?

I installed the Airline plugin in order to have a custom status bar, as seen in the figure below: However, my status bar is presenting the symbols <, >> and <. How do I fix this problem?
Geison Santos
  • 989
  • 1
  • 7
  • 7
86
votes
7 answers

Swap the position of two windows

Say the following is the current structure of my window: +-----+---------------------------- | | | A | | | +-----+ | | | B | The order of A and B is not quite natural. It would be better if B was on top. However, if I go K, B…
Jason Hu
  • 1,385
  • 1
  • 9
  • 17
85
votes
8 answers

How to map Alt key?

I'm trying to map Alt key in the following way: :map j :map k but it doesn't work (bell is rang on Alt + j/Alt + k). What am I missing? I'm using Terminal on OSX, the same happens on remote Linux. On Ctrl + v, Alt + j, I've got: ?~H~F…
kenorb
  • 18,433
  • 18
  • 72
  • 134