All Questions

78
votes
7answers
14k 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 ...
62
votes
1answer
9k 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 ...
243
votes
7answers
178k 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?
189
votes
10answers
83k views

What is the difference between the vim plugin managers?

I have been looking at the different package managers for vim and the one I decided to use vim-plug but I have seen others like pathogen and vundle and I honestly don't know what the difference is. ...
92
votes
2answers
4k 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?
91
votes
7answers
126k 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?
9
votes
1answer
2k views

Mapping Ctrl with equal sign

I am trying to map my Ctrl and plus sign together. This is what I am trying in my vimrc: nnoremap <C-=> : echo "Hello" <CR> However it seems like the mapping is not being triggered. ...
24
votes
1answer
2k views

Disable <Esc> but keep <C-[>

For switching back from Insert mode I'm used to <Esc>. Now I'm looking to retrain myself to <C-[> instead of <Esc>. For that i need to disable <Esc> to help with the ...
16
votes
1answer
3k views

Can I map a Ctrl + upper-case letter separately from Ctrl + lower-case letter?

I am trying to figure out how to navigate windows little quicker, so I would like to map the following: :nmap <silent> <C-F> :wincmd f<CR> The problem is this remaps the ^f (lower-...
31
votes
5answers
21k 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 I'm missing? I'm using Terminal on OSX, the same ...
23
votes
1answer
7k views

How to edit files non-interactively (e.g. in pipeline)?

I would like to edit files passed in pipeline input using vim in non-interactive way or edit files in-place (similar to sed). Few examples using sed: $ sed -i'.bak' s/foo/test/g file # Edit file ...
35
votes
10answers
3k views

How to comment out a set of lines which are selected in visual mode?

How do I comment out multiple in visual mode selected lines? How do I make it language specific? For example, if the first 4 lines are selected: def foo(a,b): for each in (a,b): print ...
22
votes
4answers
13k views

What is the difference between the vim snippets plugins?

There is a great number of snippets plugins for vim: ultisnips, snipmate, xptemplate, neosnippet and a lot more. They all have pros and cons and more or less dependencies. So far I've been using ...
131
votes
5answers
83k 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 ...
32
votes
4answers
7k views

How can I change the default indentation based on filetype?

I'd like to have different indentations based on the type of file I am working on. For example, working on a .c file I'd like my indentation be 4 spaces. In .html files I'd like to (have to) work with ...
27
votes
3answers
779 views

Why can ci" be outside of quoted area and ci( only works inside parentheses?

When using ci" the cursor does not have to reside in the double quoted area. |String somestring = "some text"; Assuming the pipe is the cursor position, ci" will make it jump to the quoted area. ...
8
votes
2answers
3k views

Mapping Ctrl+s does not work

I am trying to map Ctrl+s to save my file however it does not work. My mappings: map <C-s> :w <CR> :echo "Saved" <CR> imap <C-s> <Esc> :w <CR> :echo "Saved" <...
53
votes
4answers
11k 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 ...
35
votes
5answers
9k views

Detect OS in Vimscript

Can I retrieve the current operating system (Windows, Linux, OS X, ..) using pure Vimscript (no Python or Perl)? I want to enable different settings in my (synchronized) .vimrc for different types of ...
31
votes
2answers
2k views

Can I see the history of key presses in normal mode?

I know that Vim keeps history for ex commands, searches, jump locations, changes, and possibly others. With showcmd set, Vim also shows you what keys you have entered so far for a normal mode command,...
29
votes
3answers
8k views

Why should I use augroup?

I understand how auto commands work, and how to use them, but I'm a little bit sure of what augroup is for. I read in :help augroup *:aug* *:...
9
votes
1answer
2k views

Why do custom highlights in my vimrc get cleared or reset to default?

I would like to highlight (part of) my statusline with %1*, for example: set statusline=%1*%f%0* highlight User1 ctermbg=0 ctermfg=10 cterm=bold However, this always shows up as "empty" (the default ...
58
votes
4answers
44k 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?
29
votes
5answers
2k views

Performing certain operations without clearing register

Frequently, in configuration files I might copy and paste a block of lines, then I want to make small changes to that block. After pasting, I use x to delete characters that I want to remove, then ...
11
votes
3answers
6k views

Multiple cursors at desired location

I'm using vim-multiple-cursors plugin. I would like to put cursors exactly where I want. For example ([x] are the cursor positions): Lorem ipsum dolor sit amet[1], consectetur adipiscing elit, sed ...
62
votes
2answers
20k 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?
27
votes
4answers
4k views

How can I make Vim autoread a file while it doesn't have focus?

I'm using VIm for all kinds of things (or gVim in this case), including monitoring output written to a file; I use autoread to make Vim reread the file, which it does whenever I switch the keyboard ...
8
votes
1answer
4k views

How can I add additional syntax highlighting rules in my local vimrc?

I installed gvim on both Fedora and Win7. I found that both vim and gvim on Fedora didn't highlight the function name in c code while gvim on win7 did highlight it. I found that on win7, vim73/...
16
votes
1answer
216 views

Prevent Vim from breaking up links mid-tag in markdown

Let's say I have this Markdown file: [Lorem ipsum dolor sit ](http://vi.stackexchange.com/many-links-are-often-very) Lookin' good. But the link isn't finished it, so I type -long, and now Vim breaks ...
6
votes
2answers
2k views

Vim doesn't use the correct indentation in Python files

I have encountered something that I have never seen before in Vim. While I was tentatively modifying some of the source code for software I've been planning to work on, I noticed vim was displaying ...
4
votes
1answer
481 views

How to map shortcut to double square brackets?

When I type [[ or ]] in normal mode, cursor is jumping previous / next "class definition" during editing python (.py) file. I want to map these shortcuts to SHIFT + UP and SHIFT + DOWN. And I added ...
41
votes
2answers
10k views

What are the differences between LaTeX plugins?

There are a number of Tex plugins for vim (vim-latex, AutomaticLatexPlugin to say a couple). What are the differences in the provided functionalities between these (the ones I named and possibly ...
82
votes
5answers
61k 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.
48
votes
2answers
15k views

How can I get vim to stop putting comments in front of new lines?

I'm editing my .vimrc file, and I am including comments. When I have a comment like this: " example comment And then hit enter at the end of the line after finishing the comment, the next line is ...
68
votes
9answers
29k 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 ...
28
votes
5answers
8k views

What is the easiest way to insert Unicode characters into a document?

When writing documents occasionally I want to insert Unicode characters into the text. Sometimes I know the character code and sometimes I look it up on the web. Currently I go to insert mode and ...
20
votes
4answers
3k views

How to use an external command in Vim to modify selected words and lines?

Something I've found useful in other editors is the ability to: take the selected text run an external command and pass the selection to its stdin take the external commands stdout and replace the ...
29
votes
1answer
13k 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
26
votes
8answers
1k views

How do I move vertically until reaching a non-whitespace character?

In a very long file with (accurately-) indented code, it may be helpful to move directly to a line of text above or below the cursor which delimits the indenting. (One way of doing this could be via ...
48
votes
3answers
4k views

How do I reload my vimrc without leaving Vim?

When I do a change in my .vimrc, I usually exit Vim and open it again. Is there an easier way to reload the new .vimrc changes?
19
votes
8answers
3k views

How to add permanent line numbers to a file?

I have a text file like this (using gVim on Windows) foo bar baz quux corge grault garply waldo fred plugh [...150 more lines...] xyzzy thud I want to add a number to each line in the file. Not ...
19
votes
4answers
3k views

How do I deal with very long lines in text (500+ characters)?

For some text formats, line breaks matter. For example, I often use Vim to write MediaWiki documents, where you can't just put a linebreak anywhere (unlike Markdown). So I'm forced to write lines ...
13
votes
6answers
1k views

How to bind a set of buffers to a tab?

When I need to work on different projects at the same time I have the folowing workflow: I create one tab for each project. In each tab I open the files that I want to edit, which makes several ...
13
votes
3answers
918 views

How do I visually select the block of text I just pasted in Vim?

I usually need to move/copy code snippets between my source files. After I paste a block of text, I usually need to apply some operation to that block such as reindenting them with =. Is there a way ...
32
votes
6answers
2k views

Applying settings to a directory tree only

At my work we use a standard ts of 2; my personal preference is 4, which is what I use for my hobby projects, and this other project we inherited has the convention of ts=8. There are also some other ...
14
votes
1answer
1k views

Show partially hidden wrapped lines

I have turned on line wrapping with set wrap linebreak nolist in my .vimrc. However, this has the annoying behavior that lines not completely visible on the screen are hidden outright and replaced ...
9
votes
1answer
2k views

Define custom commands for the * and + registers

If I'm using a build of Vim with the xterm_clipboard feature then the system clipboard content is available through the + register. If the build I'm using doesn't have this feature, can I make the "+ ...
23
votes
4answers
709 views

How can a complete beginner learn Vim using just Vim itself?

As a complete beginner with no vi experience, how can I learn to use Vim using just Vim itself? Is there a built-in tutorial, and how can I access it? Assume I have a laptop with Linux and Vim ...
16
votes
3answers
298 views

Speed bump on <Esc>O (Insert to Normal to Insert new line above cursor)

Often when I'm in Insert mode, I'll hit Esc to get into Normal mode, and then immediately hit O to begin a new line above the cursor and go into Insert mode there. But when I do that, there is a 1-...
9
votes
3answers
2k views

How do I add skeleton text to new vim files?

I use Vim for writing C++, and I have quite a few #include<> statements, comments, etc. that I must include in each new file I create. I've added autocmd BufNewFile *.cpp r C:\(full file path ...

15 30 50 per page