8

Is there any advantages or side-effects of an explicit set nocompatible that I'm perhaps missing? Actually, there are many side-effects. Every time compatible is set or reset Vim rescans all options (except "terminal") and switches defaults when necessary. After that it rebuilds quite a few internal tables for iskeyword, spelling, vartabs etc. (see ...


7

Full restore If you want to restore layout with multiple termina buffers, you must restore other windows and buffers too, so it's in fact a full buffer layout restore, it's usage is not limited to terminal buffers. Three things must be done to achive that: Split windows according to saved layout. We can use result of winlayout() to do this. Load buffer in ...


6

One reason you might want to include a guarded set nocompatible in your .vimrc is that compatible will not be automatically unset if you specify the vimrc with the -u flag: Using the "-u" argument with another argument than DEFAULTS has the side effect that the 'compatible' option will be on by default. It's for this reason that I have this version* in ...


6

You can use :[range]w >> file to append the given range to the given file. If the file does not yet exist, use the ! argument to the :w command to force writing the new file. So this means you can use :2400w >> my_custom.txt to write line 2400 to my_custom.txt file, or if your cursor is on the current line already, you can simply use :.w >>...


5

As I have written about extensively, the vim technique for this type of thing is called an ftplugin, which stands for filetype-plugin. What that means is that certain filetypes have different settings than others. make is one such filetype. Vim comes with a set of filetype detecters that are enabled when you do :filetype on However, you can ask vim to ...


4

The error you see, comes from the plugin matchparen, that is distributed with vim and which does highlight the matching parenthesis as you edit them. Internally is uses the searchpairpos() function. Starting with Vim patch 8.1.0112, Vim will throw an error, if the skip argument for the functions searchpair() and searchpairpos() is not a string argument. ...


3

When vim encounters ^[Or it interprets it as some kind of special key, for instance a function key. Which specific one vim thinks it is I'm not sure, but for comparison the <f3> key is often ^[OR. These escape codes are interpreted in insert mode as keys to allow using function keys and arrow keys. Ordinarily, it's not an issue because one types ...


3

While I was experimenting with Rich's answer, I came up with :global/./put =line('.')|join Which can be shortened to :g/./pu =line('.')|j. And yes, you can adjust the range of :global—:3,25g/./pu =line('.')|j will work. Note: this puts the line number at the beginning of the line, at which point you might as well work with :3,25s/^/\=line('.'). Since you ...


3

I’d actually do this using either filbranden’s answer or possibly a macro recording, but as you specifically requested an ex command that takes a 3,25 range, how about using a substitute command that uses as its replacement an expression that calls the line() function: :3,25s/line \zs/\=line('.') . ' ' Or alternatively, a normal command using the same ...


3

I'd solve this using blockwise Visual mode and the g, Ctrl+A Visual mode command, that increments each line in the selection by a successive number, effectively creating an incrementing sequence. (See :help v_g_CTRL-A.) This is the way I'd do it (especially if I was playing Vimgolf): /c<CR> to put the cursor on the c character at the start of the ...


2

This situation is frustrating. Technically speaking, the CSV file you describe is within MicroSoft's CSV spec - the double-quotes escape the comma, so it's not considered a separator. However, there's a lot of programs out there that don't honor any method of saying the comma isn't a value separator, or don't honor that one. If you only have a single ...


2

As discussed in the comments, YouCompleteMe is overwriting your mapping with its own. Normally, you can overwrite a setting that a plugin has made by using the .vim/after directory but in this instance, YouCompleteMe is actually creating the mapping even later on, via an autoload function. You might like to check the YouCompleteMe documentation to see if ...


2

It is a bit surprising: my first guess was that one of ErrorMsg, Question, or WarningMsg would work. Turns out the highlight group you are looking for is MoreMsg, e.g.: :highlight MoreMsg guifg=red


2

Try it like this: s/&\zs.\{-}\ze&/ /gc Disassembled: & is the literal ampersand \zs sets the start of the match .\{-} matches any characters - but as few as possible \ze sets the end of the match & is the literal ampersand There are two special things here= First \zs...\ze: The part between them are the matched text, the ampersand ...


2

The actual behavior occurs because of the vim-airline plugin and can be removed adding the following property to your vimrc: let g:airline#extensions#tabline#tabs_label = '' So there will be no more leading "tabs>" in the tabline.


1

Vim is written in C language. According to Wikipedia, Vim is written in both C and Vimscript, not only Vimscript. The source code of Vim is available here, on Github. The two biggest folders are /src: 26.321M, mostly written in C. Most of the files are .c and .h in the folder itself (not in sub folders), but there is also some .po files containing stuff like ...


1

At the time we (maintainers of snippet/template engines) had mappings using :vmap which were targetting the select mode. I still have a few traces of that in my lh-brackets plugin. Also the mswin.vim beasts were using vmap instead of smap, IIRC. I'm not sure if there were other big users of the select mode. Evolutions that break what is already working, ...


1

I didn't follow the same approach as you did to get to the file, but I ran into the same problem. For me, a simple redraw! made it work. Here's my final command: nmap <LEADER>Sm :let fn=expand('%:t') <BAR> Explore %:p:h <BAR> call search(fn) <BAR> redraw!<CR>mfR


1

You can use autocmd for this. First run the following command to know the FileType (while your makefile is open) - :set filetype? This will show you the filetype. Then you can put the following in your vimrc to set settings for specifice fitetype like this - augroup makefilesettings autocmd! autocmd FileType makefile setlocal noexpandtab augroup ...


1

I would like to stay on console You have to press : then. Make sure you also read the corresponding Vim's help topic :h hit-enter Also, you can switch into Ex mode ("console") permanently with gQ (enter :vi to get back).


1

Invoke vim as view on the command line: view myfile.c This will automatically set the appropriate “readonly” flags.


1

We need more details. Header files aren't supposed to contain function definitions, in C. Function declaration, yes, but definitions, unless they are inlined, no. Could it be related to YCM? YCM isn't able to jump to a function definition that isn't in the same translation unit as the current file. For this, you'll need to index the files in your project. ...


1

There is a dedicated plugin for switching to header files: https://www.vim.org/scripts/script.php?script_id=31


1

Yup, they are the same (but getcwd() can accepts some arguments so it is useful for Vim scripting), both return the current working directory. By default it is the directory where you executed Vim. To change it you need to execute :cd.


1

As others have pointed out your intended way of using netrw as a project drawer is not very well supported, designed for or a good fit in general for editors which use splits. I hope you find the time to read the mentioned article Oil and vinegar – split windows and the project drawer. Despite this, netrw tries to provide some functionality to behave like a ...


1

NERDTree (#1658) is a plugin that does those things by default, and much more. If you're using vim 8, just enter $ git clone https://github.com/scrooloose/nerdtree ~/.vim/pack/my-plugins/start/nerdtree You can also look through the included manual with :h NerdTree. You might need to update the help tags with :helptags ALL.


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