Skip to content

Commit

Permalink
Use repeat.vim for \\u and not for \\\
Browse files Browse the repository at this point in the history
  • Loading branch information
tpope committed Jul 31, 2012
1 parent 50b0556 commit dc349bb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
7 changes: 3 additions & 4 deletions README.markdown
Expand Up @@ -6,17 +6,16 @@ Comment stuff out. Use `\\\` to comment out a line (takes a count),
comment out a paragraph), and `\\` in visual mode to comment out the
selection. That's it.

Install [repeat.vim](https://github.com/tpope/vim-repeat) to enable
repeating with `.` the line commenting map `\\\`.

I wrote this because 5 years after Vim added support for mapping an
operator, I still couldn't find a commenting plugin that leveraged that
feature (I overlooked
[tcomment.vim](https://github.com/tomtom/tcomment_vim)). Striving for
minimalism, it weighs in at under 100 lines of code.

Oh, and it uncomments, too. The above maps actually toggle, and `\\u`
uncomments a set of adjacent commented lines.
uncomments a set of adjacent commented lines. Install
[repeat.vim](https://github.com/tpope/vim-repeat) to enable
repeating `\\u` with `.` (the other maps are repeatable without it).

Installation
------------
Expand Down
7 changes: 2 additions & 5 deletions plugin/commentary.vim
Expand Up @@ -38,10 +38,6 @@ function! s:go(type,...) abort
endif
call setline(lnum,line)
endfor

if a:type =~ '^\d\+$'
silent! call repeat#set("\<Plug>CommentaryLine",a:type)
endif
endfunction

function! s:undo()
Expand All @@ -54,11 +50,12 @@ function! s:undo()
endwhile
endfor
call s:go(lnums[0], lnums[1])
silent! call repeat#set("\<Plug>CommentaryUndo")
endfunction

xnoremap <silent> <Plug>Commentary :<C-U>call <SID>go(line("'<"),line("'>"))<CR>
nnoremap <silent> <Plug>Commentary :<C-U>set opfunc=<SID>go<CR>g@
nnoremap <silent> <Plug>CommentaryLine :<C-U>call <SID>go(line("."),line(".")-1+v:count1)<CR>
nnoremap <silent> <Plug>CommentaryLine :<C-U>set opfunc=<SID>go<Bar>exe 'norm! 'v:count1.'g@_'<CR>
nnoremap <silent> <Plug>CommentaryUndo :<C-U>call <SID>undo()<CR>
if !hasmapto('<Plug>Commentary') || maparg('\\','n') ==# '' && maparg('\','n') ==# ''
Expand Down

0 comments on commit dc349bb

Please sign in to comment.