I am new to vimscript. I am trying to figure out how plugins like vimwiki or vim-note reformat the visible text.

I know how to use the syntax highlighter to highlight, bold, underline, strikethrough, etc.

However these plugins change the visible text when the cursor moves away from the line. When the cursor is returned to the line, the text is re-rendered to show what was typed in.

Here is an example (vimwiki), I can type *bold* when I move the cursor away it is turned into bold, when I bring the cursor back to the line it is re-rendered as *bold*.

How is this technique achieved. I did look through vimwiki source (which is very complicated), I looked at vim-note as well but couldn't figure out where they do the switch (I would have figured there would be a mapping for <CR>).

Do they keep 2 buffers, one visible, one hidden?

In vim-note, are they using vimscript undo to achieve this technique? If so how does it work?

1 Answer 1


These plugins are using Vim's syntax conceal feature.

Vim's syntax highlighting is normally used to change the colour (or a handful of other attributes, such as underlining or emboldening) of text, but the conceal feature instead allows matching items either to be hidden entirely, or replaced with a single character.

Depending on your 'concealcursor' setting, the real text will be displayed in full when you move your cursor onto the line that contains the item. The 'conceallevel' setting can also be used to disable conceal entirely, or to alter whether items are hidden or replaced.

For your specific example, vimwiki is likely using the concealends argument to :syntax to conceal the * at each end of the bold syntax region.

  • 1
    I had no idea there was such a feature...I will look through the source code looking for this usage! I spent 2 days trying to figure out how this was achieved :p Thx
    – hba
    Aug 19, 2020 at 16:43
  • 1
    You're absolutely correct. At least vim-note uses the conceal mechanism: github.com/xolox/vim-notes/blob/master/syntax/notes.vim
    – hba
    Aug 19, 2020 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.