The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Hot answers tagged

5

List & Listchars 'list' is a boolean option that, when set, instructs vim to display whitespace characters. And it is completely customizable using 'listchars'. For example, to show non-breaking spaces as ! (you can use whatever character you like, especially with digraphs and unicode support): set list listchars=nbsp:! I use 'listchars' extensively, ...


3

You can use :syntax match ErrorMsg " " while inserting an unbreakable space between the "'s. To automatically load the rule, you can simply add au VimEnter,BufWinEnter * syn match ErrorMsg " " to your .vimrc. If you want to customize the highlighting, create a custom rule before the syn match, i.e. highlight UnbreakableSpace ctermbg=red guibg=red au ...


3

Vim has its own regex engine and it doesn't support {Cyrillic}. You probably want to read :h pattern-atoms and :h /character-classes to find out what you can use in your regexes. I think the best alternative you can find comes from :h /[] (especially the last example): \_[] A collection. This is a sequence of characters enclosed in brackets. It ...


2

Turns out the "how" answer is very simple: In very-magic mode, % is already magical. Therefore, instead of \%u4e2d, %u4e2d (no backslash) works fine! In full, that's /\v%u4e2d<CR>


2

The following works and is faster than the matchstr() solution: fun! Getchar() return strcharpart(strpart(getline('.'), col('.') - 1), 0, 1) endfun nnoremap GG :echo Getchar()<CR> See my question Reliably get the character at a byte index in a string.


2

The function col() returns the byte offset of the cursor in the current line. The returned value is the offset of the first byte of a multi-byte character. You could use virtcol() instead. It returns the screen column of the character. nnoremap <silent> <expr> \ ((virtcol(".") >= virtcol("$")-1) ? "^" : "$") In a short test it also works, ...


2

I do have this in my custom vimrc file, which highlights git conflict markers as well as special whitespace characters. " highlight VCS conflict markers " highlight strange Whitespace aug CustomHighlighting au! au WinEnter * if !exists("w:custom_hi1") | let w:custom_hi1 = matchadd('ErrorMsg', '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$') | endif au ...


2

I don't think you can use the <S-Space> notation in a mapping* but I think you should be able to map it by pressing Shift+Space when typing in the mapping where I've written [lhs] below: :inoremap [lhs] <Space> Of course, when reading your .vimrc, this will be a bit confusing, so you might be better off using an :execute command and Vim's ...


2

:syntax match ZeroWidthNonJoiner "[\u200c]" conceal cchar=😄 You need to check :h conceallevel, I set it to 2 personally. Otherwise, you may not get conceal to work as you expect.


1

Prerequisites are: Use Vim built with multi-byte support set encoding=utf-8 set guifont=<font that includes the combining chars of interest> You can test by putting the cursor after a character while in Insert mode and typing ⎈ Ctrl+V then U20D7 (for example). Vim will draw the combining character above the preceding character. (Note though ...


1

According to :h /\v: */\v* */\V* Use of "\v" means that after it, all ASCII characters except '0'-'9', 'a'-'z', 'A'-'Z' and '_' have special meaning: "very magic" It's ASCII characters, not any characters. According to :h /\: */\* */\\* \x A backslash followed by a single character, with no special ...


1

I have been using this in my plugin. let char = matchstr(getline('.')[col('.') - 1 :], '^.')


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