Using vim-surround for markdown
-
22-12-2019 - |
Question
Is it possible to use vim plugin vim-surround
to wrap markdown?
For example I have code I would like to wrap
# ruby code here
with
```Ruby
# ruby code here
```
La solution
Add the following to your ~/.vim/after/ftplugin/markdown.vim
file:
let b:surround_{char2nr('r')} = "```Ruby\r```"
Select your lines of code via V
then surround via Sr
.
Autres conseils
I don't think it does.
But you could try something like this:
xnoremap <leader>c c```Ruby<CR><C-r>"```<Esc>
For markdown of a paragraph into a code block you can use this:
" markdown code for a paragraph
" vim-surround is great but it doesn't do this...
nnoremap <Leader>mdc {O<DOWN>```<DOWN><ESC>}i```<ESC><DOWN>O<ESC>
See this post for lots of vim tips: Managing Vim and Essential Plugins
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow