vimtricks.wiki Concise Vim tricks, one at a time.

How do I hide or conceal syntax elements like markdown formatting in Vim?

Answer

:set conceallevel=2

Explanation

The conceallevel option controls how Vim displays characters that have the "conceal" syntax attribute. When set, concealed text can be hidden entirely or replaced with a single substitute character. This is commonly used to render Markdown, LaTeX, or JSON files more cleanly by hiding boilerplate syntax.

How it works

  • :set conceallevel=0 — show all text normally (no concealing)
  • :set conceallevel=1 — replace concealed text with a substitute character (default ·)
  • :set conceallevel=2 — hide concealed text completely (or show substitute if defined)
  • :set conceallevel=3 — hide concealed text completely, ignore substitutes

The concealcursor option controls whether concealed text is revealed when the cursor is on that line.

Example

In a Markdown file with conceallevel=2:

What you typed:     **bold text** and _italic_
What you see:       bold text and italic

The ** and _ markers are hidden, showing clean formatted-looking text.

:set conceallevel=2
:set concealcursor=nc

Tips

  • Set per filetype in your vimrc: autocmd FileType markdown setlocal conceallevel=2
  • concealcursor=nc keeps text concealed in normal and command mode but reveals it in insert mode for editing
  • Some plugins like vim-json use conceal to hide quotes in JSON files

Next

How do I visually select a double-quoted string including the quotes themselves?