Skip to main content

Questions tagged [vimrc]

Vim reads initialization commands from a file called vimrc on startup. This can be used to set settings, define functions, execute autocommands, and more.

Filter by
Sorted by
Tagged with
111 votes
8 answers
35k 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
18 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
  • 32k
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
22 votes
1 answer
15k 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
  • 841
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
  • 17.5k
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.6k
11 votes
2 answers
2k views

How do I prevent Vim from unindenting empty lines?

Vim keeps unindenting the lines I want to keep indented if I don't write anything on them... I'll give an example, where the | is the caret. Caret is indented and I press enter if expression: ...
user6256's user avatar
  • 113
5 votes
1 answer
2k 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 ...
Umut Çağdaş Coşkun's user avatar
5 votes
1 answer
1k views

Vim never shows line number for Python files even though I have `.vimrc`

I found it strange that I can never have Vim show line number automatically for .py files, even if I have this as my ~/.vimrc set background=dark autocmd FileType py,c set number Strangely enough, ...
iBug's user avatar
  • 257
4 votes
1 answer
2k views

How to load plugins from my vimrc and from another file?

I have my dotfiles synchronized on github which is a current practice. As I use several machines I want to be able to have some part of my configuration not synched on my github repo. To do so I ...
statox's user avatar
  • 49.9k
89 votes
9 answers
77k 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
22 votes
3 answers
2k views

The simplest way to start Vim in private mode

I want to be able to easily start Vim in a private mode. Let's define a private mode as one that utilizes this set of commands: set history=0 set nobackup set nomodeline set noshelltemp set ...
Mateusz Piotrowski's user avatar
11 votes
3 answers
4k 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 ...
electriccello's user avatar
11 votes
2 answers
9k views

How to make vimrc settings applicable for a directory tree only [duplicate]

Is there a way to make certain vimrc configuration valid only for files under a defined directory tree? Or alternatively, is there a way to have a .vimrc file in a directory, and make its setting ...
guido's user avatar
  • 1,757
7 votes
2 answers
8k views

Usage of timeoutlen and ttimeoutlen

I was trying to set a timeout length to apply to: Key combination presses (for example, pressing gh in netrw); and Exiting modes (for example, zero delay when exiting visual mode). Here is a portion ...
David542's user avatar
  • 2,455
4 votes
1 answer
601 views

Vim on Debian, configuration issues

I have been working with a stock vim configuration for a long time. I want to modify just a couple of settings. I don't want to lose the rest of the default configuration. If I create a new .vimrc I ...
Spiru's user avatar
  • 43
31 votes
3 answers
10k views

How can I redefine plugin key mappings?

I have installed a plugin that doesn't provide a mechanism to disable the key mappings it defines. I want to redefine one of the mappings (<leader>cc) defined by the plugin for my own pursope, I'...
toro2k's user avatar
  • 4,912
22 votes
2 answers
3k views

What is the difference between set and :set (commands with or without a leading colon)?

I was looking at Tim Pope's vim-sensible plugin and I noticed this in the README... See the source for the authoritative list of features. (Don't worry, it's mostly :set calls.) When I looked at ...
Ethan's user avatar
  • 473
7 votes
2 answers
199 views

a highlight command resets previously declared highlights

I'm trying to tune the highlighting in my vim and I'm trying to set some syntax groups via the match command and highlight them in my vimrc file, because those groups are generic and do not belong to ...
d.k's user avatar
  • 692
3 votes
1 answer
2k views

Fire autocmd FileType on current buffers in windows

Context I have shortcuts to edit my vimrc and to source my vimrc. When I'm writing code I can quickly add a new mapping and then source vimrc. And all that would be good if I did not use autocmd ...
grochmal's user avatar
  • 1,656
1 vote
1 answer
96 views

How to display multiple changed files on disk in Vim?

Related to this thread, How can Vim tell me which buffer is changed on disk among multiple buffers? This Vim configuration automatically checks for changes in opened buffers and notifies when a single ...
Mega Bang's user avatar
  • 199
26 votes
8 answers
9k views

Is there a best practice to fold a vimrc file

I recently realized that my vimrc is now more than 400 lines long (which IMO is too much I'll try to reduce that) and to make it easier to navigate, read and edit it I decided to investigate the ...
statox's user avatar
  • 49.9k
13 votes
1 answer
3k views

Why does the order of :set bg=dark and :set bg=light matter?

While trying to match up my terminal's colour palette and GVim's I noticed this: When I open GVim and Vim, I see: (That's the same file, my vimrc.) If I do :set t_Co=256, nothing happens in GVim (...
muru's user avatar
  • 24.9k
12 votes
1 answer
360 views

Prevent Vim from recording events for certain filetypes

To add to this stackoverflow question, what should one put in their .vimrc to ensure 'private editing' of certain file extensions (e.g. .gpg files). Without compromising the effectiveness of the ...
jyalim's user avatar
  • 531
12 votes
7 answers
13k views

How can I copy/paste new text without auto-indentation at every new line?

How I paste now: Right-click/Copy or simply highlight. Right-click/Paste or Middle Click or CTRL+SHFT+V Indents appear at increasing intervals: 0, 2, 4, 6, + Question at hand: From prior research, ...
user avatar
7 votes
1 answer
4k views

In what order does vim read ftplugin files, syntax files, and the .vimrc when `filetype plugin on` and `set syntax=filetype` are called?

I've had some issues reconciling my .vimrc with files in ftplugin and after/ftplugin. In what order are they all read? For example: When vim encounters the line plugin filetype on in a .vimrc file, is ...
Luke Davis's user avatar
  • 1,397
5 votes
2 answers
743 views

Map CTRL-& in vimrc

I'm trying to re-map tagbar toggling with <C-&> that I get used to when working with IDEs. But setting execute "nnoremap <C-&> :TagbarToggle<CR>" does not have the ...
St.Antario's user avatar
  • 1,117
4 votes
1 answer
354 views

Vimrc tries to execute command defined on leader

I'm trying to have something like this in my .vimrc: nnoremap <leader>has :w | ! reset; runhaskell % <cr> How ever, now it prompts an error when loading .vimrc and tells me: :! reset; ...
Stephane Rolland's user avatar
2 votes
1 answer
786 views

I'm using a colorscheme installed with vim-plug, how can I change the color of the line numbers? [duplicate]

I'm using this colorscheme, how can I change the color of the line numbers? I think that the colorscheme will overwrite anything I'll put in .vmrc.
idankor's user avatar
  • 145
104 votes
2 answers
87k 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,559
35 votes
4 answers
82k views

Remap Esc key in Vim

Is it possible to remap the Esc key to another key in Vim? When I'm using Vim in a full screen VMware vSphere web client console window and I press the Esc key to exit edit mode, it also takes me out ...
Beam Davis's user avatar
26 votes
5 answers
2k views

GitHub for .vimrc and plugins

I know many people store their .vimrc on GitHub to make it easier to get right to work on new machines, and that makes complete sense to me. Including plugins, however, is problematic, because the ...
Tom's user avatar
  • 1,240
21 votes
2 answers
4k views

How to define a custom popup / menu in vimrc?

Assigning every useful function to a key works well for frequently used tools, but there are some operations I use so rarely, that I would prefer to assign them to some popup menu defined in my vimrc. ...
ideasman42's user avatar
  • 3,733
18 votes
2 answers
1k views

How do I make Vim use a default filename when not given any filenames?

I rarely, if ever, just open vim without filenames. Often enough, I want to test something out, usually a quick throwaway script, and I usually name them test.sh (or some variant thereof, like test.py)...
muru's user avatar
  • 24.9k
17 votes
4 answers
13k views

How can I make highlighting commands in .vimrc take effect immediately with Vim 7.4?

I have several highlight commands in my .vimrc file. In Vim 7.3, these took effect immediately after Vim had started. After updating to Vim 7.4, this is not the case anymore. Vim uses its default ...
Wolfgang Jeltsch's user avatar
15 votes
1 answer
390 views

Using <C-,> causes "<80>ü^D," to flash in the showcmd area?

I've mapped <C-,> as well as some other special keys (<C-Enter>, <C-S-Space>, ...) in my vimrc like, :set <F13>=^[[44;5u :map <F13> <C-,> :map! <F13> <C-...
ivan's user avatar
  • 1,450
13 votes
1 answer
2k views

How to record my keyboard input to do statistics on it?

I would like to find out what are the most common patterns I'm using during coding. So I'm looking for a way to record all my keyboard input while I'm in Vim, preferably with timestamps. Then I could ...
6D65's user avatar
  • 413
12 votes
1 answer
1k views

Is it possible to create custom "set" commands in my rc file and call them from a modeline?

I recently asked a question in which I learned that it is not possible to pass anything except parameters to :set in vim modelines. I understand the security concerns, but I'm wondering if there isn't ...
Caleb's user avatar
  • 2,245
11 votes
1 answer
3k views

how to load vim8 optional packages in vimrc?

I am trying to load my optional language packages based on filetype. I am using vim8 native package feature. In vim I can load them with :packadd vim-javascript. However, I read in :help packadd - (...
The Fool's user avatar
  • 221
11 votes
2 answers
4k views

How to jump to buffer from ls?

Is there any way to jump to a buffer by entering buffer number right from :ls? I mean, why this command expect me to Press ENTER or type command to continue, if pressing for example 2, wouldn't do ...
kAldown's user avatar
  • 223
10 votes
2 answers
2k views

Visual scrolling/visual <C-e> and <C-y> across wrapped lines?

This has been asked on stackoverflow before, but it seems it still has no solution. Perhaps that has changed with Vim 8.0. I'd like to be able to scroll (i.e. scroll-wheel, or <C-y>/<C-e> ...
Luke Davis's user avatar
  • 1,397
9 votes
2 answers
4k views

key mapping best practices

I found that I frequently needed a command in INSERT mode to open a line above the cursor (what O does in NORMAL mode) I put this in my .vimrc inoremap ao <esc>O It works well. I chose the ...
sudo bangbang's user avatar
8 votes
2 answers
5k views

Why can't I paste commands into vi?

I've been using vi for 40 years. A week ago I upgraded; Disaster struck! The upgrade was to VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 4 2018 23:38:28) I run this on xterm under Cygwin (...
user19858's user avatar
  • 171
8 votes
2 answers
966 views

How can I increase floating number with ctrl-a without deleting zeros?

When I'm trying to increase numbers with CtrlA it removes the leading and the trailing zeros. For example: 1.009500 1.09500 1.0009500 Results after pressing CtrlA: 1.009500 -> 1.9501 1.09500 ...
whitesiroi's user avatar
7 votes
1 answer
1k views

Sharing vimrc options in different computers [closed]

Can I easily keep my vimrc files consistent across multiple computers? I have different computers (laptop, desktop home and desktop work) and I want to keep my Vim configuration consistent, ...
Khelben's user avatar
  • 3,187
7 votes
2 answers
4k views

Multiple vimrc files for different file types in vim?

I'm a vim beginner. I want to handle multiple programming languages. I find great resources for how to perfect vim for one programming language by putting ton of stuff in one vimrc file. This is ...
goonyMachine's user avatar
7 votes
1 answer
2k views

Change command depending on file extension/type

I usually work with php projects and phpunit. I've mapped <leader>T thus I can run tests. # my .vimrc file portion nnoremap <Leader>T :!vendor/bin/phpunit --filter function! ...
sensorario's user avatar
6 votes
2 answers
5k views

How to set a colorscheme that still shows spelling errors?

How to set a colorscheme that still shows spelling errors? I am looking for two combined effects that I can acquire separately but not yet together. Set Colorscheme alone: OK. If I want highlights ...
nilon's user avatar
  • 217
6 votes
1 answer
226 views

Disable spell checking for URLs in BibTeX

I would like to disable spell checking for the URLs in my BibTeX (.bib) files. I was able to disable spell checking for the citation keys (author-year or author+year) as follows: autocmd FileType bib \...
Rudolf Adamkovic's user avatar
6 votes
1 answer
917 views

Interrupting (blink-highlighting) function if mapping is invoked again

I have an adapted version of Damian Conway's Die Blinkënmatchen in my ~/.vimrc that "highlight-flashes" search matches as I step through them with n / N: " 'hlsearch' makes it hard to tell which is ...
DevSolar's user avatar
  • 789