Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ let g:NERDTrimTrailingWhitespace = 1

" Enable NERDCommenterToggle to check all selected lines is commented or not
let g:NERDToggleCheckAllLines = 1

" Make NERDCommentYank write to a specific register by default, instead of `""`
let g:NERDDefaultRegister = 'c'
```

### Default mappings
Expand Down Expand Up @@ -172,7 +175,7 @@ Most of the following mappings are for normal/visual mode only. The **|NERDComme

* `[count]<leader>cy` **|NERDCommenterYank|**

Same as <leader>cc except that the commented line(s) are yanked first.
Same as <Leader>cc except that it first yanks the commented line(s) [into register x].

* `<leader>c$` **|NERDCommenterToEOL|**

Expand Down
7 changes: 4 additions & 3 deletions autoload/nerdcommenter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1290,12 +1290,13 @@ function! nerdcommenter#Comment(mode, type) range abort
call s:UncommentLines(firstLine, lastLine)

elseif a:type ==? 'Yank'
let l:register = (v:register ==? '"' ? g:NERDDefaultRegister : v:register)
if isVisual
normal! gvy
execute 'normal! gv"'. l:register . 'y'
elseif countWasGiven
execute firstLine .','. lastLine .'yank'
execute firstLine .','. lastLine .'yank '. l:register
else
normal! yy
execute 'normal! "'. l:register .'yy'
endif
execute firstLine .','. lastLine .'call nerdcommenter#Comment("'. a:mode .'", "Comment")'
endif
Expand Down
28 changes: 23 additions & 5 deletions doc/nerdcommenter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ Toggles the comment state of the selected line(s) individually.
Comments out the selected lines ``sexily''


[count]|<Leader>|cy |NERDCommenterYank|
Same as |<Leader>|cc except that the commented line(s) are yanked first.
["x][count]|<Leader>|cy |NERDCommenterYank|
Same as |<Leader>|cc except that it first yanks the commented line(s) [into
register x].


|<Leader>|c$ |NERDCommenterToEOL|
Expand Down Expand Up @@ -280,11 +281,15 @@ Related options:
------------------------------------------------------------------------------
3.2.7 Yank comment map *NERDCommenterYank*

Default mapping: [count]|<Leader>|cy
Default mapping: ["x]|[count]|<Leader>|cy
Mapped to: <plug>NERDCommenterYank
Applicable modes: normal visual visual-line visual-block.

Same as |<Leader>|cc except that it yanks the line(s) that are commented first.
Same as |<Leader>|cc except that it first yanks the commented line(s) [into
register x].

Related options:
|'NERDDefaultRegister'|

------------------------------------------------------------------------------
3.2.8 Comment to EOL map *NERDCommenterToEOL*
Expand Down Expand Up @@ -509,6 +514,9 @@ change the filetype back: >
|'NERDToggleCheckAllLines'| Enable NERDCommenterToggle to check
all selected lines is commented or not.

|'NERDDefaultRegister'| Specifies which register
|NERDCommenterYank| yanks to.

------------------------------------------------------------------------------
4.2 Options details *NERDCommenterOptionsDetails*

Expand Down Expand Up @@ -813,7 +821,7 @@ As opposed to like this: >
If this option is set to 1 then the top style will be used.

------------------------------------------------------------------------------
*'NERDDefaultNesting'*
*'NERDDefaultNesting'*
Values: 0 or 1.
Default 1.

Expand Down Expand Up @@ -854,6 +862,16 @@ file by the following line >
\ }
<

------------------------------------------------------------------------------
*'NERDDefaultRegister'*
Values: single-character string.
Default '"'.

|NERDCommenterYank| will yank to this register, unless another is specified
with ["x].

See |registers| for available register names and other details.

------------------------------------------------------------------------------
4.3 Default delimiter customisation *NERDCommenterDefaultDelims*

Expand Down
1 change: 1 addition & 0 deletions plugin/nerdcommenter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ call s:InitVariable('g:NERDTrimTrailingWhitespace', 0)
call s:InitVariable('g:NERDToggleCheckAllLines', 0)
call s:InitVariable('g:NERDDisableTabsInBlockComm', 0)
call s:InitVariable('g:NERDSuppressWarnings', 0)
call s:InitVariable('g:NERDDefaultRegister', '"')

" Section: Comment mapping and menu item setup
" ===========================================================================
Expand Down