All Questions

Filter by
Sorted by
Tagged with
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
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
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
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
12 votes
1 answer
3k views

How do I use a variable or return value in option, command, or mapping?

I have a variable foo with let foo='value', and a function F like function F() return 'value' endfunction and I want to use them in an option: :set option=foo, :set option=F(); or in a command: :...
D. Ben Knoble's user avatar
  • 25.4k
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
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
27 votes
1 answer
7k 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-...
user1135541's user avatar
  • 1,103
15 votes
1 answer
5k 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. ...
James Franco's user avatar
  • 1,081
49 votes
4 answers
31k 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 ...
statox's user avatar
  • 49.4k
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
76 votes
3 answers
30k views

Why should I use augroup?

I understand how auto commands work, and how to use them, but I'm somewhat unsure of what augroup is for. I read in :help augroup *:aug* *:augroup* :...
DJMcMayhem's user avatar
  • 17.4k
29 votes
4 answers
23k 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 ...
tomasyany's user avatar
  • 444
28 votes
1 answer
4k 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 ...
mxlian's user avatar
  • 545
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
45 votes
4 answers
17k 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 ...
DeltaLima's user avatar
  • 1,145
28 votes
1 answer
14k 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 ...
kenorb's user avatar
  • 18.2k
14 votes
1 answer
4k 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 ...
Martin Tournoij's user avatar
41 votes
12 answers
8k 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 ...
JHK's user avatar
  • 755
17 votes
5 answers
2k views

Why does this <Esc> normal mode mapping affect startup?

I'm experiencing a weird problem with a normal mode mapping of Esc. If you create the file escmapvimrc with the contents: set nocompatible set showcmd " Doesn't affect the problem: just makes it ...
Rich's user avatar
  • 31.3k
16 votes
5 answers
3k views

How to run a substitute command on only a certain part of the line

I have the following line in my code: INCORRECT_EMAIL_MOBILE_COMBINATION("incorrect_email_mobile_combination"); When I try to substitute the underscores with spaces in visual mode (using :'<,'>...
TheChetan's user avatar
  • 407
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
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
12 votes
3 answers
4k 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" <...
iProgram's user avatar
  • 1,589
6 votes
1 answer
297 views

Mathematical expressions in TeX files are displayed in a human-readable way

When I type some mathematical expressions in Tex files using Vim, e.g. a_{2} = a_{1} + a_{0}, it is displayed in a human readable way like a2 = a1 + a0. (Actually the numbers are of a smaller font, ...
hitochan's user avatar
  • 215
41 votes
2 answers
4k 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,...
John O'M.'s user avatar
  • 8,472
40 votes
6 answers
4k 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 ...
Martin Tournoij's user avatar
34 votes
5 answers
3k 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 ...
durron597's user avatar
  • 2,131
22 votes
1 answer
14k 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/...
tamlok's user avatar
  • 831
9 votes
3 answers
10k 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 ...
BenB's user avatar
  • 193
73 votes
6 answers
25k 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 ...
muffel's user avatar
  • 1,007
31 votes
4 answers
2k 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. ...
Reaver's user avatar
  • 603
31 votes
4 answers
7k 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 ...
Martin Tournoij's user avatar
27 votes
1 answer
5k views

How to make movements respect camelCase or snake_case?

It is common to use either camelCase or snake_case to separate multiple words which form an identifier. It would be nice if the "word" movements (b, w, e) would detect those inner-identifier ...
Jasper's user avatar
  • 515
24 votes
3 answers
15k views

How to use a variable in the expression of a 'normal' command?

How can one use a variable when executing something via normal! in vimscript? Example: function! MyFunction(someArg) normal! (a:someArg)l endfunction This should move the cursor someArg steps ...
user avatar
13 votes
3 answers
1k views

Scrolling issues when the `wrap` option is set

I find myself dealing with this issue every time the wrap option is active (in my particular case whenever I'm working with markdown files). What happens is that, while scrolling up and down the ...
mrzool's user avatar
  • 1,002
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
74 votes
13 answers
150k views

How to insert a newline without leaving normal mode

I wonder if I can insert a new line without leaving normal mode. For example, I have two lines: this is line one this is line two And the cursor is on line one. Now I want a new line between line ...
Alex's user avatar
  • 1,175
60 votes
3 answers
11k 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?
thameera's user avatar
  • 17k
38 votes
4 answers
9k 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 ...
falstro's user avatar
  • 483
36 votes
8 answers
3k 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 ...
alxndr's user avatar
  • 1,356
30 votes
3 answers
10k views

What is the order of WinEnter, BufEnter, BufRead, Syntax, FileType events?

I've gone through the autocmd.txt help, but the information about this is scattered and not always present (eg. with BufRead). Could someone who understands this well list the order of these events -...
Sundar R's user avatar
  • 751
27 votes
3 answers
10k views

What does `<Bar>` mean?

In answering a question just now, I mentioned using a normal mode key mapping that can be found at the Vim Tips Wiki. In the middle of explaining the key mapping, I realized that I had no idea what &...
Christopher Bottoms's user avatar
18 votes
1 answer
2k views

What does it mean to replace slashes (/) by exclamation marks (!) in a substitute command?

I recently saw a substitute command where the author had the / replaced by a ! like this: :s!abc!ABC!g I tried to find some documentation on this usage but I couldn't find anything relevant. So I ...
statox's user avatar
  • 49.4k
17 votes
5 answers
4k views

How can I open multiple tabs at once?

If I use: :tabedit file1 file2 I get: E172: Only one file name allowed Is there any way to use :tabedit with multiple file names? Or another way to open multiple tabs at once?
Martin Tournoij's user avatar
11 votes
3 answers
5k views

Bash not recognizing aliases when run from Vim [duplicate]

In Vim, when I run this command :!bash -c "ll", I get this error message bash: ll: command not found. ll is an alias in my ~/.bashrc file. If I just enter ll from bash it works. I created a ~/....
still_dreaming_1's user avatar
8 votes
1 answer
2k views

Mapping control-H in insert mode doesn't work; it always works like backspace

I tried mapping control-H, J, K, and L respectively in insert mode to move around splits. inoremap <C-h> <ESC><C-W><C-h>i inoremap <C-l> <ESC><C-W><C-l&...
matts1's user avatar
  • 181
6 votes
3 answers
3k views

Strange behavior of <ctrl-j> remapping

I want ctrl-h, ctrl-j, ctrl-k and ctrl-l in insert mode to behave like the arrow keys. I have this (among other things) in my .vimrc: inoremap <C-j> <Down> inoremap <C-k> <Up&...
DJMcMayhem's user avatar
  • 17.4k
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
202 votes
11 answers
275k 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

15 30 50 per page
1
2 3 4 5
33