Skip to content

Instantly share code, notes, and snippets.

@skaji
Created August 19, 2012 01:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skaji/3390716 to your computer and use it in GitHub Desktop.
Save skaji/3390716 to your computer and use it in GitHub Desktop.
vim commentout
" inline commentout
noremap <silent> ,# :s/^/#/<CR>:nohlsearch<CR>
noremap <silent> ,/ :s/^/\/\//<CR>:nohlsearch<CR>
noremap <silent> ," :s/^/\"/<CR>:nohlsearch<CR>
noremap <silent> ,c :s/^\(\s*\)\(\/\/\\|[#"]\)/\1/<CR>:nohlsearch<CR>
" block commentout
vnoremap <silent> ,p d:set paste<CR>0i=pod<CR>=cut<CR><ESC>kkp:set nopaste<CR>
vnoremap <silent> ,r d:set paste<CR>0i=begin<CR>=end<CR><ESC>kkp:set nopaste<CR>
vnoremap <silent> ,< d:set paste<CR>0i<!--<CR>--><CR><ESC>kkp:set nopaste<CR>
vnoremap <silent> ,* d:set paste<CR>0i/*<CR>*/<CR><ESC>kkp:set nopaste<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment