4

syntax keywords are supposed to be - well - keywords. Initially, this meant, it must match the definition of the 'iskeyword' option, which usually does not include the quotation mark. Some years later, the iskeyword option has been de-coupled from the syntax highlighting option and now one can use the :syn iskeyword command to specify the iskeyword option ...


4

For some unknown reason it's :h hl-MoreMsg. BTW. If you're unhappy with some colors it might be worth to give a try to a different color scheme, as there's a ton of them.


4

Here's how you do this automatically after keeping your cursor still for a short time: :au CursorHold * :exec 'match Search /\V\<' . expand('<cword>') . '\>/' By default, this will highlight the word under the cursor after 4s of inactivity. Use :set updatetime=100 to make it happen after 0.1s instead. If you want to do this in a script instead ...


4

term is intended for b&w terminals only. So it has no effect in your case and all you got is a different background. What you want is called cterm. cterm=reverse actually swaps foreground and background color. So if you highlight Normal text with Search it effectively becomes ctermfg=3 ctermbg=fg. However, it will be different if the "searched"...


4

With the help from Konfekt/vim-unicode-homoglyphs and the answers here I found this solution that works quite well and has (almost?) no performance impact: augroup Hiunicode autocmd! autocmd BufEnter * \ syntax match nonascii "[^\x00-\x7F]" | \ highlight nonascii ctermfg=NONE ctermbg=red augroup END


3

You can get a List of all matches previously defined for the current window with the getmatches() function. By using an <expr> mapping, you can dynamically set a mapping based on the size of the List returned by getmatches() with a conditional expression. Conditional expressions in Vimscript (often called ternary expressions in other languages) take ...


3

You need these three lines: hi CursorLineNr guifg=#af00af set cursorline set cursorlineopt=number The last line removes the highlighting of the cursor line even if cursorline is set and only highlights the cursor line number.


3

You want the :redir family of commands. See :h :redir. For example... :redir > /path/to/file Then run :au. Then :redir END And the file will contain the same things you saw on the screen. This should work for any command that emits "messages" (echoes to the screen). You can also append. And you can redirect to registers and variables. Again, ...


3

Works only in neovim highlight CustomError ctermfg=red guifg=red sign define error numhl=CustomError sign place 2 name=error line=7 Have a look, at :h sign


3

I wrote a plugin for this: vim-current-search-match.


3

There's :h g:indentLine_defaultGroup specially for this case. So it becomes simply let g:indentLine_defaultGroup = 'Comment' In principle, when you need to read in the color from an existing highlight group it's done like that: let color = synIDattr(synIDtrans(hlID('Comment')), 'fg') hlID() returns numerical ID; synIDtrans() follows links if any; ...


3

The incsearch option is very specific to highlight the text that matches a pattern used in a search (which is defined as a /.../ or a ?...? block.) When you're using :g/^##1##\n.*/+,/##z##/- y, it will only highlight the text that matches the first search pattern, /^##1##\n.*/, which matches the header line and the following line. (The reason why only the ...


3

You might try just :set cursorline— *'cursorline'* *'cul'* *'nocursorline'* *'nocul'* 'cursorline' 'cul' boolean (default off) local to window {not available when compiled without the |+syntax| feature} Highlight the text line of the cursor with CursorLine |hl-CursorLine|. Useful to easily spot the ...


2

Option 1 Hack A hack... you could get the title of the quickfix window, and then strip off the parts that arent the search term: let pattern = getqflist({'title' : 0}).title let pattern = strip_off_not_search_parts(pattern) And then add a match with: call clearmatches() silent call matchadd('Search', pattern) " Hi group / pattern I have ...


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

The search highlight status is actually isolated from a function call, so you can't really re-enable it (or disable it) from inside a function. See :help function-search-undo: The last used search pattern and the redo command "." will not be changed by the function. This also implies that the effect of :nohlsearch is undone when the function returns. ...


2

If I generate keywords for buffer A, then open another buffer B in the same window and then come back to original buffer A, keywords are gone and I need to regenerate them Actually the problem is not that you switched from the buffer A, but is that the buffer A was unloaded by Vim. And upon unloading buffer contents Vim also disposes its syntax elements (...


2

So you're referring to the search results that get highlighted when you have the 'hlsearch' option set. So, in effect, these are the search results. Your example has one more quirk to it, which is the fact that you're ending with a \zs, so in effect what Vim is highlighting there is the character following the search term and not the match itself (...


2

The highlight of the matching brace is ruled by the MatchParen group. You can customize it with the highlight command. Here's an example: highlight MatchParen guifg=Black guibg=Yellow


2

There's no built in way to do what you want to do, but you can build your way there with some vimscript. Here's an example: function! Tester(line) if match(a:line, '(.*)') >= 0 return '(.*)' endif if match(a:line, '\.') >= 0 return '\.\S*' endif return '' endfunction function! Recolor() call clearmatches() ...


2

About :match With the match command, you only get 3 match ids: :match noteHi /\[\cNOTE:[^=]*\]/ :2match todoHi /\[\cTODO:[^=]*\]/ :3match what /ever/ Each time you call these commands for a particular id (1,2,3) you replace whatever was there before. So you can have 3 different ones but that's it, only 3. If you need more, use matchadd(). About matchadd() ...


1

I have not found a way to detect search highlighting. A character's search highlight seems to be invisible to vimscript. Having said that, you can detect when the cursor is in a search match by other means. searchcount().exact_match returns 1 if the cursor is in a search match. Thanks @D.BenKnoble. /\%#@/ can be used to determine whether the cursor is at ...


1

You can create $HOME/.vim/scripts.vim of your own, as $VIMRUNTIME/filetype.vim will source it by executing :runtime! scripts.vim if needed. It's enough to put only these lines: if getline(1) =~# '^Client:.' setf veltxt endif Note that .* at the end of a pattern does nothing (always matches).


1

Yes, you should be able to set the filetype based on the contents of the file. If you add a script to the ftdetect directory, this script should set up a new autocmd to trigger when a file of a specific extension or file name pattern (or * if any file name is possible) is opened and then set the appropriate filetype there. The autocmd can then set the ...


1

Well, I have a code just for this.It uses the quickfix window to display all instances of a string or a search. :MC string, or select an instance of string and press Y, or M<motion>. function! SpecialFind(type) let &selection = "inclusive" exec 'normal! `[v`]"xy' call Matches(@x) endfunction nnoremap M :set opfunc=...


1

You can use Vim's syntax highlighting mechanism but you'll need some code: function! HilightVisSel() abort let higroup = "Error" let [_, lineno1, column1, _] = getpos("'<") let [_, lineno2, column2, _] = getpos("'>") let sellines = getline(lineno1, lineno2) let sellines[-1] = sellines[-1][: column2 - 1]...


1

Type the following commands in normal mode / command mode: vit (I just discovered that ☝️ answer ☝️ on stackoverflow) :help v :help v_it (inner tag block) :help text-objects


1

The backgroud color is set by the normal group. You could check your colorscheme and use the same colour, which is probably not plain "black". The highlight command can help you observe each highlight. This will show you the settings for the normal group only: :hi normal You could even link your group to the normal group: :hi link IgnoreGroup normal


1

It is normal, you are not using the correct directory. See :h mysyntaxfile-add: If you are mostly satisfied with an existing syntax file, but would like to add a few items or change the highlighting, follow these steps: 1. Create your user directory from 'runtimepath', see above. 2. Create a directory in there called "after/syntax". For Unix: > ...


1

I came up with execute('highlight Comment')->split('\n')->filter({i,v -> v =~# '^Comment'})[0]->split(' ')->filter({i,v -> v =~# 'guifg'})[0]->split('=') as a way to parse the output of :highlight, but it doesn't take links into account, so it will probably be wrong. (With dracula it gives Blue, but Comment is linked to DraculaComment ...


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