Skip to content

Instantly share code, notes, and snippets.

@sooop
Created February 26, 2014 07:44
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 sooop/9225308 to your computer and use it in GitHub Desktop.
Save sooop/9225308 to your computer and use it in GitHub Desktop.
"pycomment
"comment selected line
function! PyComment#com()
let b:l1 = line("'<")
let b:l2 = line("'>")
let b:cmd_ = ":" . b:l1 . "," . b:l2 . "s/^/#/g"
exec b:cmd_
endfunction
function! PyComment#uncom()
let b:l1 = line("'<")
let b:l2 = line("'>")
let b:cmd_ = ":". b:l1 . "," . b:l2 . "s/\\v^([\\t\\s]*)#+/\\1/"
exec b:cmd_
endfunction
augroup python comment
autocmd!
autocmd FileType *.py vnoremap <c-/> <esc>:call PyComment#com()<enter> |
\ vnoremap <c-,> <esc>:call PyComment#uncom()<enter>
augroup end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment