Different text width in the same filetype in vim -
i editing markdown files wich contain code examples (like here). there way tell vim, when editing markdown files, set textwidth=80 exept keep code syntax? example:
here text within markdown file // textwidth=80 puts 'hello world' // textwidth not specified
i don't know how set tw option meet requirement. came function, want:
function! wrapmd() let x=&tw let &tw=80 normal! gqq let &tw=x endfunction this function format tw=80 on current line, after restores original tw setting.
you can source function (or put in vimrc), , do:
:v/\v^( {4}|\t)/call wrapmd() at time when want format md text.
you create mapping or put in autocmd on event bufwritepre.
here made gif when test function:

Comments
Post a Comment