File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ gc Text object for a comment (operator pending mode
26
26
gcgc Uncomment the current and adjacent commented lines.
27
27
gcu
28
28
29
+ *i_CTRL-/* *i_CTRL-_*
30
+ CTRL-/ or CTRL-_ Insert comment delimiters around the cursor in insert
31
+ mode.
32
+
29
33
*:Commentary*
30
34
:[range] Commentary Comment or uncomment [range] lines
31
35
Original file line number Diff line number Diff line change @@ -97,12 +97,18 @@ function! s:textobject(inner) abort
97
97
endif
98
98
endfunction
99
99
100
+ function s: insert ()
101
+ let [l , r ] = s: surroundings ()
102
+ call feedkeys (l . r . repeat (" \<Left> " , strchars (r )), ' ni' )
103
+ endfunction
104
+
100
105
command ! - range - bar Commentary call s: go (<line1> ,<line2> )
101
106
xnoremap <expr> <Plug> Commentary <SID> go()
102
107
nnoremap <expr> <Plug> Commentary <SID> go()
103
108
nnoremap <expr> <Plug> CommentaryLine <SID> go() . '_'
104
109
onoremap <silent> <Plug> Commentary :<C-U> call <SID> textobject(get(v:, 'operator', '') ==# 'c')<CR>
105
110
nnoremap <silent> <Plug> ChangeCommentary c:<C-U> call <SID> textobject(1)<CR>
111
+ inoremap <silent> <Plug> CommentaryInsert <C-\><C-O> :call <SID> insert()<CR>
106
112
nmap <silent> <Plug> CommentaryUndo :echoerr "Change your <Plug> CommentaryUndo map to <Plug> Commentary<Plug> Commentary"<CR>
107
113
108
114
if ! hasmapto (' <Plug>Commentary' ) || maparg (' gc' ,' n' ) == # ' '
@@ -114,6 +120,8 @@ if !hasmapto('<Plug>Commentary') || maparg('gc','n') ==# ''
114
120
nmap cgc <Plug> ChangeCommentary
115
121
endif
116
122
nmap gcu <Plug> Commentary<Plug> Commentary
123
+ imap <C-/> <C-G> u<Plug> CommentaryInsert
124
+ imap <C-_> <C-G> u<Plug> CommentaryInsert
117
125
endif
118
126
119
127
" vim:set et sw = 2 :
You can’t perform that action at this time.
0 commit comments