Skip to content

Instantly share code, notes, and snippets.

@tweekmonster
Created November 30, 2016 15:37
Show Gist options
  • Save tweekmonster/9d23e2b058b79dde6751e7a64fb5447b to your computer and use it in GitHub Desktop.
Save tweekmonster/9d23e2b058b79dde6751e7a64fb5447b to your computer and use it in GitHub Desktop.
highlight default NonComment ctermfg=8 ctermbg=none cterm=none guifg=#333333 guibg=none gui=none
function! s:toggle_comments() abort
if exists('w:toggle_comments')
silent! call matchdelete(w:toggle_comments)
unlet! w:toggle_comments
else
let w:toggle_comments = matchadd('NonComment', '^\%(\s*'.split(escape(&commentstring, '^$.*/"'''), '%s')[0].'\)\@!.*')
endif
endfunction
nnoremap <leader>c :<c-u>call <sid>toggle_comments()<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment