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.
1,395
questions
5
votes
1answer
105 views
Are spaces OK in set statements?
Is it OK to use spaces for better readability in a .vimrc? For example, right now I have:
set number| "show line numbers
set history=1000
Would it be OK to write instead:
set number | "show line ...
5
votes
2answers
2k views
CursorLine colors
I configured my CursorLine to be lightyellow.
I have a couple of issues here:
First, lightyellow is marked as an error when it is a valid color. How can I avoid this?
Second, when the cursor line is ...
5
votes
2answers
714 views
How to change location of ~/.vim
I have Vim 7 installed from my distro's package manager, and I compiled Vim 8 from source. Vim 8 is all in /usr/local. Then I created a new directory in $HOME called ".vim8". I have all my Vim 7 stuff ...
5
votes
2answers
2k views
Remap <Space> key doesn't work
I was trying to remap some keys to switch to the next buffer, but something doesn't work, I have these lines on my .vimrc file:
" Cambia tecla lider a <Space>
let mapleader="<Space>"
" ...
5
votes
1answer
593 views
Map 'Jump to mark line' to 'Jump to mark position'
Let's say I've set a mark a via ma. Then 'a will bring me to the first non whitespace character of the line. However `a will bring me to the exact position of the mark a.
I prefer the second ...
5
votes
2answers
1k views
How can I unmap <esc> key in vim, it keeps reverting despite setting it in .vimrc?
Hi I am having some issue trying to unmap this key in my .vimrc. I've tried a lot of suggestions and remapping but it seems to be resetting itself every time.
unamp <Esc>
unmap! <Esc>
...
5
votes
1answer
81 views
How do I get rid of <filename>.project.vim files?
It seems like any time I edit a file with gvim it creates a litany of files I don't want or seem to need. I understand the <filename>.~ files are backups of the file before I started editing and ...
5
votes
1answer
802 views
How do I remap “å” to type “å”?
I recently came over some use for letters like æ, ø, and Ä. For context, these are available on my keyboard, and work fine in other programs. It's also a Norwegian keyboard if that's relevant.
With ...
5
votes
3answers
214 views
Make backup only once per session, when I close a file
Using the backup option, I'd like vim to keep the backup of a file until that file is closed, instead of overwriting the backup every time the file is saved.
I want Vim to do that because I often ...
5
votes
2answers
5k views
Keep \t Characters, While Don't Transform Spaces to Tabs?
In Vim, how to change the vimrc so that I could keep files' \t characters while I don't want \t characters appear in the newline generated by auto-indentation and tab-button I pressed.
Is this ...
5
votes
1answer
1k views
How to show line numbers for all buffers, windows & tabs
Is there any way to show line numbers by default, for all windows, buffers, and tabs opened inside Vim (including man pages, netrw buffers, etc.)?
What I have already tried to edit _vimrc by putting ...
5
votes
1answer
3k views
Set an option dependent on the filetype [duplicate]
How to configure on the .vimrc file to use a particular set options for a particular filetype, but others for a different filetype?
For example, I want to enable expand tab (set tabs to be spaces) ...
5
votes
1answer
512 views
Map NERDComToggleComment to a keyboard shortcut
To use NERDComToggleComment, I need to type
<Leader>c<Space>
(in my case, Leader is ,).
I would like to map this to a Ctrl+C (or Ctrl+any key if Ctrl+C is reserved/unavailable for any ...
5
votes
1answer
7k views
What is the variable $MYVIMRC?
One of my project folders has a file $MYVIMRC. I didn't create it.
I have a .vimrc file I created in my home folder. What is the difference and what is $MYVIMRC and when/how is it created.
5
votes
1answer
664 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 ...
5
votes
2answers
2k views
Change what vim displays when there is a fold
When I create a fold with zfap, vim displays something like:
+-- 15 lines: myFunctionPrototype :: Test -> Test -> Bool
However, I would like vim not to display this number of lines.
I find ...
5
votes
1answer
607 views
Pasting emojis 🦄 in Vim or Neovim
Been to trying to figure out why pasting an emoji from the clipboard doesn't paste properly when using ā + v on macOS.
I have the following key bindings in my .vimrc
vnoremap <M-c> "+y
...
5
votes
1answer
379 views
Why can't I set <Home> or t_kh in my vimrc file?
I'm having some problems remapping my home key; it works when I run Vim from tmux but not when I run it from a regular xterm without tmux. It looks like they're sending different escape codes and Vim ...
5
votes
1answer
322 views
Can auto-format break at hyphens?
I write my email in vim, which dynamically inserts newlines after 72 characters.
formatoptions=awtcql
This works nicely, breaking at spaces. However, is there a way to make it break at hyphens as ...
5
votes
1answer
1k views
In an autocmd what's the use of the BufRead event?
I'm trying to learn a bit of vimscript and currently reading the 12th chapter of Learn Vimscript the Hard Way.
In this page, the author says :
A common idiom in Vim scripting is to pair the ...
5
votes
2answers
1k views
How to specify a vim flag in the vimrc
I know that you can pass several flags to vim at startup.
For example: the -w flags enables to records every keystrokes on the file output.
vi -w output
But I wonder if there is a way of doing ...
5
votes
1answer
76 views
How often and when is foldexpr evaluated?
I want to toggle foldmethod between expr and manual because if we always set foldmethod=expr, then the cursor tends to move slowly in vim.
I think that foldexpr is evaluated just after switching ...
5
votes
2answers
51 views
How push a vimrc change to all open windows without doing anything extra each time?
Is there a way to push out a vimrc change to all open windows and instances of vim without having to write/change any buffers or reopen vim? I'd like vim to be able to behave like a modern day IDE for ...
5
votes
1answer
4k views
How to set VIM's background based on terminal's background colour?
I use CentOS 7 which has VIM 7.4 installed. By default the background property of VIM here is set to light irrespective of the colourscheme of my terminal. Although I can always force the desired ...
5
votes
1answer
826 views
Can't move `viminfo` file - &viminfo reverts upon loading vim
I'm trying to change the location of the viminfo file.
Why does the value of &viminfo revert after it is set in vimrc?
TL;DR:
In my vimrc I have:
set nocompatible
exec "set viminfo+=n".expand($...
5
votes
3answers
631 views
Making a custom function to comment out a range of lines
I want to make block commenting easy. To comment out a range of lines, what I can do is something like: :17,21s/^/# This will comment lines 17 to 21 in Python. But I don't want to write the whole ...
5
votes
2answers
3k views
How to make vim text bold?
In order to have my vim text always bold, I found this config in stackoverflow:
:hi MyGroup cterm=bold
:match MyGroup /./
But somehow, it has messed up search highlighting. It is no longer ...
5
votes
1answer
915 views
Perl folding with perl_fold_blocks
I have the below settings in my .vimrc relating to Perl code folding.
When I type za to toggle folding, it works on any sub { } by just folding up the sub.
However, if I za a non-sub block (e.g. ...
4
votes
2answers
1k views
Why cannot I source vimrc for the current file being editing?
And I add this in the vimrc file:
autocmd FileType markdown iabbrev mkdc <!--i--><left><left><left>
What I want to do is source the vimrc and make the abbreviation effective ...
4
votes
2answers
506 views
How to insert line in normal mode and stay at the same position
I tried to bind the following to insert a line after the line I'm currently on. Here it is:
nnoremap <CR> o<ESC>k
But this works weird. After inserting a new line cursor is at the ...
4
votes
2answers
162 views
Mappings with @=“^E” result in @=“” and do nothing
It seems that mappings with @="^E" or @="<c-e>" result in @="" and do nothing.
For example if I use nnoremap ^N @="^E"^M then press ctrl-n I will get a @="" message and nothing happens. ...
4
votes
1answer
3k views
How to move cursor in a specific column
I know that there is already a method to move the cursor to a particular line in vim like :25 and it moves to line number 25. But can I configure vim to move to 15th column in 25th line say something ...
4
votes
2answers
2k views
How can I get vim to not auto-wrap pasted text? [duplicate]
I am pasting several lines of text into vim at once (from another application, so I am using the OS's copy and paste and insert mode in vim). The longest of these lines is below:
" :PluginClean -...
4
votes
4answers
2k views
Change $HOME before it gets accessed
I'm using vim 8.1 on windows.
The IT department has set $HOME to a slow network drive.
Every time a file gets written to $HOME vim slows down.
I have $VIM/vimrc with the following content.
let $HOME ...
4
votes
1answer
1k views
Why does gvim read /usr/share/vim/vimrc instead of ~/.vim/vimrc
:help startup states, under 3. Execute Ex commands, from environment variables and/or files that (for Unix systems) $HOME/.vimrc or $HOME/.vim/vimrc is read and that The files are searched in the ...
4
votes
3answers
463 views
How can a character be inserted during an edit session by its Unicode numeric value?
I'm trying to set up a plugin to enable indentation guides, following an answer to this question. The plugin is Yggdroot/indentLine. It has instructions to set up a custom glyph to be shown instead of ...
4
votes
1answer
3k views
Change color of CoC suggestion box
I successfully installed CoC in my Vim to have some code-suggestions/completions while coding in Rust.
It works fine, but I want to change the color and basic looks of the suggestion box.
I tried ...
4
votes
2answers
254 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 ...
4
votes
2answers
2k views
How can I reload my .vimrc without appending anything to my current settings?
I'm aware of this question, but sourcing that way is not the same as restarting Vim. I want to do that without restarting Vim.
Like, if you have set fo+=c in your vimrc then re-sourcing changes it ...
4
votes
2answers
641 views
How do PuTTY/KiTTY ANSI colors affect Vim colorschemes?
I'm having a hard time understanding how the ANSI colors affect the named colors in Vim. My KiTTY terminal has "regular" and "bold" versions for the main 8 colors, plus foreground/background colors. ...
4
votes
1answer
1k views
Leader shortcuts ignored
In my vimrc I have
nnoremap <Leader>h :bp<CR>
nnoremap <Leader>l :bn<CR>
But I have to source my vimrc to enable them with (:so $MYVIMRC). If I do a :map after starting vim I ...
4
votes
1answer
447 views
How can I set expandtab but only for git commit messages?
Most of the time I'd like noexpandtab on because our corporate formatting uses tabs instead of spaces, so in my .vimrc I have this:
" Set tab width stuff
set tabstop=4 softtabstop=0 noexpandtab ...
4
votes
1answer
2k views
What does “set iskeyword+=@-@” do?
I'm looking at a file that has this in the .vimrc file:
set iskeyword+=@-@
I assumed it would let me delete a word with a hypen surrounded by two letters such as this-word with a dw command but it ...
4
votes
1answer
168 views
Visually selecting a line and then deleting does not copy to black hole register
I would like to not have vim copy items to the default register when I delete or change an item; for that, the following configuration seems to do the job perfectly. However I noticed that the only ...
4
votes
1answer
240 views
New lines are not continuing block comments, only in php
Say I type
/**
and hit return. In a .cpp file, or a .js file, the cursor would continue adding *s for me.
/**
*
But in a .php file, the cursor just moves to the next line. It's very annoying ...
4
votes
1answer
462 views
How to use the value of a register in a key mapping?
I want to map a key to the system command
`tmux set-buffer $var`
where $var is the value of @0 register.
How do i insert the @0 value into the map command
map <leader>t :!tmux set-buffer @...
4
votes
1answer
361 views
How to stop Vim from sourcing a file halfway through? [duplicate]
I'm mostly a Neovim user and I would like to share part of my config with regular Vim. Here's the problem: my init.vim is organized in such a way that at the top there are the general Vim options, ...
4
votes
2answers
235 views
Howto enable only one plugin to test?
I need to test a vim plugin. The problem: I already have my vim setup in current env, so ~/.vimrc is occupied.
I want to issue a command like vim -u <blah..blah> that maybe specifies the plugin ...
4
votes
1answer
228 views
How to set ruler with decimals in .vimrc file?
I have this line in .vimrc file
set ruler
which shows the percentage of current line. But for very large text files, it would just show 0% for first couple hundreds of lines, which is not quite ...
4
votes
3answers
4k views
Vim python debugger
I'm using vim for python scripting and currently approaching jedi-vim for autocomplete, navigation and refactoring. But it would be nice to have some ide-like debugging facilities.
Is there some ...