Hot answers tagged

9

set nocp is not actually needed if your vimrc is located at ~/.vimrc or ~/.vim/vimrc. Many of your commands can be abbreviated even further sy on colo torte se rnu nu nowrap hi=1000 cb=unnamed si ts=4 sts=4 sw=4 sr is hls nn <CR> :noh<CR><CR> ino {<CR> {<CR>}<C-o>O


6

The first line really should be runtime defaults.vim. This is a standard file and it must be present in all Vim installations. Among other things, it saves from typing syntax on filetype plugin indent on set hi=200 set is Also set cb=unnamed is evil (just prepend "+ before normal mode command when needed) and set hls IMO is more harmful (every time ...


3

There are a few interresting things already in the default C and C++ filetype plugins -> filetype plugin indent on. This should enable smart indenting. No need anymore to use tabs, which could be left to the universal default of 8 -- I never use tab but always let Vim handle automatically the indent. Regarding compilation, :make %<<cr> is enough ...


3

In my case, I did split my .vimrc using the plugins feature (mentioned in the link of Jake Grossman's comment). So my final .vimrc contains the definition of the external plugins I use and a couple of autocommands. Then, I have the following: ~/.vim/plugin/0-settings.vim which contains most of the set commands ~/.vim/plugin/1-utils.vim which contains some ...


3

You can use folding to split your vimrc into sections and keep them collapsed, giving you a high level overview of the sections of the file that ressembles à table of contents. You can then expand folds for specific sections as you read or modify them. One very effective technique for folding arbitrary sections is to use fold markers, which you can place ...


2

Based on some information in the comments and the text re: folding on <>, I suggested verbose set foldmarker? (foldmarker being the option that controls what "marker" to use when foldmethod=marker) The OP confirmed in comments that a line in a session file was changing this; deleting it did the trick.


2

When I need to copy a word in reverse, I need to do it (l+y+b). I would like to do this only with (shift+y+b). That is, I would like to copy from the current cursor position and not from the previous position. If you want to copy the current word while the cursor is at the end of it, you can use yvb, which uses v as an operator (or a modifier for an ...


2

That's going to be a result of you having 'visualbell' (alias 'vb') enabled, per your vimrc file. When that setting is enabled any illegal/invalid action that would normally cause a beep/bell sound will instead flash the screen (by briefly inverting the display). The simple solution is, obviously, to disable it. :set novb You can also shorten the length of ...


1

Like Rich mentioned, the vim config you posted is unrelated to the mouse. You might try adding: if has('mouse') set mouse=a endif ...to your .vimrc. In regards to: so I don’t have to always find where my mouse cursor is set cursorline is a handy option for making the position of the cursor easily detectable.


1

You can use <space> to describe a space, although it is not mandatory. However, | has to be escaped: \| the result would be: vmap <Leader>rt :s/ \+\| \+/\|/g<cr> (or vmap <Leader>rt :s/<space>\+\|<space>\+/\|/g<cr> with <space>) On top of it, I'd suggest to use vnoremap, unless you actively need a recursive ...


1

Make sure you vim-commentary works, e.g. you can open python file and gcc to comment current line. To add support for a new filetype -- filetype has to provide commentstring, so if you are the author of the filetype -- then add setlocal commentstring=--\ %s to your ftplugin/YOURFILETYPENAME.vim. if you want to add support for a filetype you are not the ...


1

Remove the lines that open the quickfix list (:copen). Aside—if you use :execute for simple Ex commands, it’s usually enough to do just the command (so just :copen, :wincmd p, etc.). Even the colon’s aren’t necessary in most places.


1

You can normally use double quoted strings for this purpose. They accept a range of backslash escape sequences to produce special characters without having to input the special character literals into your buffer. The character that shows as ^M is the carriage return and you can enter it as "\r". You can also use key names in double quoted ...


1

While I can't suggest why this happens (cf. :help :syn-sync), a usual fix is :syntax sync fromstart, or to increase maxlines, or similar tweaks.


1

The CursorHold event will only trigger after the user has pressed a key, which hasn't yet happened when Vim is first opened. (Once you're in the loop, it will trigger repeatedly, since feedkeys("G") will produce a "key" stroke, which will then trigger the event again after 'updatetime' has elapsed.) You can easily produce a keystroke at ...


1

If you have a non-English keyboard layout, you can turn the extra keys into your advantage! For example, Hungarian layout has the ö (o umlaut) where 0 would be on an English keyboard. Most would never use this letter in vim. So I just remap Esc to it everywhere without fear. But as Bruno found out, in command mode remapping to Esc alters the behaviour, so ...


Only top voted, non community-wiki answers of a minimum length are eligible