All Questions

Filter by
Sorted by
Tagged with
507 votes
13 answers
663k views

How can I copy text to the system clipboard from Vim?

Is there a way to copy a block of text to the system clipboard, so I can paste it in another program?
thameera's user avatar
  • 17k
322 votes
5 answers
245k views

How do I reload the current file?

Quite often I am working with files that are version controlled, so it is possible for changes to be made to them outside of Vim. What is a quick way to reload the file without having to close and ...
Kevin Brown-Silva's user avatar
312 votes
10 answers
177k views

What are the differences between the Vim plugin managers?

I have been looking at the different package managers for Vim, and the one I decided to use is vim-plug. However, I have seen others like pathogen and vundle, and I honestly don't know what the ...
ZucchiniZe's user avatar
  • 3,223
251 votes
13 answers
181k views

How can I see the full path of the current file?

When I'm editing a file in Vim, is there a command to see the path of the current file? Sometimes this is very handy if there are multiple files with the same name in a project.
thameera's user avatar
  • 17k
231 votes
6 answers
165k views

How do I change the current split's width and height?

I am working on split (using ^w+v, ^w+s) buffers, but sometimes I would like to widen a current split or change its height. How can I achieve that?
Nebril's user avatar
  • 3,367
230 votes
6 answers
206k views

Why doesn't the backspace key work in insert mode?

Trying to delete characters in insert mode with the backspace key sometimes doesn't seem to work. I can backspace sometimes, but at other times it does nothing; the cursor doesn't go to the left, and ...
glS's user avatar
  • 3,789
208 votes
6 answers
194k views

What's the simplest way to strip trailing whitespace from all lines in a file?

It's pretty common when programming or opening text files to encounter files with trailing whitespace at the end of a line. vim has a way to show this by setting the trail option in the listchars ...
Andrew Ferrier's user avatar
207 votes
9 answers
257k views

How can I display tabs as characters?

When I work on files in python, I sometimes mistake tabs for spaces and vice versa. Is there a way I can get Vim to display a character for a tab instead of a tab?
Dom's user avatar
  • 3,265
202 votes
11 answers
274k views

How do I use Vim as a diff tool?

I use Vim as my primary editor. I would also like to use vim to diff files and modify the files while doing the diff to fix easy changes (rather than most diff techniques which are a cycle of diff, ...
Martin York's user avatar
  • 6,392
194 votes
6 answers
93k views

What is Neovim, and how is it different from Vim?

I've been hearing about Neovim; how does it differ from Vim? All the points on the homepage are just architectural changes 'under the hood'. As a user, what's the difference for me?
Martin Tournoij's user avatar
191 votes
9 answers
81k views

Does Ex mode have any practical use?

Vim has an Ex mode that can be entered by entering Q, and a command line mode that can be entered with q:. A common complaint amongst new vim users is that they enter these modes accidentally when ...
Andrew Ferrier's user avatar
170 votes
2 answers
331k views

How can I use Vim as a hex editor? [duplicate]

Is there a neat way I can view binary files as hex in Vim, and save it back to binary from the hex?
nos's user avatar
  • 1,853
152 votes
4 answers
53k views

What is the Vim8 package feature and how should I use it?

Vim 8 was released today and the release notes mentions a new "package" feature. What is it and how should I use it? Most importantly, does it replace the good old plugin managers?
statox's user avatar
  • 49.4k
146 votes
10 answers
97k views

How to format JSON file in Vim

Given a file with a large JSON object all on one line like {"versions":[{"count":2,"version":""},{"count":1,"version":"1.1.1"},{&...
ljs.dev's user avatar
  • 2,507
143 votes
17 answers
180k views

Other ways to exit Insert mode besides Escape

The primary reason I like vim over emacs is that my hand movement distance away from the home row is very low (even as a programmer). However, the one main time that I do this is leaving insert mode, ...
durron597's user avatar
  • 2,131
143 votes
7 answers
196k views

How do I install a plugin in Vim/vi?

How do I install a plugin in Vim? Does it matter: Whether I use vi or Vim? Whether I use gVim? Which version of Vim I'm using? What my OS is?
elyashiv's user avatar
  • 2,429
142 votes
13 answers
129k views

Exit from Terminal mode in Neovim/Vim 8

I can't figure out how to go back to Normal mode after entering Terminal in Insert mode... Escape just doesn't seem to work. Any idea?
Stephane Rolland's user avatar
137 votes
8 answers
195k views

How can I easily move a line?

What is the command (or shortcut) to move a line up or down in vim? My current workflow is to yank (copy) the line and than delete that line and than to put (paste) that line.
Vader's user avatar
  • 1,615
134 votes
5 answers
162k views

How to replace tabs with spaces?

Is it possible to convert tabs to spaces, while maintaining text alignment? Simply replacing only works usefully when there are no leading characters.
ideasman42's user avatar
  • 3,683
134 votes
3 answers
16k views

How do I navigate to topics in Vim's documentation?

In Vim's built-in help system, how do I… search for topics that I want help on? follow hyperlinks? browse around for related material?
romainl's user avatar
  • 39.3k
133 votes
6 answers
38k views

How do I jump to the location of my last edit?

I often make changes to the middle of a big file, use gg to jump to the top to check something, and then realize I forgot to set a mark where I was editing. Is there a built-in way to jump to the ...
bdesham's user avatar
  • 2,923
128 votes
4 answers
187k views

Is it possible to split Vim window to view multiple files at once?

When working with multiple files, it would be very handy if we can see more than one file in the screen at once. Is there any way in Vim to split the window (horizontally or vertically) so each split ...
thameera's user avatar
  • 17k
125 votes
7 answers
92k views

Is there a way to count the number of occurrences of a word in a file?

Is it possible to count how many times a word or a pattern appears in a file? This is sometimes useful to find out how many times a function has been called, etc.
thameera's user avatar
  • 17k
121 votes
8 answers
113k views

How to share config between Vim and Neovim

I started using Neovim and moved my .vimrc to .config/nvim/init.vim and other stuff is located in .local/share/nvim. What is the best way to share configs or even plugins between Vim and Neovim? ...
lumbric's user avatar
  • 1,499
116 votes
16 answers
107k views

How do I delete a large block of text without counting the lines?

In vim, I often need to delete, or yank/put large blocks of text. I can count the lines of text and enter something like 50dd to delete 50 lines. But that's a bit of a pain. How can I delete this ...
user avatar
116 votes
9 answers
251k views

What is the command for "Select All" in Vim and VsVim?

How do I select all the content of a file in Vim and VsVim? Like in other editors Ctrl-A does the job for select all.
Armaan's user avatar
  • 1,263
116 votes
8 answers
136k views

How to edit binary files with Vim?

Is there a way to edit binary files in some kind of hexadecimal mode? For example if I have some binary data shown by xxd or hexdump -C like this: $ hexdump -C a.bin | head -n 5 00000000 cf fa ed ...
janos's user avatar
  • 2,818
116 votes
5 answers
30k views

How to join lines without producing a space?

The standard J command for joining lines replaces the newline character(s) with a space. It's useful when editing 'literature' but can be troublesome if I, say, edit a hex dump by hand if I forget to ...
SF.'s user avatar
  • 2,059
111 votes
1 answer
30k views

How to debug a mapping?

I see a lot of questions on here where a user has a mapping which doesn't work and most of the time the reasons are pretty similar. I suggest to make this question a reference for this kind of ...
statox's user avatar
  • 49.4k
110 votes
8 answers
34k views

How do I debug my vimrc file?

I have a problem in Vim, and I think it may be in my vimrc file (or have been told it could be my vimrc file). How do I verify this? If it is my vimrc file, how do I know where exactly the problem ...
Martin Tournoij's user avatar
105 votes
4 answers
80k views

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 ...
Nick J Adams's user avatar
  • 1,215
103 votes
10 answers
157k views

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 ...
drs's user avatar
  • 3,018
103 votes
2 answers
85k views

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 ...
200_success's user avatar
  • 9,379
102 votes
2 answers
59k views

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

How can I figure out which key is set as my <Leader>, and how do I remap it?
krampstudio's user avatar
  • 1,205
101 votes
4 answers
37k views

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 ...
Praxeolitic's user avatar
  • 2,448
101 votes
4 answers
53k views

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 ...
Christopher Bottoms's user avatar
98 votes
2 answers
68k views

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 ...
Kevin's user avatar
  • 1,083
95 votes
9 answers
67k views

How to execute shell commands silently?

:!<command> 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 ...
OrangeTux's user avatar
  • 3,536
93 votes
3 answers
31k views

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 ...
Volker Siegel's user avatar
90 votes
6 answers
45k views

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'...
Simone Carletti's user avatar
89 votes
6 answers
49k views

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 ...
muru's user avatar
  • 24.7k
86 votes
4 answers
101k views

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's user avatar
84 votes
8 answers
72k views

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 ...
Giorgio Robino's user avatar
83 votes
6 answers
77k views

How can I set up a ruler at a specific column?

When coding in different languages, I tend to need to restrict my lines to a specific length (usually 79 or 80 characters). I've seen this done in other editors through the use of a ruler (solid line ...
Kevin Brown-Silva's user avatar
83 votes
1 answer
36k views

How to open multiple files in split mode?

I know how to split windows in vim, but it's possible to open multiple files using vim in split mode (at startup) from the command line? In example: vim file1 file2 file3 or: vim *.cpp
kenorb's user avatar
  • 18.2k
82 votes
7 answers
46k views

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 ...
Jason Hu's user avatar
  • 1,345
82 votes
8 answers
88k views

How to map Alt key?

I'm trying to map Alt key in the following way: :map <A-j> j :map <A-k> 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 ...
kenorb's user avatar
  • 18.2k
81 votes
11 answers
132k views

How can I change the font size in gVim?

Is there a way to change the size of the font in gVim, using native commands? And if not, what script can be used to do it quickly?
glS's user avatar
  • 3,789
81 votes
1 answer
27k views

What is the select mode and when is it relevant to use it?

I accidentally pressed gh in normal mode and started a selection, so I looked up the doc and found :h Select-mode. From what I understand the select mode is close to the visual mode excepted that: ...
statox's user avatar
  • 49.4k
77 votes
4 answers
27k views

How to save window, split, and buffer layout?

I have several tasks I am working on in one repository. I would like to create "workspaces" for working on them. One "workspace" or "buffer layout" would have all files I need to work on open in the ...
Nebril's user avatar
  • 3,367

15 30 50 per page
1
2 3 4 5
284