mirror of
https://github.com/preservim/nerdcommenter.git
synced 2025-11-10 10:43:48 -05:00
remove prepend comments
This commit is contained in:
@@ -23,11 +23,10 @@ CONTENTS *NERDCommenterContents*
|
|||||||
2.2.7 Yank comment map............|NERDComYankComment|
|
2.2.7 Yank comment map............|NERDComYankComment|
|
||||||
2.2.8 Comment to EOL map..........|NERDComEOLComment|
|
2.2.8 Comment to EOL map..........|NERDComEOLComment|
|
||||||
2.2.9 Append com to line map......|NERDComAppendComment|
|
2.2.9 Append com to line map......|NERDComAppendComment|
|
||||||
2.2.10 Prepend com to line map....|NERDComPrependComment|
|
2.2.10 Insert comment map.........|NERDComInsertComment|
|
||||||
2.2.11 Insert comment map.........|NERDComInsertComment|
|
2.2.11 Use alternate delims map...|NERDComAltDelim|
|
||||||
2.2.12 Use alternate delims map...|NERDComAltDelim|
|
2.2.12 Comment aligned maps.......|NERDComAlignedComment|
|
||||||
2.2.13 Comment aligned maps.......|NERDComAlignedComment|
|
2.2.13 Uncomment line map.........|NERDComUncommentLine|
|
||||||
2.2.14 Uncomment line map.........|NERDComUncommentLine|
|
|
||||||
2.3 Supported filetypes...............|NERDComFiletypes|
|
2.3 Supported filetypes...............|NERDComFiletypes|
|
||||||
2.4 Sexy Comments.....................|NERDComSexyComments|
|
2.4 Sexy Comments.....................|NERDComSexyComments|
|
||||||
2.5 The NERDComment function..........|NERDComNERDComment|
|
2.5 The NERDComment function..........|NERDComNERDComment|
|
||||||
@@ -101,11 +100,6 @@ Adds comment delimiters to the end of line and goes into insert mode between
|
|||||||
them.
|
them.
|
||||||
|
|
||||||
|
|
||||||
<leader>cI |NERDComPrependComment|
|
|
||||||
Adds comment delimiters to the start of line and goes into insert mode between
|
|
||||||
them.
|
|
||||||
|
|
||||||
|
|
||||||
|NERDComInsertComment|
|
|NERDComInsertComment|
|
||||||
Adds comment delimiters at the current cursor position and inserts between.
|
Adds comment delimiters at the current cursor position and inserts between.
|
||||||
Disabled by default.
|
Disabled by default.
|
||||||
@@ -270,17 +264,7 @@ Appends comment delimiters to the end of the current line and goes
|
|||||||
to insert mode between the new delimiters.
|
to insert mode between the new delimiters.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.2.10 Prepend com to line map *NERDComPrependComment*
|
2.2.10 Insert comment map *NERDComInsertComment*
|
||||||
|
|
||||||
Default mapping: <leader>cI
|
|
||||||
Mapped to: <plug>NERDCommenterPrepend
|
|
||||||
Applicable modes: normal.
|
|
||||||
|
|
||||||
Prepends comment delimiters to the start of the current line and goes to
|
|
||||||
insert mode between the new delimiters.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
2.2.11 Insert comment map *NERDComInsertComment*
|
|
||||||
|
|
||||||
Default mapping: disabled by default.
|
Default mapping: disabled by default.
|
||||||
Map it to: <plug>NERDCommenterInInsert
|
Map it to: <plug>NERDCommenterInInsert
|
||||||
@@ -296,7 +280,7 @@ mapping add >
|
|||||||
to your vimrc.
|
to your vimrc.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.2.12 Use alternate delims map *NERDComAltDelim*
|
2.2.11 Use alternate delims map *NERDComAltDelim*
|
||||||
|
|
||||||
Default mapping: <leader>ca
|
Default mapping: <leader>ca
|
||||||
Mapped to: <plug>NERDCommenterAltDelims
|
Mapped to: <plug>NERDCommenterAltDelims
|
||||||
@@ -309,7 +293,7 @@ then they will be switched over to /**/ comments.
|
|||||||
See also |NERDComDefaultDelims|
|
See also |NERDComDefaultDelims|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.2.13 Comment aligned maps *NERDComAlignedComment*
|
2.2.12 Comment aligned maps *NERDComAlignedComment*
|
||||||
|
|
||||||
Default mappings: [count]<leader>cl [count]<leader>cb
|
Default mappings: [count]<leader>cl [count]<leader>cb
|
||||||
Mapped to: <plug>NERDCommenterAlignLeft
|
Mapped to: <plug>NERDCommenterAlignLeft
|
||||||
@@ -324,7 +308,7 @@ If a [count] is given in normal mode, the mapping works as though that many
|
|||||||
lines were selected in visual-line mode.
|
lines were selected in visual-line mode.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
2.2.14 Uncomment line map *NERDComUncommentLine*
|
2.2.13 Uncomment line map *NERDComUncommentLine*
|
||||||
|
|
||||||
Default mapping: [count]<leader>cu
|
Default mapping: [count]<leader>cu
|
||||||
Mapped to: <plug>NERDCommenterUncomment
|
Mapped to: <plug>NERDCommenterUncomment
|
||||||
@@ -410,8 +394,8 @@ The arguments to this function are simple:
|
|||||||
line.
|
line.
|
||||||
- type: is used to specify what type of commenting operation is to be
|
- type: is used to specify what type of commenting operation is to be
|
||||||
performed, and it can be one of the following: "sexy", "invert",
|
performed, and it can be one of the following: "sexy", "invert",
|
||||||
"minimal", "toggle", "alignLeft", "alignBoth", "norm",
|
"minimal", "toggle", "alignLeft", "alignBoth", "norm", "nested",
|
||||||
"nested", "toEOL", "prepend", "append", "insert", "uncomment", "yank"
|
"toEOL", "append", "insert", "uncomment", "yank"
|
||||||
|
|
||||||
For example, if you typed >
|
For example, if you typed >
|
||||||
:call NERDComment(1, 'sexy')
|
:call NERDComment(1, 'sexy')
|
||||||
|
|||||||
@@ -1501,7 +1501,7 @@ endfunction
|
|||||||
" mode or not
|
" mode or not
|
||||||
" -type: the type of commenting requested. Can be 'sexy', 'invert',
|
" -type: the type of commenting requested. Can be 'sexy', 'invert',
|
||||||
" 'minimal', 'toggle', 'alignLeft', 'alignBoth', 'norm',
|
" 'minimal', 'toggle', 'alignLeft', 'alignBoth', 'norm',
|
||||||
" 'nested', 'toEOL', 'prepend', 'append', 'insert', 'uncomment', 'yank'
|
" 'nested', 'toEOL', 'append', 'insert', 'uncomment', 'yank'
|
||||||
function! NERDComment(isVisual, type) range
|
function! NERDComment(isVisual, type) range
|
||||||
" we want case sensitivity when commenting
|
" we want case sensitivity when commenting
|
||||||
let oldIgnoreCase = &ignorecase
|
let oldIgnoreCase = &ignorecase
|
||||||
@@ -1574,9 +1574,6 @@ function! NERDComment(isVisual, type) range
|
|||||||
call s:CommentBlock(firstLine, firstLine, col("."), col("$")-1, 1)
|
call s:CommentBlock(firstLine, firstLine, col("."), col("$")-1, 1)
|
||||||
call s:RestoreScreenState()
|
call s:RestoreScreenState()
|
||||||
|
|
||||||
elseif a:type == 'prepend'
|
|
||||||
call s:PrependCommentToLine()
|
|
||||||
|
|
||||||
elseif a:type == 'append'
|
elseif a:type == 'append'
|
||||||
call s:AppendCommentToLine()
|
call s:AppendCommentToLine()
|
||||||
|
|
||||||
@@ -1654,46 +1651,6 @@ function s:PlaceDelimitersAndInsBetween()
|
|||||||
startinsert
|
startinsert
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: s:PrependCommentToLine(){{{2
|
|
||||||
" This function prepends comment delimiters to the start of line and places
|
|
||||||
" the cursor in position to start typing the comment
|
|
||||||
function s:PrependCommentToLine()
|
|
||||||
" get the left and right delimiters without any escape chars in them
|
|
||||||
let left = s:GetLeft(0, 1, 0)
|
|
||||||
let right = s:GetRight(0, 1, 0)
|
|
||||||
|
|
||||||
" get the len of the right delim
|
|
||||||
let lenRight = strlen(right)
|
|
||||||
|
|
||||||
|
|
||||||
"if the line is empty then we need to know about this later on
|
|
||||||
let isLineEmpty = strlen(getline(".")) == 0
|
|
||||||
|
|
||||||
"stick the delimiters down at the start of the line. We have to format the
|
|
||||||
"comment with spaces as appropriate
|
|
||||||
if lenRight > 0
|
|
||||||
execute ":normal I" . left . right
|
|
||||||
else
|
|
||||||
execute ":normal I" . left
|
|
||||||
endif
|
|
||||||
|
|
||||||
" if there is a right delimiter then we gotta move the cursor left
|
|
||||||
" by the len of the right delimiter so we insert between the delimiters
|
|
||||||
if lenRight > 0
|
|
||||||
let leftMoveAmount = lenRight
|
|
||||||
execute ":normal " . leftMoveAmount . "h"
|
|
||||||
endif
|
|
||||||
normal l
|
|
||||||
|
|
||||||
"if the line was empty then we gotta add an extra space on the end because
|
|
||||||
"the cursor will move back one more at the end of the last "execute"
|
|
||||||
"command
|
|
||||||
if isLineEmpty && lenRight == 0
|
|
||||||
execute ":normal a "
|
|
||||||
endif
|
|
||||||
|
|
||||||
startinsert
|
|
||||||
endfunction
|
|
||||||
" Function: s:RemoveDelimiters(left, right, line) {{{2
|
" Function: s:RemoveDelimiters(left, right, line) {{{2
|
||||||
" this function is called to remove the first left comment delimiter and the
|
" this function is called to remove the first left comment delimiter and the
|
||||||
" last right delimiter of the given line.
|
" last right delimiter of the given line.
|
||||||
@@ -3281,9 +3238,6 @@ nnoremap <silent> <plug>NERDCommenterToEOL :call NERDComment(0, "toEOL")<cr>
|
|||||||
" append comments
|
" append comments
|
||||||
nmap <silent> <plug>NERDCommenterAppend :call NERDComment(0, "append")<cr>
|
nmap <silent> <plug>NERDCommenterAppend :call NERDComment(0, "append")<cr>
|
||||||
|
|
||||||
" prepend comments
|
|
||||||
nmap <silent> <plug>NERDCommenterPrepend :call NERDComment(0, "prepend")<cr>
|
|
||||||
|
|
||||||
" insert comments
|
" insert comments
|
||||||
inoremap <silent> <plug>NERDCommenterInInsert <SPACE><BS><ESC>:call NERDComment(0, "insert")<CR>
|
inoremap <silent> <plug>NERDCommenterInInsert <SPACE><BS><ESC>:call NERDComment(0, "insert")<CR>
|
||||||
|
|
||||||
@@ -3311,7 +3265,6 @@ if g:NERDCreateDefaultMappings
|
|||||||
call s:CreateMaps('<plug>NERDCommenterUncomment', '<leader>cu')
|
call s:CreateMaps('<plug>NERDCommenterUncomment', '<leader>cu')
|
||||||
call s:CreateMaps('<plug>NERDCommenterToEOL', '<leader>c$')
|
call s:CreateMaps('<plug>NERDCommenterToEOL', '<leader>c$')
|
||||||
call s:CreateMaps('<plug>NERDCommenterAppend', '<leader>cA')
|
call s:CreateMaps('<plug>NERDCommenterAppend', '<leader>cA')
|
||||||
call s:CreateMaps('<plug>NERDCommenterPrepend', '<leader>cI')
|
|
||||||
|
|
||||||
if !hasmapto('<plug>NERDCommenterAltDelims', 'n')
|
if !hasmapto('<plug>NERDCommenterAltDelims', 'n')
|
||||||
nmap <leader>ca <plug>NERDCommenterAltDelims
|
nmap <leader>ca <plug>NERDCommenterAltDelims
|
||||||
@@ -3347,7 +3300,6 @@ if g:NERDMenuMode != 0
|
|||||||
call s:CreateMenuItems('<plug>NERDCommenterSexy', 'Sexy', menuRoot)
|
call s:CreateMenuItems('<plug>NERDCommenterSexy', 'Sexy', menuRoot)
|
||||||
call s:CreateMenuItems('<plug>NERDCommenterYank', 'Yank\ then\ comment', menuRoot)
|
call s:CreateMenuItems('<plug>NERDCommenterYank', 'Yank\ then\ comment', menuRoot)
|
||||||
exec 'nmenu <silent> '. menuRoot .'.Append <plug>NERDCommenterAppend'
|
exec 'nmenu <silent> '. menuRoot .'.Append <plug>NERDCommenterAppend'
|
||||||
exec 'nmenu <silent> '. menuRoot .'.Prepend <plug>NERDCommenterPrepend'
|
|
||||||
exec 'menu <silent> '. menuRoot .'.-Sep- :'
|
exec 'menu <silent> '. menuRoot .'.-Sep- :'
|
||||||
call s:CreateMenuItems('<plug>NERDCommenterAlignLeft', 'Left\ aligned', menuRoot)
|
call s:CreateMenuItems('<plug>NERDCommenterAlignLeft', 'Left\ aligned', menuRoot)
|
||||||
call s:CreateMenuItems('<plug>NERDCommenterAlignBoth', 'Left\ and\ right\ aligned', menuRoot)
|
call s:CreateMenuItems('<plug>NERDCommenterAlignBoth', 'Left\ and\ right\ aligned', menuRoot)
|
||||||
|
|||||||
Reference in New Issue
Block a user