Skip to content

Commit

Permalink
Support custom maps
Browse files Browse the repository at this point in the history
Closes tpope#2
  • Loading branch information
tpope committed Aug 28, 2011
1 parent 8647be4 commit 6876b3e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
8 changes: 0 additions & 8 deletions README.markdown
Expand Up @@ -39,14 +39,6 @@ Relax! You just have to adjust `'commentstring'`:

autocmd FileType apache set commentstring=#\ %s

> What if I want custom maps?
Fly by the seat of your pants and map directly to the `\` maps:

xmap gc \\
nmap gc \\
nmap gcc \\\

Contributing
------------

Expand Down
12 changes: 9 additions & 3 deletions plugin/commentary.vim
Expand Up @@ -46,8 +46,14 @@ function! s:go(type) abort
endif
endfunction

xnoremap <silent> \\ :<C-U>call <SID>go(visualmode())<CR>
nnoremap <silent> \\ :<C-U>set opfunc=<SID>go<CR>g@
nnoremap <silent> \\\ :<C-U>call <SID>go(v:count1)<CR>
xnoremap <silent> <Plug>Commentary :<C-U>call <SID>go(visualmode())<CR>
nnoremap <silent> <Plug>Commentary :<C-U>set opfunc=<SID>go<CR>g@
nnoremap <silent> <Plug>CommentaryLine :<C-U>call <SID>go(v:count1)<CR>
if maparg('\\') ==# ''
xmap \\ <Plug>Commentary
nmap \\ <Plug>Commentary
nmap \\\ <Plug>CommentaryLine
endif

" vim:set sw=2 sts=2:

0 comments on commit 6876b3e

Please sign in to comment.