1 Commits
2.5.0 ... 2.3.0

Author SHA1 Message Date
marty
902faedee2 update version to 2.2.3 2010-12-08 09:37:01 +13:00
3 changed files with 452 additions and 974 deletions

156
README.md
View File

@@ -1,156 +0,0 @@
# NERD Commenter
Comment functions so powerful—no comment necessary.
## Installation
### Via Plugin Manager (Recommended)
#### [Vim-Plug](https://github.com/junegunn/vim-plug)
1. Add `Plug 'scrooloose/nerdcommenter'` to your vimrc file.
2. Reload your vimrc or restart
3. Run `:PlugInstall`
#### [Vundle](https://github.com/VundleVim/Vundle.vim) or similar
1. Add `Plugin 'scrooloose/nerdcommenter'` to your vimrc file.
2. Reload your vimrc or restart
3. Run `:BundleInstall`
#### [NeoBundle](https://github.com/Shougo/neobundle.vim)
1. Add `NeoBundle 'scrooloose/nerdcommenter'` to your vimrc file.
2. Reload your vimrc or restart
3. Run `:NeoUpdate``
#### [Pathogen](https://github.com/tpope/vim-pathogen)
```sh
cd ~/.vim/bundle
git clone https://github.com/scrooloose/nerdcommenter.git
```
### Manual Installation
#### Unix
(For Neovim, change `~/.vim/` to `~/.config/nvim/`.)
```sh
curl -fLo ~/.vim/plugin/NERD_Commenter.vim --create-dirs \
https://raw.githubusercontent.com/scrooloose/nerdcommenter/master/plugin/NERD_commenter.vim
curl -fLo ~/.vim/doc/NERD_Commenter.txt --create-dirs \
https://raw.githubusercontent.com/scrooloose/nerdcommenter/master/doc/NERD_commenter.txt
```
#### Windows (PowerShell)
```powershell
md ~\vimfiles\plugin
md ~\vimfiles\doc
$pluguri = 'https://raw.githubusercontent.com/scrooloose/nerdcommenter/master/plugin/NERD_commenter.vim'
$docsuri = 'https://raw.githubusercontent.com/scrooloose/nerdcommenter/master/doc/NERD_commenter.txt'
(New-Object Net.WebClient).DownloadFile($pluguri, $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("~\vimfiles\plugin\NERD_commenter.vim"))
(New-Object Net.WebClient).DownloadFile($docsuri, $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("~\vimfiles\doc\NERD_commenter.txt"))
```
### Post Installation
Make sure that you have filetype plugins enabled, as the plugin makes use of **|commentstring|** where possible (which is usually set in a filetype plugin). See **|filetype-plugin-on|** for details, but the short version is make sure this line appears in your vimrc:
```sh
filetype plugin on
```
## Usage
### Documentation
Please see the vim help system for full documentation of all options: `:help nerdcommenter`
### Settings
Several settings can be added to your vimrc to change the default behavior. Some examples:
```vim
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
" Set a language to use its alternate delimiters by default
let g:NERDAltDelims_java = 1
" Add your own custom formats or override the defaults
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }
" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1
```
### Default mappings
The following key mappings are provided by default (there is also a menu provided that contains menu items corresponding to all the below mappings):
Most of the following mappings are for normal/visual mode only. The **|NERDComInsertComment|** mapping is for insert mode only.
* `[count]<leader>cc` **|NERDComComment|**
Comment out the current line or text selected in visual mode.
* `[count]<leader>cn` **|NERDComNestedComment|**
Same as <leader>cc but forces nesting.
* `[count]<leader>c<space>` **|NERDComToggleComment|**
Toggles the comment state of the selected line(s). If the topmost selected line is commented, all selected lines are uncommented and vice versa.
* `[count]<leader>cm` **|NERDComMinimalComment|**
Comments the given lines using only one set of multipart delimiters.
* `[count]<leader>ci` **|NERDComInvertComment|**
Toggles the comment state of the selected line(s) individually.
* `[count]<leader>cs` **|NERDComSexyComment|**
Comments out the selected lines with a pretty block formatted layout.
* `[count]<leader>cy` **|NERDComYankComment|**
Same as <leader>cc except that the commented line(s) are yanked first.
* `<leader>c$` **|NERDComEOLComment|**
Comments the current line from the cursor to the end of line.
* `<leader>cA` **|NERDComAppendComment|**
Adds comment delimiters to the end of line and goes into insert mode between them.
* **|NERDComInsertComment|**
Adds comment delimiters at the current cursor position and inserts between. Disabled by default.
* `<leader>ca` **|NERDComAltDelim|**
Switches to the alternative set of delimiters.
* `[count]<leader>cl`
`[count]<leader>cb` **|NERDComAlignedComment|**
Same as **|NERDComComment|** except that the delimiters are aligned down the left side (`<leader>cl`) or both sides (`<leader>cb`).
* `[count]<leader>cu` **|NERDComUncommentLine|**
Uncomments the selected line(s).

View File

@@ -28,9 +28,8 @@ CONTENTS *NERDCommenterContents*
3.2.11 Use alternate delims map...|NERDComAltDelim| 3.2.11 Use alternate delims map...|NERDComAltDelim|
3.2.12 Comment aligned maps.......|NERDComAlignedComment| 3.2.12 Comment aligned maps.......|NERDComAlignedComment|
3.2.13 Uncomment line map.........|NERDComUncommentLine| 3.2.13 Uncomment line map.........|NERDComUncommentLine|
3.3 Sexy Comments.....................|NERDComSexyComments| 3.4 Sexy Comments.....................|NERDComSexyComments|
3.4 The NERDComment function..........|NERDComNERDComment| 3.5 The NERDComment function..........|NERDComNERDComment|
3.5 The Hooks.........................|NERDComHooks|
4.Options.................................|NERDComOptions| 4.Options.................................|NERDComOptions|
4.1 Options summary...................|NERDComOptionsSummary| 4.1 Options summary...................|NERDComOptionsSummary|
4.2 Options details...................|NERDComOptionsDetails| 4.2 Options details...................|NERDComOptionsDetails|
@@ -84,40 +83,40 @@ See |filetype-plugin-on| for details, but basically, stick this in your vimrc >
The following key mappings are provided by default (there is also a menu The following key mappings are provided by default (there is also a menu
with items corresponding to all the mappings below): with items corresponding to all the mappings below):
[count]|<Leader>|cc |NERDComComment| [count]<leader>cc |NERDComComment|
Comment out the current line or text selected in visual mode. Comment out the current line or text selected in visual mode.
[count]|<Leader>|cn |NERDComNestedComment| [count]<leader>cn |NERDComNestedComment|
Same as |<Leader>|cc but forces nesting. Same as <leader>cc but forces nesting.
[count]|<Leader>|c<space> |NERDComToggleComment| [count]<leader>c<space> |NERDComToggleComment|
Toggles the comment state of the selected line(s). If the topmost selected Toggles the comment state of the selected line(s). If the topmost selected
line is commented, all selected lines are uncommented and vice versa. line is commented, all selected lines are uncommented and vice versa.
[count]|<Leader>|cm |NERDComMinimalComment| [count]<leader>cm |NERDComMinimalComment|
Comments the given lines using only one set of multipart delimiters. Comments the given lines using only one set of multipart delimiters.
[count]|<Leader>|ci |NERDComInvertComment| [count]<leader>ci |NERDComInvertComment|
Toggles the comment state of the selected line(s) individually. Toggles the comment state of the selected line(s) individually.
[count]|<Leader>|cs |NERDComSexyComment| [count]<leader>cs |NERDComSexyComment|
Comments out the selected lines ``sexily'' Comments out the selected lines ``sexily''
[count]|<Leader>|cy |NERDComYankComment| [count]<leader>cy |NERDComYankComment|
Same as |<Leader>|cc except that the commented line(s) are yanked first. Same as <leader>cc except that the commented line(s) are yanked first.
|<Leader>|c$ |NERDComEOLComment| <leader>c$ |NERDComEOLComment|
Comments the current line from the cursor to the end of line. Comments the current line from the cursor to the end of line.
|<Leader>|cA |NERDComAppendComment| <leader>cA |NERDComAppendComment|
Adds comment delimiters to the end of line and goes into insert mode between Adds comment delimiters to the end of line and goes into insert mode between
them. them.
@@ -127,30 +126,26 @@ Adds comment delimiters at the current cursor position and inserts between.
Disabled by default. Disabled by default.
|<Leader>|ca |NERDComAltDelim| <leader>ca |NERDComAltDelim|
Switches to the alternative set of delimiters. Switches to the alternative set of delimiters.
[count]|<Leader>|cl [count]<leader>cl
[count]|<Leader>|cb |NERDComAlignedComment| [count]<leader>cb |NERDComAlignedComment|
Same as |NERDComComment| except that the delimiters are aligned down the Same as |NERDComComment| except that the delimiters are aligned down the
left side (|<Leader>|cl) or both sides (|<Leader>|cb). left side (<leader>cl) or both sides (<leader>cb).
[count]|<Leader>|cu |NERDComUncommentLine| [count]<leader>cu |NERDComUncommentLine|
Uncomments the selected line(s). Uncomments the selected line(s).
With the optional repeat.vim plugin (vimscript #2136), the mappings can also
be repeated via |.|
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.2 Functionality details *NERDComFunctionalityDetails* 3.2 Functionality details *NERDComFunctionalityDetails*
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.2.1 Comment map *NERDComComment* 3.2.1 Comment map *NERDComComment*
Default mapping: [count]|<Leader>|cc Default mapping: [count]<leader>cc
Mapped to: <plug>NERDCommenterComment Mapped to: <plug>NERDCommenterComment
Applicable modes: normal visual visual-line visual-block. Applicable modes: normal visual visual-line visual-block.
@@ -166,11 +161,11 @@ lines were selected in visual-line mode.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.2.2 Nested comment map *NERDComNestedComment* 3.2.2 Nested comment map *NERDComNestedComment*
Default mapping: [count]|<Leader>|cn Default mapping: [count]<leader>cn
Mapped to: <plug>NERDCommenterNested Mapped to: <plug>NERDCommenterNest
Applicable modes: normal visual visual-line visual-block. Applicable modes: normal visual visual-line visual-block.
Performs nested commenting. Works the same as |<Leader>|cc except that if a line Performs nested commenting. Works the same as <leader>cc except that if a line
is already commented then it will be commented again. is already commented then it will be commented again.
If |'NERDUsePlaceHolders'| is set then the previous comment delimiters will If |'NERDUsePlaceHolders'| is set then the previous comment delimiters will
@@ -187,7 +182,7 @@ Related options:
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.2.3 Toggle comment map *NERDComToggleComment* 3.2.3 Toggle comment map *NERDComToggleComment*
Default mapping: [count]|<Leader>|c<space> Default mapping: [count]<leader>c<space>
Mapped to: <plug>NERDCommenterToggle Mapped to: <plug>NERDCommenterToggle
Applicable modes: normal visual-line. Applicable modes: normal visual-line.
@@ -204,14 +199,14 @@ lines were selected in visual-line mode.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.2.4 Minimal comment map *NERDComMinimalComment* 3.2.4 Minimal comment map *NERDComMinimalComment*
Default mapping: [count]|<Leader>|cm Default mapping: [count]<leader>cm
Mapped to: <plug>NERDCommenterMinimal Mapped to: <plug>NERDCommenterMinimal
Applicable modes: normal visual-line. Applicable modes: normal visual-line.
Comments the selected lines using one set of multipart delimiters if possible. Comments the selected lines using one set of multipart delimiters if possible.
For example: if you are programming in c and you select 5 lines and press For example: if you are programming in c and you select 5 lines and press
|<Leader>|cm then a '/*' will be placed at the start of the top line and a '*/' <leader>cm then a '/*' will be placed at the start of the top line and a '*/'
will be placed at the end of the last line. will be placed at the end of the last line.
Sets of multipart comment delimiters that are between the top and bottom Sets of multipart comment delimiters that are between the top and bottom
@@ -226,11 +221,11 @@ lines were selected in visual-line mode.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.2.5 Invert comment map *NERDComInvertComment* 3.2.5 Invert comment map *NERDComInvertComment*
Default mapping: |<Leader>|ci Default mapping: <leader>ci
Mapped to: <plug>NERDCommenterInvert Mapped to: <plug>NERDCommenterInvert
Applicable modes: normal visual-line. Applicable modes: normal visual-line.
Inverts the commented state of each selected line. If the selected line is Inverts the commented state of each selected line. If the a selected line is
commented then it is uncommented and vice versa. Each line is examined and commented then it is uncommented and vice versa. Each line is examined and
commented/uncommented individually. commented/uncommented individually.
@@ -243,11 +238,11 @@ lines were selected in visual-line mode.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.2.6 Sexy comment map *NERDComSexyComment* 3.2.6 Sexy comment map *NERDComSexyComment*
Default mapping: [count]|<Leader>|cs Default mapping: [count]<leader>cs
Mapped to: <plug>NERDCommenterSexy Mapped to: <plug>NERDCommenterSexy
Applicable modes: normal, visual-line. Applicable modes: normal, visual-line.
Comments the selected line(s) ``sexily''. See |NERDComSexyComments| for Comments the selected line(s) ``sexily''... see |NERDComSexyComments| for
a description of what sexy comments are. Can only be done on filetypes for a description of what sexy comments are. Can only be done on filetypes for
which there is at least one set of multipart comment delimiters specified. which there is at least one set of multipart comment delimiters specified.
@@ -263,16 +258,16 @@ Related options:
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.2.7 Yank comment map *NERDComYankComment* 3.2.7 Yank comment map *NERDComYankComment*
Default mapping: [count]|<Leader>|cy Default mapping: [count]<leader>cy
Mapped to: <plug>NERDCommenterYank Mapped to: <plug>NERDCommenterYank
Applicable modes: normal visual visual-line visual-block. 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 yanks the line(s) that are commented first.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.2.8 Comment to EOL map *NERDComEOLComment* 3.2.8 Comment to EOL map *NERDComEOLComment*
Default mapping: |<Leader>|c$ Default mapping: <leader>c$
Mapped to: <plug>NERDCommenterToEOL Mapped to: <plug>NERDCommenterToEOL
Applicable modes: normal. Applicable modes: normal.
@@ -282,7 +277,7 @@ the line.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.2.9 Append com to line map *NERDComAppendComment* 3.2.9 Append com to line map *NERDComAppendComment*
Default mapping: |<Leader>|cA Default mapping: <leader>cA
Mapped to: <plug>NERDCommenterAppend Mapped to: <plug>NERDCommenterAppend
Applicable modes: normal. Applicable modes: normal.
@@ -293,27 +288,27 @@ to insert mode between the new delimiters.
3.2.10 Insert comment map *NERDComInsertComment* 3.2.10 Insert comment map *NERDComInsertComment*
Default mapping: disabled by default. Default mapping: disabled by default.
Map it to: <plug>NERDCommenterInsert Map it to: <plug>NERDCommenterInInsert
Applicable modes: insert. Applicable modes: insert.
Adds comment delimiters at the current cursor position and inserts Adds comment delimiters at the current cursor position and inserts
between them. between them.
NOTE: prior to version 2.1.17 this was mapped to <C-c>. To restore this NOTE: prior to version 2.1.17 this was mapped to ctrl-c. To restore this
mapping add > mapping add >
imap <C-c> <plug>NERDCommenterInsert let NERDComInsertMap='<c-c>'
< <
to your vimrc. to your vimrc.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.2.11 Use alternate delims map *NERDComAltDelim* 3.2.11 Use alternate delims map *NERDComAltDelim*
Default mapping: |<Leader>|ca Default mapping: <leader>ca
Mapped to: <plug>NERDCommenterAltDelims Mapped to: <plug>NERDCommenterAltDelims
Applicable modes: normal. Applicable modes: normal.
Changes to the alternative commenting style if one is available. For example, Changes to the alternative commenting style if one is available. For example,
if the user is editing a c++ file using // comments and they hit |<Leader>|ca if the user is editing a c++ file using // comments and they hit <leader>ca
then they will be switched over to /**/ comments. then they will be switched over to /**/ comments.
See also |NERDComDefaultDelims| See also |NERDComDefaultDelims|
@@ -321,12 +316,12 @@ See also |NERDComDefaultDelims|
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.2.12 Comment aligned maps *NERDComAlignedComment* 3.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
<plug>NERDCommenterAlignBoth <plug>NERDCommenterAlignBoth
Applicable modes: normal visual-line. Applicable modes: normal visual-line.
Same as |<Leader>|cc except that the comment delimiters are aligned on the left Same as <leader>cc except that the comment delimiters are aligned on the left
side or both sides respectively. These comments are always nested if the side or both sides respectively. These comments are always nested if the
line(s) are already commented. line(s) are already commented.
@@ -336,7 +331,7 @@ lines were selected in visual-line mode.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
3.2.13 Uncomment line map *NERDComUncommentLine* 3.2.13 Uncomment line map *NERDComUncommentLine*
Default mapping: [count]|<Leader>|cu Default mapping: [count]<leader>cu
Mapped to: <plug>NERDCommenterUncomment Mapped to: <plug>NERDCommenterUncomment
Applicable modes: normal visual visual-line visual-block. Applicable modes: normal visual visual-line visual-block.
@@ -344,9 +339,9 @@ Uncomments the current line. If multiple lines are selected in
visual mode then they are all uncommented. visual mode then they are all uncommented.
When uncommenting, if the line contains multiple sets of delimiters then the When uncommenting, if the line contains multiple sets of delimiters then the
``outermost'' pair of delimiters will be removed. ``outtermost'' pair of delimiters will be removed.
The script uses a set of heuristics to distinguish ``real'' delimiters from The script uses a set of heurisics to distinguish ``real'' delimiters from
``fake'' ones when uncommenting. See |NERDComIssues| for details. ``fake'' ones when uncommenting. See |NERDComIssues| for details.
If a [count] is given in normal mode, the mapping works as though that many If a [count] is given in normal mode, the mapping works as though that many
@@ -377,14 +372,16 @@ Here the multipart delimiters are /* and */ and the marker is *.
All of the NERD commenter mappings and menu items invoke a single function All of the NERD commenter mappings and menu items invoke a single function
which delegates the commenting work to other functions. This function is which delegates the commenting work to other functions. This function is
public and has the prototype: > public and has the prototype: >
function! NERDComment(mode, type) function! NERDComment(isVisual, type)
< <
The arguments to this function are simple: The arguments to this function are simple:
- mode: a character indicating the mode in which the comment is requested: - isVisual: if you wish to do any kind of visual comment then set this to
'n' for Normal mode, 'x' for Visual mode 1 and the function will use the '< and '> marks to find the comment
boundries. If set to 0 then the function will operate on the current
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", "comment", "nested", "minimal", "toggle", "alignLeft", "alignBoth", "norm", "nested",
"toEOL", "append", "insert", "uncomment", "yank" "toEOL", "append", "insert", "uncomment", "yank"
For example, if you typed > For example, if you typed >
@@ -392,35 +389,6 @@ For example, if you typed >
< <
then the script would do a sexy comment on the last visual selection. then the script would do a sexy comment on the last visual selection.
------------------------------------------------------------------------------
3.5 The hooks *NERDComHooks*
|fu! NERDCommenter_before()| Before NERDComment/SwitchToAlternativeDelimiters
|fu! NERDCommenter_after()| After NERDComment/SwitchToAlternativeDelimiters
For example, in order to handle different language blocks embedded in the same
file such as |vim-vue|, you can change the filetype, comment something and
change the filetype back: >
let g:ft = ''
fu! NERDCommenter_before()
if &ft == 'vue'
let g:ft = 'vue'
let stack = synstack(line('.'), col('.'))
if len(stack) > 0
let syn = synIDattr((stack)[0], 'name')
if len(syn) > 0
let syn = tolower(syn)
exe 'setf '.syn
endif
endif
endif
endfu
fu! NERDCommenter_after()
if g:ft == 'vue'
setf vue
let g:ft = ''
endif
endfu
<
============================================================================== ==============================================================================
4. Options *NERDComOptions* 4. Options *NERDComOptions*
@@ -429,65 +397,39 @@ change the filetype back: >
4.1 Options summary *NERDComOptionsSummary* 4.1 Options summary *NERDComOptionsSummary*
|'loaded_nerd_comments'| Turns off the script. |'loaded_nerd_comments'| Turns off the script.
|'NERDAllowAnyVisualDelims'| Allows multipart alternative delims to
|'NERDAllowAnyVisualDelims'| Allows multipart alternative delimiters be used when commenting in
to be used when commenting in
visual/visual-block mode. visual/visual-block mode.
|'NERDBlockComIgnoreEmpty'| Forces right delims to be placed when
|'NERDBlockComIgnoreEmpty'| Forces right delimiters to be placed doing visual-block comments.
when doing visual-block comments.
|'NERDCommentEmptyLines'| Specifies if empty lines should be
commented (useful with regions).
|'NERDCommentWholeLinesInVMode'| Changes behaviour of visual comments. |'NERDCommentWholeLinesInVMode'| Changes behaviour of visual comments.
|'NERDCreateDefaultMappings'| Turn the default mappings on/off. |'NERDCreateDefaultMappings'| Turn the default mappings on/off.
|'NERDCustomDelimiters'| Add or override delimiters for any
filetypes.
|'NERDDefaultNesting'| Tells the script to use nested comments |'NERDDefaultNesting'| Tells the script to use nested comments
by default. by default.
|'NERDMenuMode'| Specifies how the NERD commenter menu |'NERDMenuMode'| Specifies how the NERD commenter menu
will appear (if at all). will appear (if at all).
|'NERDLPlace'| Specifies what to use as the left |'NERDLPlace'| Specifies what to use as the left
delimiter placeholder when nesting delimiter placeholder when nesting
comments. comments.
|'NERDUsePlaceHolders'| Specifies which filetypes may use |'NERDUsePlaceHolders'| Specifies which filetypes may use
placeholders when nesting comments. placeholders when nesting comments.
|'NERDRemoveAltComs'| Tells the script whether to remove |'NERDRemoveAltComs'| Tells the script whether to remove
alternative comment delimiters when alternative comment delimiters when
uncommenting. uncommenting.
|'NERDRemoveExtraSpaces'| Tells the script to always remove the |'NERDRemoveExtraSpaces'| Tells the script to always remove the
extra spaces when uncommenting extra spaces when uncommenting
(regardless of whether NERDSpaceDelims (regardless of whether NERDSpaceDelims
is set). is set)
|'NERDRPlace'| Specifies what to use as the right |'NERDRPlace'| Specifies what to use as the right
delimiter placeholder when nesting delimiter placeholder when nesting
comments. comments.
|'NERDSpaceDelims'| Specifies whether to add extra spaces |'NERDSpaceDelims'| Specifies whether to add extra spaces
around delimiters when commenting, and around delimiters when commenting, and
whether to remove them when whether to remove them when
uncommenting. uncommenting.
|'NERDTrimTrailingWhitespace'| Specifies if trailing whitespace
should be deleted when uncommenting.
|'NERDCompactSexyComs'| Specifies whether to use the compact |'NERDCompactSexyComs'| Specifies whether to use the compact
style sexy comments. style sexy comments.
|'NERDDefaultAlign'| Specifies the default alignment to use,
one of 'none', 'left', 'start', or
'both'.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
4.3 Options details *NERDComOptionsDetails* 4.3 Options details *NERDComOptionsDetails*
@@ -515,8 +457,8 @@ example if we are editing the following java code: >
< <
If we are using // comments and select the "foo" and "bar" in visual-block If we are using // comments and select the "foo" and "bar" in visual-block
mode, as shown left below (where '|'s are used to represent the visual-block mode, as shown left below (where '|'s are used to represent the visual-block
boundary), and comment it then the script will use the alternative delimiters boundary), and comment it then the script will use the alternative delims as
as shown on the right: > shown on the right: >
float |foo| = 1221; float /*foo*/ = 1221; float |foo| = 1221; float /*foo*/ = 1221;
float |bar| = 324; float /*bar*/ = 324; float |bar| = 324; float /*bar*/ = 324;
@@ -565,15 +507,6 @@ Otherwise, the code block would become: >
} }
/*} */ /*} */
< <
------------------------------------------------------------------------------
*'NERDCommentEmptyLines'*
Values: 0 or 1.
Default: 0.
This option affects commenting of empty lines. If this option is turned on,
then empty lines will be commented as well. Useful when commenting regions of
code.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*'NERDCommentWholeLinesInVMode'* *'NERDCommentWholeLinesInVMode'*
Values: 0, 1 or 2. Values: 0, 1 or 2.
@@ -601,7 +534,7 @@ If you prefer the second option then stick this line in your vimrc: >
< <
If the filetype you are editing only has no multipart delimiters (for example If the filetype you are editing only has no multipart delimiters (for example
a shell script) and you hadn't set this option then the above would become > a shell script) and you hadnt set this option then the above would become >
in#t foo = 3; in#t foo = 3;
#int bar = 9; #int bar = 9;
< <
@@ -625,25 +558,6 @@ If set to 0, none of the default mappings will be created.
See also |NERDComMappings|. See also |NERDComMappings|.
------------------------------------------------------------------------------
*'NERDCustomDelimiters'*
Values: A map (format specified below).
Default: {}
Use this option if you have new filetypes you want the script to handle, or if
you want to override the default delimiters of a filetype.
Example: >
let g:NERDCustomDelimiters = {
\ 'ruby': { 'left': '#', 'leftAlt': 'FOO', 'rightAlt': 'BAR' },
\ 'grondle': { 'left': '{{', 'right': '}}' }
\ }
<
Here we override the delimiter settings for ruby and add FOO/BAR as alternative
delimiters. We also add {{ and }} as delimiters for a new filetype called
'grondle'.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*'NERDRemoveAltComs'* *'NERDRemoveAltComs'*
Values: 0 or 1. Values: 0 or 1.
@@ -654,7 +568,7 @@ this option tells the script whether to look for, and remove, comment
delimiters of the alternative style. delimiters of the alternative style.
For example, if you are editing a c++ file using // style comments and you go For example, if you are editing a c++ file using // style comments and you go
|<Leader>|cu on this line: > <leader>cu on this line: >
/* This is a c++ comment baby! */ /* This is a c++ comment baby! */
< <
It will not be uncommented if the NERDRemoveAltComs is set to 0. It will not be uncommented if the NERDRemoveAltComs is set to 0.
@@ -662,7 +576,7 @@ It will not be uncommented if the NERDRemoveAltComs is set to 0.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*'NERDRemoveExtraSpaces'* *'NERDRemoveExtraSpaces'*
Values: 0 or 1. Values: 0 or 1.
Default: 0. Default: 1.
By default, the NERD commenter will remove spaces around comment delimiters if By default, the NERD commenter will remove spaces around comment delimiters if
either: either:
@@ -685,14 +599,8 @@ Otherwise they would become: >
int bar = 10; int bar = 10;
int baz = foo + bar int baz = foo + bar
< <
If you want the spaces to be removed only if |'NERDSpaceDelims'| is set then
Note: When using 'start' as the default alignment, the enabling of set NERDRemoveExtraSpaces to 0.
NERDRemoveExtraSpaces will still result in the removal of a space after the
delimiter. This can be undesirable since aligning the delimiters at the very
start of the line (index 0) will usually result in spaces between the comment
delimiters and the text which probably shouldn't be removed. So when using
'start' as the default alignment, take care to also disable
NERDRemoveExtraSpaces.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*'NERDLPlace'* *'NERDLPlace'*
@@ -712,7 +620,7 @@ To set these options use lines like: >
Following the above example, if we have line of c code: > Following the above example, if we have line of c code: >
/* int horse */ /* int horse */
< <
and we comment it with |<Leader>|cn it will be changed to: > and we comment it with <leader>cn it will be changed to: >
/*FOO int horse BAR*/ /*FOO int horse BAR*/
< <
When we uncomment this line it will go back to what it was. When we uncomment this line it will go back to what it was.
@@ -725,7 +633,7 @@ Default: 3
This option can take 4 values: This option can take 4 values:
"0": Turns the menu off. "0": Turns the menu off.
"1": Turns the 'comment' menu on with no menu shortcut. "1": Turns the 'comment' menu on with no menu shortcut.
"2": Turns the 'comment' menu on with <alt>-c as the shortcut. "2": Turns the 'comment 'menu on with <alt>-c as the shortcut.
"3": Turns the 'Plugin -> comment' menu on with <alt>-c as the shortcut. "3": Turns the 'Plugin -> comment' menu on with <alt>-c as the shortcut.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
@@ -752,26 +660,6 @@ If you want spaces to be added then set NERDSpaceDelims to 1 in your vimrc.
See also |'NERDRemoveExtraSpaces'|. See also |'NERDRemoveExtraSpaces'|.
------------------------------------------------------------------------------
*'NERDTrimTrailingWhitespace'*
Values: 0 or 1.
Default 0.
When uncommenting an empty line some whitespace may be left as a result of
alignment padding. With this option enabled any trailing whitespace will be
deleted when uncommenting a line.
------------------------------------------------------------------------------
*'NERDDefaultAlign'*
Values: 'none', 'left', 'start', 'both'
Default 'none'.
Specifies the default alignment to use when inserting comments.
Note: When using 'start' as the default alignment be sure to disable
NERDRemoveExtraSpaces. See the note at the bottom of |NERDRemoveExtraSpaces|
for more details.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*'NERDCompactSexyComs'* *'NERDCompactSexyComs'*
Values: 0 or 1. Values: 0 or 1.
@@ -797,7 +685,7 @@ Values: 0 or 1.
Default 1. Default 1.
When this option is set to 1, comments are nested automatically. That is, if When this option is set to 1, comments are nested automatically. That is, if
you hit |<Leader>|cc on a line that is already commented it will be commented you hit <leader>cc on a line that is already commented it will be commented
again. again.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
@@ -805,11 +693,11 @@ again.
If you want the NERD commenter to use the alternative delimiters for a If you want the NERD commenter to use the alternative delimiters for a
specific filetype by default then put a line of this form into your vimrc: > specific filetype by default then put a line of this form into your vimrc: >
let g:NERDAltDelims_<filetype> = 1 let NERD_<filetype>_alt_style=1
< <
Example: java uses // style comments by default, but you want it to default to Example: java uses // style comments by default, but you want it to default to
/* */ style comments instead. You would put this line in your vimrc: > /* */ style comments instead. You would put this line in your vimrc: >
let g:NERDAltDelims_java = 1 let NERD_java_alt_style=1
< <
See |NERDComAltDelim| for switching commenting styles at runtime. See |NERDComAltDelim| for switching commenting styles at runtime.
@@ -840,7 +728,7 @@ Heuristics are used to distinguish the real comment delimiters
Because we have comment mappings that place delimiters in the middle of lines, Because we have comment mappings that place delimiters in the middle of lines,
removing comment delimiters is a bit tricky. This is because if comment removing comment delimiters is a bit tricky. This is because if comment
delimiters appear in a line doesn't mean they really ARE delimiters. For delimiters appear in a line doesnt mean they really ARE delimiters. For
example, Java uses // comments but the line > example, Java uses // comments but the line >
System.out.println("//"); System.out.println("//");
< <
@@ -860,11 +748,11 @@ If we have some line of code like this: >
/*int foo */ = /*5 + 9;*/ /*int foo */ = /*5 + 9;*/
< <
This will not be uncommented legally. The NERD commenter will remove the This will not be uncommented legally. The NERD commenter will remove the
"outer most" delimiters so the line will become: > "outter most" delimiters so the line will become: >
int foo */ = /*5 + 9; int foo */ = /*5 + 9;
< <
which almost certainly will not be what you want. Nested sets of comments will which almost certainly will not be what you want. Nested sets of comments will
uncomment fine though. E.g.: > uncomment fine though. Eg: >
/*int/* foo =*/ 5 + 9;*/ /*int/* foo =*/ 5 + 9;*/
< <
will become: > will become: >
@@ -878,10 +766,10 @@ for simplicity)
The author of the NERD commenter is Martyzillatron --- the half robot, half The author of the NERD commenter is Martyzillatron --- the half robot, half
dinosaur bastard son of Megatron and Godzilla. He enjoys destroying dinosaur bastard son of Megatron and Godzilla. He enjoys destroying
metropolises and eating tourist buses. metropolises and eating tourist busses.
Drop him a line at martin_grenfell at msn.com. He would love to hear from you. Drop him a line at martin_grenfell at msn.com. He would love to hear from you.
It's a lonely life being the worlds premier terror machine. How would you feel its a lonely life being the worlds premier terror machine. How would you feel
if your face looked like a toaster and a t-rex put together? :( if your face looked like a toaster and a t-rex put together? :(
The latest stable versions can be found at The latest stable versions can be found at
@@ -893,12 +781,12 @@ The latest dev versions are on github
============================================================================== ==============================================================================
8. Changelog *NERDComChangelog* 8. Changelog *NERDComChangelog*
2.3.0 2.2.3
- remove all filetypes which have a &commentstring in the standard vim - remove all filetypes which have a &commentstring in the standard vim
runtime for vim > 7.0 unless the script stores an alternate set of runtime for vim > 7.0 unless the script stores an alternate set of
delimiters delimiters
- make the script complain if the user doesn't have filetype plugins enabled - make the script complain if the user doesnt have filetype plugins enabled
- use |<Leader>| instead of comma to start the default mappings - use <leader> instead of comma to start the default mappings
- fix a couple of bugs with sexy comments - thanks to Tim Smart - fix a couple of bugs with sexy comments - thanks to Tim Smart
- lots of refactoring - lots of refactoring

File diff suppressed because it is too large Load Diff