The aim of this pageđź“ť is to simplify the creation of markdown codeblock to code that is already in a file. There may be other scenarios. This is working for me. I often have a JSON in markdown or other pieces of code.
Instead of first creating the block, I paste/create the content that should go into the block, then visually select it and then press c to create the block with cursor in INSERT mode after the first triple backtick, so that I can define a language/style of the block.
- there may be better ways just using vanilla-vim, but I just can't resist this has been my VSCODE workflow for a long time
- therefore - select the code block visually and go with c (or whatever letter you define)
- the implementation is simple, just put the following into your
.vimrc
: - NOTE: it is a triple backtick, not a double as shown below but it is breaking the parsing of the blog and I don't know how to escape it reliably :/
vnoremap <leader>c <esc>o``<esc>gvo<esc>O``
- Then select the block visually, ideally with line selection
- Press
<leader>c
--> DONE
Top comments (0)