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
0 votes
3 answers
687 views

don't use scrolloff=5 for mouse clicks

I use (neo)vim with mouse=a and scrolloff=5. Clicking on one of the top or bottom five lines with the mouse causes the screen to jump (so that the new cursor position is more centered), which ...
0 votes
1 answer
25 views

How to change editor options when switching to diff mode?

I have a few options I like to apply both when Vim is opened in diff mode and when it is switched to diff mode, e.g., when calling diffsplit. I have the following lines in my ~/.vimrc: command! -nargs=...
6 votes
5 answers
5k 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 ...
1 vote
1 answer
51 views

Certain commands in vimrc not being picked up anymore

I am having an issue where anything I enter into my .vimrc file is not being picked up, regardless of how many times I add it / close the file / re-open it, etc. Here is the most basic example of what ...
1 vote
1 answer
855 views

Mapping doesn't work for tabs

I have several files opened in tabs in Vim. I want to switch between tabs, so I use Ctrl+left to move left (previous) and for next also. But my mapping doesn't work. :map <C-Left> :tabprevious&...
0 votes
1 answer
26 views

To not treat files like 'vimrc-tips.txt' as Vim Script files

There is a line in defaults.vim that enables Vim Script syntax for any .txt file with vimrc in its filename (for example, vimrc-tips.txt): au BufNewFile,BufRead *vimrc* call s:StarSetf('vim')...
0 votes
1 answer
32 views

'autocmd OptionSet' - How to make it work?

The following .vimrc snippet is by Martin Tournoij's answer posted here: How do I stop the colorcolumn from breaking into multiple pieces when there are wrapped lines? augroup wrappedcc autocmd! ...
1 vote
2 answers
52 views

Some settings don't work because of their arrangement. Is it possible to workaround this?

I try arrange settings in my .vimrc in the exact order and by using the same sectioning as if you click "Edit" (in the menu) and then "Settings Window". There is problem that when ...
0 votes
1 answer
32 views

To not wrap at 'textwidth' if 'filetype' is 'text'

I want to ask Vim to not auto-wrap text at the textwidth value. For this, I adopted a function from the following article: Vim: Set wrapping and indentation according to file type. The autocmd doesn't ...
0 votes
0 answers
24 views

Coc.nvim doesn't work correctly

Yesterday, I installed coc.nvim in vim on windows. I remember that it showed up the suggestion tab. But today, I removed go and visual studio, then it didn't show up anymore. I tried to reinstall Go, ...
2 votes
1 answer
3k views

NeoVim: colorscheme won't work in init.vim; requires command to be typed

I'm new to NeoVim and just getting started. My init.vim file under NeoVim\share\nvim\runtime\plugin\init.vim successfully sets everything except for the colorscheme and background. As seen in the ...
0 votes
0 answers
14 views

Vimlsp and asyncomplete not displaying completion popups

Been trying for a couple days with no luck to get an lsp with autocompletion working in my Vim setup. My .vimrc file looks like this: let g:asyncomplete_log_file="/home/user/z_log" let g:...
3 votes
2 answers
100 views

Make Vim _really_ work with both spaces and tabs

Here is what I use for indentation: set autoindent set breakindent set expandtab set smarttab set shiftround set shiftwidth=2 softtabstop=-1 " or maybe shiftwidth=2 softtabstop=8 " https://...
0 votes
1 answer
39 views

How can I open a vim fold so that it is not affected by `foldclose=all`?

In my config file I have set foldclose=all so that folds get automatically closed upon cursor leaving them. However, sometimes, I want a specific fold not to close for a while. Because folds below ...
1 vote
1 answer
35 views

"autocmd!" on a separate line vs. "autocmd! <the autocmd itself>"

From what I have read in a book by Steve Losh (chapter 14), it seems that to avoid performance issues, it is best practise to enclose autocommands, even the single ones, in autocommand groups: augroup ...
5 votes
1 answer
70 views

Is it possible to wrap and properly align inline comments?

set textwidth=60 let &colorcolumn=&textwidth set linebreak Is there a relatively simple way (that is, with using formatoptions only) to make Vim format inline comments (gq) from this: ...
0 votes
2 answers
25 views

Avoid "cannot find spell file" window

I have set spelllang=en_us,ru_ru in my .vimrc, and when I enable spell check by typing :set spell, Vim shows me a pop-up window that says that the dictionary for the second language is not installed. ...
0 votes
0 answers
15 views

How do I prevent vim from overriding my fold preferences? [closed]

I really really really don't like folding and when my colleague last updated our lab, vim started automatically folding on every file when I opened it. I'd be happy to set an option to turn it off ...
2 votes
2 answers
176 views

Is it possible to modify default statusline without resetting it to blank?

Normally, if you add something like set setting+=value into your .vimrc, the value will be appended to the existing ones. For example: set formatoptions+=j " => tcqj However, it seems it ...
23 votes
6 answers
2k views

After copying a visual selection, 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 ...
0 votes
3 answers
84 views

vim copy/paste from clipboard while keeping indentation

I am using Putty on Windows to connect to a Linux server. On the Linux server I am using vim to edit code files. I am using my mouse to select an area to copy and then right click to paste the copied ...
1 vote
1 answer
2k views

Make YouCompleteMe open definition in vertical split even if buffer is not saved

There is something I cannot do with YouCompleteMe that I could do when just using tags to navigate to a definition or declaration. The desired behaviour is (taking into account that , is my leader ...
1 vote
1 answer
26 views

Remap CTRL-x in insert mode

I want to remap <C-x> in insert mode (I do not use the completion commands via this key). This is what I tried: inoremap <C-x> <Esc> :x <Enter> inoremap <C-x> <C-o>...
1 vote
1 answer
40 views

Why `highlight X ...` from `.vimrc` does not work in gVim (but works in VIM) and I have to type it again during session?

For following snippet of code, to see what was highlighted I need to run :highlight LineHighlight ctermbg=darkgray guibg=drakgray after running vim session, and then rest of snippet works (i.e. loads ...
3 votes
1 answer
157 views

What is the reason to specify ':cANSI' (or another character set) for a font

I often see that fonts intended to be used on Windows are defined with :cANSI. set guifont=Consolas:h11:cANSI The help is, of course, provide some explanation, but I don't really understand it. cXX -...
0 votes
0 answers
23 views

'set fileencoding' for new files. Vim says it won't work, but is it really so?

set encoding=utf-8 set fileencoding=cp1251 set fileencodings=ut8-8,latin1 set laststatus=2 set statusline=%{(&fileencoding)} Vim help says that only global value of fileencoding won't for new ...
3 votes
1 answer
166 views

Prevent buffer loads within Nerdtree

If I have many buffers opened and, if the cursor (focus) is within NERDTree, when I change the buffer with :bn or :bp, the content of buffer loads within NERDTree. There's a way to, before buffer ...
3 votes
2 answers
175 views

Preload a named register?

Is there a way to preload a named register in vim? For example: I would like to have an empty comment always available in register "c". This way I could insert it and quickly add the text.
0 votes
1 answer
18 views

Different highlighting between foldtext and "the line number on the folded line"?

Can I control the highlighting of the foldtext separately from the color of the line number on a folded line? I want the foldtext to be quite visible while keeping my chosen line number color
0 votes
0 answers
3 views

How to get "foldlevel" number of characters in foldtext? [duplicate]

EDIT Duplicated by vimscript: how to repeat a string N times? ? I currently have the following in my .vimrc: function! MyFoldText() const foldindicator = ">" return v:folddashes . v:...
0 votes
1 answer
43 views

Vim Autoindent does not work [closed]

I'm configuring my Vim editor. Now I want it to automatically indent when I press enter after a parenthesis (like in modern IDEs) function test() { | } I already have autoindent and smartindent ...
0 votes
1 answer
21 views

.vimrc in local folder

Can I have a .vimrc file in local folder, so that each time I open files in that folder, vim will automatically load that .vimrc file? so that I can have different settings in different folder?
0 votes
1 answer
24 views

Set location to be same as path

I keep a vimrc file stored on Dropbox and use symlinks to point to this so my vimrc is always synced up. Recently I got a new laptop and the location of some utilities are different from that of my ...
0 votes
0 answers
29 views

How do I disable syntax highlighting in the changelist?

I want syntax highlighting off in menus like the changelist (accessed via :changes). Is there a setting for this?
0 votes
0 answers
27 views

Do I need the contents of the indent and ftplugin directories in my configuration?

While I have been using nvim (on Linux) for some time, I have only recently started using gvim (on Linux and Windows). I have noticed that on the Windows version of gvim there are directories amongst ...
1 vote
1 answer
24 views

Why is my changelist not working?

I'm using homebrew-installed vim My changelist looks something like this: 10 250 0 nmap <leader>rn <Plug>(coc-rename) 9 266 11 set report=0 8 267 20 set display+=...
1 vote
1 answer
35 views

How can I turn off syntax highlighting for man pages?

I open man pages in vim, per export MANPAGER="vim -M +MANPAGER -" in my zshrc. However, vim has syntax highlighting enabled when it opens a man page. Is there a way to ensure man pages ...
20 votes
4 answers
4k 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 <(...
2 votes
2 answers
81 views

choose template option for newfiles in vim

I have different templates in this directory ~/Documents/Library/ like: Template.cpp, normal.cpp, advanced.cpp normally i use this autocmd BufNewFile *.cpp 0r ~/Documents/Library/Template.cpp I want ...
0 votes
1 answer
43 views

Why is this mapping deleting text?

I'm using these two binding for indentation and dedentation of a visual selected block of text. " Indentation vmap <TAB> >gv " Dedentation vmap <S-TAB> <gv When I ...
0 votes
1 answer
1k views

Color scheme won't fully source from .vimrc

I just added a few things to my colorscheme.vim which is sourced from my .vimrc. In fact, it is the last line in the .vimrc.1 source ~/.vim/colorscheme.vim Oddly, now most of it doesn't apply, yet ...
0 votes
1 answer
56 views

Why doesn't vim-sneak's label-mode work even after enabling it?

I wanted lightspeed-like features in Vim (without having to install Neovim). I installed vim-sneak and followed the directions to enable "label-mode": let g:sneak#label = 1 But when ...
1 vote
1 answer
105 views

How to copy contents of wl-clipboard into a Vim register?

I would like to swap content between my system clipboard and a Vim register. I am missing one last piece of the puzzle, indicated below. Any thoughts? map <Leader>" :call SwapBuffer()<CR&...
1 vote
1 answer
34 views

How to remap :bn and :bp [closed]

I have these remaps for buffer switching in my .vimrc let mapleader = ' ' nnoremap <leader>bk :bw<CR> nnoremap <leader>bn :bn<CR> nnoremap <leader>bp :bp<CR> If I ...
0 votes
1 answer
155 views

mouse to highlight text puts vi into some kind of Visual mode

only on osx (not on Ubuntu ) when I hightlight text while in a terminal ( iterm2 3.4.8 ) vim shows some kind of notice saying Visual and then across top of terminal a banner appears saying Looks ...
0 votes
2 answers
842 views

How to Keep Syntax Color but Disable Highlighting in Vim?

I recently activated auto-complete using YouCompleteMe and syntax color in Vim. However, a red highlighting color appeared. I tried to disable syntax color with syntax off, but this highlighting ...
1 vote
1 answer
35 views

Why are incsearch and hlsearch disabled when opening a .csv file?

I like the incsearch and hlsearch options in Vim, so early on in my .vimrc file, I have the following lines: augroup allfiles autocmd FileType * :set nocindent noexpandtab incsearch hlsearch ...
0 votes
2 answers
40 views

Can vimrc 'tell' if syntax is on or off?

I want to write a simple function that will toggle syntax highlighting, I imagine it'll just be a simple if-else. Is there a condition I can check? If "syntax is on"?
3 votes
2 answers
307 views

How do I configure vim to unzip files with 7zip?

In an answer to this particular question, it's said that it's enough to have unzip installed and available to make vim able to unzip files on the fly. However, I'm wondering if there's a way to ...
0 votes
0 answers
19 views

Arrow characters are left behind on the screen

Whenever I press and hold any arrow key (e.g. h, j, k or l) they appears on screen as such: The same kind of thing happens whenever I accidentally scroll, where ^[OA are displayed if I scroll up and ^...

1
2 3 4 5
34