zhon
zhon

Reputation: 1630

Using vim-surround for markdown

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
```

Upvotes: 4

Views: 668

Answers (3)

Geoff McNamara
Geoff McNamara

Reputation: 1

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

Upvotes: 0

Peter Rincker
Peter Rincker

Reputation: 45087

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.

Upvotes: 7

romainl
romainl

Reputation: 196476

I don't think it does.

But you could try something like this:

xnoremap <leader>c c```Ruby<CR><C-r>"```<Esc>

Upvotes: 0

Related Questions