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
82
votes
7answers
17k 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 ...
81
votes
1answer
44k 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 ...
50
votes
3answers
5k 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?
49
votes
7answers
26k 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 ...
39
votes
1answer
19k views

Why do I need both a vimrc and a gvimrc?

There seems to be two ways to store preferences specific to gvim: Keep an .vimrc file for vim and a .gvimrc file for gvim specific additions. Keep all settings in .vimrc and wrap gvim specific ...
33
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 ...
32
votes
2answers
7k views

What's the difference between let and set?

I don't know much of the theory behind Vim. It looks as if we set some variables, and let other variables. What's the difference, and when is one required over the other? Also, the solarized vim ...
27
votes
5answers
19k 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? ...
24
votes
2answers
6k views

Is it possible and useful to split vimrc?

As per the title, is it possible to split the vimrc file in several sub-files? Keep separate files for groups of settings that concern one thing? This thing might be anything, any kind of user-...
23
votes
1answer
40k views

How do I configure the Vim airline plugin to look like its own project screenshot?

I am trying to get the vim-airline up and running. I have required it via vundle in my ~./vimrc: Plugin 'bling/vim-airline' I have installed it and expected my Vim to look like the screenshot on ...
21
votes
5answers
1k 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 ...
21
votes
8answers
5k 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 ...
21
votes
2answers
5k 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'...
21
votes
3answers
20k views

What is `softtabstop` used for?

I've been aware of these tab related settings in Vim: ts sw expandtab smarttab sts My normal setting is set ts=4 sw=4 expandtab smarttab. But according to sts documentation, if expandtab is not ...
20
votes
2answers
1k 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 ...
19
votes
1answer
3k 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. ...
18
votes
5answers
1k views

After copying a visual selection to keyboard, return to original location

My cursor is in the middle of a paragraph when I decide suddenly I need to copy that paragraph: So I type vip to select the paragraph visually: Now I hit cmd+C to copy to clipboard (this may vary on ...
18
votes
4answers
2k views

How can I suppress the “reading from STDIN” message from within Vim?

When using Vim to read from stdin, it prints a informative message: $ echo foo | vim - Vim: Reading from stdin... $ This is just an example. The actual use doesn't allow shell constructs. vim <(...
17
votes
2answers
2k views

What is the difference between set and :set?

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 ...
17
votes
2answers
696 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)...
16
votes
3answers
11k views

How to make vim automatically add a newline to the end of a file?

Vim normally writes <EOL> for the last line only when there was one in the original file. How to make vim to write a new line at the end of a file all the time (when the file is not binary and ...
15
votes
5answers
7k views

Settings and plugins when root (`sudo vim`)?

It's really frustrating when I need to edit a file as root and use sudo vim somefile.conf and I can't use any of my keybindings and settings and plugins. Is there a way to get all my customizations ...
14
votes
3answers
2k views

How to label tmux tabs with the name of the file edited in vim?

Whenever I open a tmux session in terminal, all of the tabs containing vim sessions are labelled vim. My question is: How to configure it to label tmux tabs with the name of the edited file or ...
14
votes
1answer
14k views

How can I change the colour of the line highlighted with the 'cursorline' option?

I can highlight the current line like this :set cursorline, which underlines the current line. However I would like to highlight the entire line in a lighter color. How can I achieve this look?
13
votes
4answers
1k views

Same vimrc, customized per machine [duplicate]

I use the same versioned .vimrc on several machines. Is there a way of customise that file to enable/disable a plugin based on machine name or something like that? As example, I have something like ...
13
votes
9answers
25k views

Colorscheme's background not correct in terminal

I imported the solarized colorscheme and palette. My terminal has the correct colors and background, gvim has the correct colors and background, but vim has an incorrectly colored background. The text ...
13
votes
4answers
1k 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 ...
13
votes
0answers
205 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-...
12
votes
3answers
336 views

UI to personalize a vimrc without writing one from scratch

Vim is so infinitely configurable. However, devising a vimrc is a daunting task for novices and intermediate users. Basically, you're expected to develop one from a blank slate by reading the ...
12
votes
1answer
449 views

How to use sensitive data in .vimrc?

I want to have my .vimrc synced through github so it has to be public file, but at the same time i have to put some sensitive data (for example db passwords/hosts for dbext.vim) in it, without giving ...
12
votes
1answer
199 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 ...
12
votes
1answer
1k 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 ...
12
votes
2answers
5k views

Display CR and LF rather than “EOL” in ':set list'

Rather than choosing one character to be displayed as the EOL character, I'd like one to display for both CR and LF separately and regardless of if the file is unix or dos. Is this possible?
11
votes
3answers
1k views

What's the difference between the '\zs' and '\@<=' atoms in Vim regex?

This is what I get from the documentation: \zs "starts the highlighted part" after matching the preceding regex, and \@<= "starts the highlighted part" after matching the preceding atom. But I don'...
11
votes
2answers
2k views

How do you find where a variable was last assigned?

I am trying to set g:netrw_list_hide and it doesn't seem to work. No matter what I set it to in my .vimrc it always has the value ,^\.\.\=/\=$. Only if I source my vimrc file again, then it holds the ...
11
votes
1answer
5k views

How to enable spell check for certain file types?

I flip between Ruby and Markdown files a lot. Is there a way that I can have set spell automatically set when I open a *.md file, but not when I open a *.rb one?
11
votes
1answer
2k views

How can I run an autocmd when starting Vim with no file, a non-existing file, or a blank file (but not when starting with an existing file)?

I would like to run an autocmd in the following scenarios when I start Vim: With no filename specified. When the file is new. When the file exists but is completely blank. In all of the above three ...
11
votes
2answers
3k views

How can I modify Vim to work with a different keyboard layout?

I type with a non-QWERTY keyboard layout. Many of the keys Vim uses are now on the home row, but some key bindings just don't work, the most obvious one being the hjkl keys. How and where can I ...
11
votes
1answer
2k 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 (...
11
votes
2answers
234 views

Is it possible to use vim's clientserver functionality to keep settings synchronized?

I usually have multiple instances of vim running on the same machine. When I make a change to my vimrc I can just :source ~/.vimrc (with an easy mapping or an autocmd). But in order to have all ...
10
votes
2answers
1k views

How do I differentiate between vim and vimdiff from within vimrc?

I have a function in vim which will open all buffers as tabs. However after I add this function, vimdiff too opens the files to be compared as different tabs and hence doesn't show the differences. Is ...
10
votes
4answers
2k views

Includes in vimrc?

Is it possible to include external files to be sourced in the vimrc file? Is it as simple a matter as just adding source somefile?
10
votes
1answer
6k 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/...
10
votes
1answer
1k views

How can I highlight matching “%” names (e.g. if/end, for/end) defined by matchit.vim on selection?

Currently my Vim highlights matching parentheses, brackets, quotes, etc. with Cyan background and white foreground -- the cursor can be moved between these with %. Thanks to my matchit.vim, I can also ...
10
votes
1answer
4k views

Why is set exrc dangerous?

I've seen set exrc mentioned in various places for using per-directory .vimrc files, but every time it's been mentioned it's been with strong admonition not to actually use it because it's dangerous. ...
10
votes
1answer
855 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 ...
10
votes
2answers
566 views

Is it possible to remove an entry from the undo history?

I have these lines in my .vimrc to help with indentation: autocmd BufReadPost * set noexpandtab | retab! 4 autocmd BufWritePre * set expandtab | retab! 4 autocmd BufWritePost * set noexpandtab | ...
10
votes
1answer
6k views

Why doesn't YouCompleteMe complete function paramters?

I'd like to use YouCompleteMe with C++ semantic completion, but after hours of trying, I can't find why it doesn't work as expected. Everything seems to be working but I can't complete function ...
9
votes
2answers
2k views

Why won't vim source my .vimrc file

Today, I found my .vimrc didn't take effect. It was ok just hours ago. When I launched vim with $vim --plugin, :scriptnames echoed nothing: .vimrc file was not sourced. (Note: /etc/vimrc was removed ...
9
votes
1answer
3k views

What is command! -bang -nargs=* in a vimrc file?

I read a document about vim and the author suggest a line of code that should be put in .vimrc but I totally have no idea what it is. command! -bang -nargs=* Find call fzf#vim#grep('rg --column --...

1 2 3 4 5 21