Frage

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
```
War es hilfreich?

Lösung

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.

Andere Tipps

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top