9

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

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 >>...


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 ...


5

They are tag synonyms. That is, any of them can be used to reach the same point whether by way of :help {tagname}, typing Ctrl+] when the cursor is over text of the form *{tagname}* or any of the handful of other ways you can navigate tags. So, for example, :h v_i) and :h i( will both take you to the same place. Note that the particular entry chosen as an ...


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. ...


4

If you run vim --help you'll find the answer... $ vim --help | grep vimrc --cmd <command> Execute <command> before loading any vimrc file Some additional details under :help --cmd ... --cmd {command} {command} will be executed before processing any vimrc file. Otherwise it acts like -c {command}. You can use up to 10 of these commands, ...


4

Read :h 'lcs': "Two or three characters to be used to show a tab". First, the first one. Then the second one repeated as many times as needed. set lcs=tab:\|\|


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 ...


3

I think you want to add a positive look-ahead for the -> syntax (you could also use \ze or \zs, but that tends to cause problems with syntax because the text is consumed; with a look-ahead/behind, that is not the case): :syntax match PTR1 /\<[0-9A-Za-z_]\+\(->\)\@=\>/ Note that I've swapped \{1,\} for \+ and used \(->\): the group is ...


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

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 ...


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.


2

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, ...


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

What I'm missing? :h '] "To the last character of the previously changed or yanked text." You must keep marks intact until you've done with all of them. Maybe :lockmarks or setline() or whatever.


2

@Matt is correct. You have effectively changed the last change marks which is why your approach can not work. I would suggest you use c and <c-r> to paste/put the last deleted/yanked text to do your star-surrounding. e.g. c**<c-r>"** I would also recommend following the technique/example laid out by Vim's help (See :h g@) nnoremap <expr&...


2

As far as I know :h text-properties were designed with this in mind. The main use for text properties is to highlight text. This can be seen as a replacement for syntax highlighting. Instead of defining patterns to match the text, the highlighting is set by a script, possibly using the output of an external parser. This only needs to be done once, not ...


1

AFAIK, space will always trigger an abbreviation. At best you could analyse the context to prevent expansion within strings or comment for instance. The closest you could have to abbreviations, but with other triggers would be to register the association into a dictionary, and then search in that dictionary to do the replacement. Something like " In ...


1

I don't think this is possible using vim abbreviations. The closest you can come is to press CTRL-V before pressing the next key that would otherwise trigger the abbreviation. If you wish to have this behaviour (expanding is to Input()) on pressing a key then I suspect you'd have to do it with completions.


1

I don't really know much about VHDL... But looking at the VHDL indent script ($VIMRUNTIME/indent/vhdl.vim) I can see that it recognizes port map, but it seems it's only prepared to recognize the parens ( and ) in separate lines. If you do wrap the lines, you'll see that Vim will indent it properly: comp1 : Comp port map( a => a, b =...


1

Welcome to Vi and Vim! I think the javac linter is like a single-file compile, so it doesn't work well for whole-projects. I would suggest either setting up one of the many java build tools (maven, gradle, ant, etc.?) or using a linter that works with projects (probably eclipselsp does) This was the answer, from D. Ben Knoble. I had to get rid of the javac ...


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 ...


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