20 Commits

Author SHA1 Message Date
Martin Grenfell
ddd235757b switch to version 2.2.0 2008-10-04 00:07:40 +13:00
Martin Grenfell
d6ca231ac9 update changelog 2008-10-04 00:07:31 +13:00
Martin Grenfell
fe71371c15 make the mappings start with comma (again) 2008-10-03 23:58:41 +13:00
Martin Grenfell
226063bfc1 add support for SVNinfo 2008-10-03 23:23:08 +13:00
Martin Grenfell
d6282ef7a3 add support for txt2tags 2008-10-03 23:19:31 +13:00
Martin Grenfell
c2a3f093ae remove prepend comments 2008-09-23 21:41:15 +12:00
Martin Grenfell
b8c5a4443c remove useless "align right" comments 2008-09-23 21:39:06 +12:00
Martin Grenfell
6bf14ce062 update the changelog 2008-09-23 21:29:33 +12:00
Martin Grenfell
e6a36fb8aa update the changelog 2008-09-21 20:07:56 +12:00
Martin Grenfell
5bf567d75e update the mapping section of the doc 2008-09-21 12:55:08 +12:00
Martin Grenfell
1ae6bd4870 various updates/corrections to the doc 2008-09-21 11:46:40 +12:00
Martin Grenfell
6835cfe090 wrap the help tags for options in quotes 2008-09-21 11:43:33 +12:00
Martin Grenfell
b54d3bbc92 rewrite the key mappings part of the script
internal <plug> mappings are now used for all the commenting operations.
Key mappings are no longer specified with options. Instead the user must
create their own mappings to the internal <plug> mappings.
2008-09-21 11:08:49 +12:00
Martin Grenfell
27e8727a35 add support for applescript 2008-09-09 22:51:57 +12:00
Martin Grenfell
e164c00246 add support for calibre 2008-09-09 22:49:30 +12:00
Martin Grenfell
134acc595e add support for man 2008-09-09 22:44:07 +12:00
Martin Grenfell
d3718d9d21 bugfix for haskell delimiters 2008-09-09 22:37:43 +12:00
Martin Grenfell
53558869a9 remove a redundant if statement 2008-09-01 00:16:58 +12:00
Martin Grenfell
0370366572 add support for SVNcommit 2008-08-02 14:51:45 +12:00
Martin Grenfell
a4453c01ee add support for potwiki 2008-07-28 22:52:34 +12:00
2 changed files with 281 additions and 594 deletions

View File

@@ -23,11 +23,10 @@ CONTENTS *NERDCommenterContents*
2.2.7 Yank comment map............|NERDComYankComment|
2.2.8 Comment to EOL map..........|NERDComEOLComment|
2.2.9 Append com to line map......|NERDComAppendComment|
2.2.10 Prepend com to line map....|NERDComPrependComment|
2.2.11 Insert comment map.........|NERDComInsertComment|
2.2.12 Use alternate delims map...|NERDComAltDelim|
2.2.13 Comment aligned maps.......|NERDComAlignedComment|
2.2.14 Uncomment line map.........|NERDComUncommentLine|
2.2.10 Insert comment map.........|NERDComInsertComment|
2.2.11 Use alternate delims map...|NERDComAltDelim|
2.2.12 Comment aligned maps.......|NERDComAlignedComment|
2.2.13 Uncomment line map.........|NERDComUncommentLine|
2.3 Supported filetypes...............|NERDComFiletypes|
2.4 Sexy Comments.....................|NERDComSexyComments|
2.5 The NERDComment function..........|NERDComNERDComment|
@@ -35,24 +34,24 @@ CONTENTS *NERDCommenterContents*
3.1 Options summary...................|NERDComOptionsSummary|
3.2 Options details...................|NERDComOptionsDetails|
3.3 Default delimiter Options.........|NERDComDefaultDelims|
3.4 Key mapping Options...............|NERDComMappings|
4.Issues with the script..................|NERDComIssues|
4.1 Delimiter detection heuristics....|NERDComHeuristics|
4.2 Nesting issues....................|NERDComNesting|
5.The author..............................|NERDComAuthor|
6.Changelog...............................|NERDComChangelog|
7.Credits.................................|NERDComCredits|
8.License.................................|NERDComLicense|
4. Customising key mappings...............|NERDComMappings|
5. Issues with the script.................|NERDComIssues|
5.1 Delimiter detection heuristics....|NERDComHeuristics|
5.2 Nesting issues....................|NERDComNesting|
6.The author..............................|NERDComAuthor|
7.Changelog...............................|NERDComChangelog|
8.Credits.................................|NERDComCredits|
9.License.................................|NERDComLicense|
==============================================================================
1. Intro *NERDCommenter*
The NERD commenter provides many different commenting operations and styles
which may be invoked via key mappings and a commenting menu. These operations
are available for most filetypes.
which are invoked via key mappings and a menu. These operations are available
for most filetypes.
There are also options available that allow you to tweak the commenting engine
to you taste.
There are also options that allow to tweak the commenting engine to your
taste.
==============================================================================
2. Functionality provided *NERDComFunctionality*
@@ -61,17 +60,15 @@ to you taste.
2.1 Functionality summary *NERDComFunctionalitySummary*
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.
with items corresponding to all the mappings below):
[count],cc |NERDComComment|
Comments out the current line or text selected in visual mode.
Comment out the current line or text selected in visual mode.
[count],cn |NERDComNestedComment|
Same as |NERDComComment| but forces nesting.
Same as ,cc but forces nesting.
[count],c<space> |NERDComToggleComment|
Toggles the comment state of the selected line(s). If the topmost selected
@@ -79,13 +76,11 @@ line is commented, all selected lines are uncommented and vice versa.
[count],cm |NERDComMinimalComment|
Comments the given lines using only one set of multipart delimiters if
possible.
Comments the given lines using only one set of multipart delimiters.
[count],ci |NERDComInvertComment|
Toggles the comment state of the selected line(s) individually. Each selected
line that is commented is uncommented and vice versa.
Toggles the comment state of the selected line(s) individually.
[count],cs |NERDComSexyComment|
@@ -93,8 +88,7 @@ Comments out the selected lines ``sexily''
[count],cy |NERDComYankComment|
Same as |NERDComComment| except that the commented line(s) are yanked
before commenting.
Same as ,cc except that the commented line(s) are yanked first.
,c$ |NERDComEOLComment|
@@ -106,12 +100,7 @@ Adds comment delimiters to the end of line and goes into insert mode between
them.
,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.
Disabled by default.
@@ -121,11 +110,9 @@ Switches to the alternative set of delimiters.
[count],cl
[count],cr
[count],cb |NERDComAlignedComment|
Same as |NERDComComment| except that the delimiters are aligned down the
left side (,cl), the right side (,cr) or both sides
(,cb).
left side (,cl) or both sides (,cb).
[count],cu |NERDComUncommentLine|
@@ -138,7 +125,7 @@ Uncomments the selected line(s).
2.2.1 Comment map *NERDComComment*
Default mapping: [count],cc
Change the mapping with: NERDComLineMap.
Mapped to: <plug>NERDCommenterComment
Applicable modes: normal visual visual-line visual-block.
@@ -154,13 +141,13 @@ lines were selected in visual-line mode.
2.2.2 Nested comment map *NERDComNestedComment*
Default mapping: [count],cn
Change the mapping with: NERDComLineNestMap.
Mapped to: <plug>NERDCommenterNest
Applicable modes: normal visual visual-line visual-block.
Performs nested commenting. Works the same as ,cc except that if a
line is already commented then it will be commented again.
Performs nested commenting. Works the same as ,cc except that if a line 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
be replaced by place-holder delimiters if needed. Otherwise the nested
comment will only be added if the current commenting delimiters have no right
delimiter (to avoid syntax errors)
@@ -169,13 +156,13 @@ If a [count] is given in normal mode, the mapping works as though that many
lines were selected in visual-line mode.
Related options:
|NERDDefaultNesting|
|'NERDDefaultNesting'|
------------------------------------------------------------------------------
2.2.3 Toggle comment map *NERDComToggleComment*
Default mapping: [count],c<space>
Change the mapping with: NERDComLineToggleMap.
Mapped to: <plug>NERDCommenterToggle
Applicable modes: normal visual-line.
Toggles commenting of the lines selected. The behaviour of this mapping
@@ -192,18 +179,18 @@ lines were selected in visual-line mode.
2.2.4 Minimal comment map *NERDComMinimalComment*
Default mapping: [count],cm
Change the mapping with: NERDComLineMinimalMap
Mapped to: <plug>NERDCommenterMinimal
Applicable modes: normal visual-line.
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
,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.
For example: if you are programming in c and you select 5 lines and press ,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.
Sets of multipart comment delimiters that are between the top and bottom
selected lines are replaced with place holders (see |NERDLPlace|) if
|NERDUsePlaceHolders| is set for the current filetype. If it is not, then
selected lines are replaced with place holders (see |'NERDLPlace'|) if
|'NERDUsePlaceHolders'| is set for the current filetype. If it is not, then
the comment will be aborted if place holders are required to prevent illegal
syntax.
@@ -214,7 +201,7 @@ lines were selected in visual-line mode.
2.2.5 Invert comment map *NERDComInvertComment*
Default mapping: ,ci
Change the mapping with: NERDComLineInvertMap.
Mapped to: <plug>NERDCommenterInvert
Applicable modes: normal visual-line.
Inverts the commented state of each selected line. If the a selected line is
@@ -231,7 +218,7 @@ lines were selected in visual-line mode.
2.2.6 Sexy comment map *NERDComSexyComment*
Default mapping: [count],cs
Change the mapping with: NERDComLineSexyMap
Mapped to: <plug>NERDCommenterSexy
Applicable modes: normal, visual-line.
Comments the selected line(s) ``sexily''... see |NERDComSexyComments| for
@@ -245,13 +232,13 @@ If a [count] is given in normal mode, the mapping works as though that many
lines were selected in visual-line mode.
Related options:
|NERDCompactSexyComs|
|'NERDCompactSexyComs'|
------------------------------------------------------------------------------
2.2.7 Yank comment map *NERDComYankComment*
Default mapping: [count],cy
Change the mapping with: NERDComLineYankMap
Mapped to: <plug>NERDCommenterYank
Applicable modes: normal visual visual-line visual-block.
Same as ,cc except that it yanks the line(s) that are commented first.
@@ -260,7 +247,7 @@ Same as ,cc except that it yanks the line(s) that are commented first.
2.2.8 Comment to EOL map *NERDComEOLComment*
Default mapping: ,c$
Change the mapping with: NERDComToEOLMap
Mapped to: <plug>NERDCommenterToEOL
Applicable modes: normal.
Comments the current line from the current cursor position up to the end of
@@ -270,27 +257,17 @@ the line.
2.2.9 Append com to line map *NERDComAppendComment*
Default mapping: ,cA
Change the mapping with: NERDAppendComMap.
Mapped to: <plug>NERDCommenterAppend
Applicable modes: normal.
Appends comment delimiters to the end of the current line and goes
to insert mode between the new delimiters.
------------------------------------------------------------------------------
2.2.10 Prepend com to line map *NERDComPrependComment*
Default mapping: ,cI
Change the mapping with: NERDPrependComMap.
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*
2.2.10 Insert comment map *NERDComInsertComment*
Default mapping: disabled by default.
Change the mapping with: NERDComInInsertMap.
Map it to: <plug>NERDCommenterInInsert
Applicable modes: insert.
Adds comment delimiters at the current cursor position and inserts
@@ -303,10 +280,10 @@ mapping add >
to your vimrc.
------------------------------------------------------------------------------
2.2.12 Use alternate delims map *NERDComAltDelim*
2.2.11 Use alternate delims map *NERDComAltDelim*
Default mapping: ,ca
Change the mapping with: NERDAltComMap
Mapped to: <plug>NERDCommenterAltDelims
Applicable modes: normal.
Changes to the alternative commenting style if one is available. For example,
@@ -316,25 +293,25 @@ then they will be switched over to /**/ comments.
See also |NERDComDefaultDelims|
------------------------------------------------------------------------------
2.2.13 Comment aligned maps *NERDComAlignedComment*
2.2.12 Comment aligned maps *NERDComAlignedComment*
Default mappings: [count],cl [count],cr [count],cb
Change the mappings with: NERDComAlignLeftMap, NERDComAlignRightMap and
NERDComAlignBothMap.
Default mappings: [count],cl [count],cb
Mapped to: <plug>NERDCommenterAlignLeft
<plug>NERDCommenterAlignBoth
Applicable modes: normal visual-line.
Same as ,cc except that the comment delimiters are aligned on the left
side, right side or both sides respectively. These comments are always nested
if the line(s) are already commented.
Same as ,cc except that the comment delimiters are aligned on the left side or
both sides respectively. These comments are always nested if the line(s) are
already commented.
If a [count] is given in normal mode, the mapping works as though that many
lines were selected in visual-line mode.
------------------------------------------------------------------------------
2.2.14 Uncomment line map *NERDComUncommentLine*
2.2.13 Uncomment line map *NERDComUncommentLine*
Default mapping: [count],cu
Change the mapping with: NERDUncomLineMap.
Mapped to: <plug>NERDCommenterUncomment
Applicable modes: normal visual visual-line visual-block.
Uncomments the current line. If multiple lines are selected in
@@ -350,8 +327,8 @@ If a [count] is given in normal mode, the mapping works as though that many
lines were selected in visual-line mode.
Related options:
|NERDRemoveAltComs|
|NERDRemoveExtraSpaces|
|'NERDRemoveAltComs'|
|'NERDRemoveExtraSpaces'|
------------------------------------------------------------------------------
2.3 Supported filetypes *NERDComFiletypes*
@@ -400,8 +377,7 @@ one other marker symbol. For example: >
* So there!
* But this one is ``compact'' style */
<
Here the multipart delimiters are /* and */ and the marker is *. The NERD
commenter is capable of adding and removing comments of this type.
Here the multipart delimiters are /* and */ and the marker is *.
------------------------------------------------------------------------------
2.5 The NERDComment function *NERDComNERDComment*
@@ -417,9 +393,9 @@ The arguments to this function are simple:
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
performed, and it can be one of the following: 'sexy', 'invert',
'minimal', 'toggle', 'alignLeft', 'alignRight', 'alignBoth', 'norm',
'nested', 'toEOL', 'prepend', 'append', 'insert', 'uncomment', 'yank'
performed, and it can be one of the following: "sexy", "invert",
"minimal", "toggle", "alignLeft", "alignBoth", "norm", "nested",
"toEOL", "append", "insert", "uncomment", "yank"
For example, if you typed >
:call NERDComment(1, 'sexy')
@@ -433,41 +409,40 @@ then the script would do a sexy comment on the last visual selection.
------------------------------------------------------------------------------
3.1 Options summary *NERDComOptionsSummary*
|loaded_nerd_comments| Turns off the script.
|NERDAllowAnyVisualDelims| Allows multipart alternative delims to
|'loaded_nerd_comments'| Turns off the script.
|'NERDAllowAnyVisualDelims'| Allows multipart alternative delims to
be used when commenting in
visual/visual-block mode.
|NERDBlockComIgnoreEmpty| Forces right delims to be placed when
|'NERDBlockComIgnoreEmpty'| Forces right delims to be placed when
doing visual-block comments.
|NERDCommentWholeLinesInVMode| Changes behaviour of visual comments.
|NERDDefaultNesting| Tells the script to use nested comments
|'NERDCommentWholeLinesInVMode'| Changes behaviour of visual comments.
|'NERDCreateDefaultMappings'| Turn the default mappings on/off.
|'NERDDefaultNesting'| Tells the script to use nested comments
by default.
|NERDMenuMode| Specifies how the NERD commenter menu
|'NERDMenuMode'| Specifies how the NERD commenter menu
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
comments.
|NERDMapleader| Specifies what all the commenting key
mappings will begin with.
|NERDUsePlaceHolders| Specifies which filetypes may use
|'NERDUsePlaceHolders'| Specifies which filetypes may use
placeholders when nesting comments.
|NERDRemoveAltComs| Tells the script whether to remove
|'NERDRemoveAltComs'| Tells the script whether to remove
alternative comment delimiters when
uncommenting.
|NERDRemoveExtraSpaces| Tells the script to always remove the
|'NERDRemoveExtraSpaces'| Tells the script to always remove the
extra spaces when uncommenting
(regardless of whether NERDSpaceDelims
is set)
|NERDRPlace| Specifies what to use as the right
|'NERDRPlace'| Specifies what to use as the right
delimiter placeholder when nesting
comments.
|NERDShutUp| Stops "Unknown filetype" output from the
|'NERDShutUp'| Stops "Unknown filetype" output from the
script
|NERDSpaceDelims| Specifies whether to add extra spaces
|'NERDSpaceDelims'| Specifies whether to add extra spaces
around delimiters when commenting, and
whether to remove them when
uncommenting.
|NERDCompactSexyComs| Specifies whether to use the compact
|'NERDCompactSexyComs'| Specifies whether to use the compact
style sexy comments.
------------------------------------------------------------------------------
@@ -476,13 +451,13 @@ then the script would do a sexy comment on the last visual selection.
To enable any of the below options you should put the given line in your
~/.vimrc
*loaded_nerd_comments*
*'loaded_nerd_comments'*
If this script is driving you insane you can turn it off by setting this
option >
let loaded_nerd_comments=1
<
------------------------------------------------------------------------------
*NERDAllowAnyVisualDelims*
*'NERDAllowAnyVisualDelims'*
Values: 0 or 1.
Default: 1.
@@ -505,7 +480,7 @@ shown on the right: >
System.out.println(foo * bar); System.out.println(foo * bar);
<
------------------------------------------------------------------------------
*NERDBlockComIgnoreEmpty*
*'NERDBlockComIgnoreEmpty'*
Values: 0 or 1.
Default: 1.
@@ -548,7 +523,7 @@ Otherwise, the code block would become: >
/*} */
<
------------------------------------------------------------------------------
*NERDCommentWholeLinesInVMode*
*'NERDCommentWholeLinesInVMode'*
Values: 0, 1 or 2.
Default: 0.
@@ -586,15 +561,25 @@ then stick the following line in your vimrc: >
let NERDCommentWholeLinesInVMode=2
<
Note that this option does not affect the behaviour of |visual-block| mode.
Note that this option does not affect the behaviour of commenting in
|visual-block| mode.
------------------------------------------------------------------------------
*NERDRemoveAltComs*
*'NERDCreateDefaultMappings'*
Values: 0 or 1.
Default: 1.
If set to 0, none of the default mappings will be created.
See also |NERDComMappings|.
------------------------------------------------------------------------------
*'NERDRemoveAltComs'*
Values: 0 or 1.
Default: 1.
When uncommenting a line (for a filetype with an alternative commenting style)
this option tells the script whether to look for, and remove, comments
this option tells the script whether to look for, and remove, comment
delimiters of the alternative style.
For example, if you are editing a c++ file using // style comments and you go
@@ -604,13 +589,13 @@ For example, if you are editing a c++ file using // style comments and you go
It will not be uncommented if the NERDRemoveAltComs is set to 0.
------------------------------------------------------------------------------
*NERDRemoveExtraSpaces*
*'NERDRemoveExtraSpaces'*
Values: 0 or 1.
Default: 1.
By default, the NERD commenter will remove spaces around comment delimiters if
either:
1. |NERDSpaceDelims| is set to 1.
1. |'NERDSpaceDelims'| is set to 1.
2. NERDRemoveExtraSpaces is set to 1.
This means that if we have the following lines in a c code file: >
@@ -629,12 +614,12 @@ Otherwise they would become: >
int bar = 10;
int baz = foo + bar
<
If you want the spaces to be removed only if |NERDSpaceDelims| is set then
If you want the spaces to be removed only if |'NERDSpaceDelims'| is set then
set NERDRemoveExtraSpaces to 0.
------------------------------------------------------------------------------
*NERDLPlace*
*NERDRPlace*
*'NERDLPlace'*
*'NERDRPlace'*
Values: arbitrary string.
Default:
NERDLPlace: "[>"
@@ -656,37 +641,7 @@ and we comment it with ,cn it will be changed to: >
When we uncomment this line it will go back to what it was.
------------------------------------------------------------------------------
*NERDMapleader*
Values: arbitrary string.
Default: ,c
NERDMapleader is used to specify what all the NERD commenter key mappings
begin with.
The default key mappings will look like this: >
,cc
,cu
,ca
,ci
,cs
...
<
However, if this line: >
let NERDMapleader = ',x'
<
were present in your vimrc then the default mappings would look like this: >
,xc
,xu
,xa
,xi
,xs
...
<
This option only affects the mappings that have not been explicitly set
manually (see |NERDComMappings|).
------------------------------------------------------------------------------
*NERDMenuMode*
*'NERDMenuMode'*
Values: 0, 1, 2, 3.
Default: 3
@@ -697,15 +652,15 @@ This option can take 4 values:
"3": Turns the 'Plugin -> comment' menu on with <alt>-c as the shortcut.
------------------------------------------------------------------------------
*NERDUsePlaceHolders*
*'NERDUsePlaceHolders'*
Values: 0 or 1.
Default 1.
This option is used to specify whether place-holder delimiters should be used
when adding nested comments.
when creating a nested comment.
------------------------------------------------------------------------------
*NERDShutUp*
*'NERDShutUp'*
Values: 0 or 1.
Default 1.
@@ -714,7 +669,7 @@ messages. Stick this line in your vimrc: >
let NERDShutUp=1
<
------------------------------------------------------------------------------
*NERDSpaceDelims*
*'NERDSpaceDelims'*
Values: 0 or 1.
Default 0.
@@ -727,10 +682,10 @@ as opposed to this: >
<
If you want spaces to be added then set NERDSpaceDelims to 1 in your vimrc.
See also |NERDRemoveExtraSpaces|.
See also |'NERDRemoveExtraSpaces'|.
------------------------------------------------------------------------------
*NERDCompactSexyComs*
*'NERDCompactSexyComs'*
Values: 0 or 1.
Default 0.
@@ -749,20 +704,19 @@ 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.
When this option is set to 1, comments are nested automatically. That is, if
you hit ,cc on a line that is already commented it will be commented
again
you hit ,cc on a line that is already commented it will be commented again
------------------------------------------------------------------------------
3.3 Default delimiter customisation *NERDComDefaultDelims*
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: >
let NERD_<&filetype>_alt_style=1
let NERD_<filetype>_alt_style=1
<
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: >
@@ -771,42 +725,27 @@ Example: java uses // style comments by default, but you want it to default to
See |NERDComAltDelim| for switching commenting styles at runtime.
------------------------------------------------------------------------------
3.4 Key mapping customisation *NERDComMappings*
==============================================================================
4. Key mapping customisation *NERDComMappings*
These options are used to override the default keys that are used for the
commenting mappings. Their values must be set to strings. As an example: if
you wanted to use the mapping ,foo to uncomment lines of code then
you would place this line in your vimrc >
let NERDUncomLineMap=",foo"
To change a mapping just map another key combo to the internal <plug> mapping.
For example, to remap the *NERDComComment* mapping to ",omg" you would put
this line in your vimrc: >
map ,omg <plug>NERDCommenterComment
<
Check out |NERDComFunctionality| for details about what the following
mappings do.
This will stop the corresponding default mappings from being created.
Default Mapping Option to override~
See the help for the mapping in question to see which <plug> mapping to
map to.
,ca NERDAltComMap
,ce NERDAppendComMap
,cl NERDComAlignLeftMap
,cb NERDComAlignBothMap
,cr NERDComAlignRightMap
<C-c> NERDComInInsertMap
,ci NERDComLineInvertMap
,cc NERDComLineMap
,cn NERDComLineNestMap
,cs NERDComLineSexyMap
,c<space> NERDComLineToggleMap
,cm NERDComLineMinimalMap
,c$ NERDComToEOLMap
,cy NERDComLineYankMap
,cu NERDUncomLineMap
See also |'NERDCreateDefaultMappings'|.
==============================================================================
4. Issues with the script *NERDComIssues*
5. Issues with the script *NERDComIssues*
------------------------------------------------------------------------------
4.1 Delimiter detection heuristics *NERDComHeuristics*
5.1 Delimiter detection heuristics *NERDComHeuristics*
Heuristics are used to distinguish the real comment delimiters
@@ -826,7 +765,7 @@ string. These heuristics, while usually pretty accurate, will not work for all
cases.
------------------------------------------------------------------------------
4.2 Nesting issues *NERDComNesting*
5.2 Nesting issues *NERDComNesting*
If we have some line of code like this: >
/*int foo */ = /*5 + 9;*/
@@ -846,7 +785,7 @@ will become: >
for simplicity)
==============================================================================
5. The author *NERDComAuthor*
6. The author *NERDComAuthor*
The author of the NERD commenter is Martyzillatron --- the half robot, half
dinosaur bastard son of Megatron and Godzilla. He enjoys destroying
@@ -857,8 +796,19 @@ 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? :(
==============================================================================
7. Changelog *NERDComChangelog*
8. Changelog *NERDComChangelog*
2.2.0
- rewrote the mappings system to be more "standard".
- removed all the mapping options. Now, mappings to <plug> mappings are
used
- see :help NERDComMappings, and :help NERDCreateDefaultMappings for
more info
- remove "prepend comments" and "right aligned comments".
- add support for applescript, calbire, man, SVNcommit, potwiki, txt2tags and SVNinfo.
Thanks to nicothakis, timberke, sgronblo, mntnoe, Bernhard Grotz, John
O'Shea, François and Giacomo Mariani respectively.
- bugfix for haskell delimiters. Thanks to mntnoe.
2.1.18
- add support for llvm. Thanks to nicothakis.
- add support for xquery. Thanks to Phillip Kovalev.
@@ -871,222 +821,8 @@ if your face looked like a toaster and a t-rex put together? :(
- disable the insert mode ctrl-c mapping by default, see :help
NERDComInsertComment if you wish to restore it
2.1.16
- compatibility fix for vim7.2, cheers to Ben Schmidt, David Fishburn, and
Erik Falor for the emails, and to JaGoTerr for posting the issue.
2.1.15
- added pamconf support, thanks to Martin Kustermann
- added mason support, thanks to Indriði Einarsson
- added map support, thanks to Chris
- added bzr support, thanks to Stromnov
- added group support, thanks to Krzysztof A. Adamski
- change license to wtfpl
2.1.14
- added support for gitconfig, tar, nerdtree
- added support for dtrace, thanks to nicothakis for the post
2.1.13
- added support for rib, pyrex/cython, liquid, services, gitcommit,
vimperator, and slice. Thanks to spookypeanut, Greg Jandl, Christophe
Benz, A Pontus, and Stromnov for emailing me and/or posting issues.
- set the NERDRemoveExtraSpaces option to 1 by default as the doc states
- other fixes: (thanks to Zhang Shuhan for all his emails and testing)
* made the sexy comment mapping fall back to normal commenting if sexy
comments arent possible for the current filetype
* fixed some bugs with sexy comments
* made the uncommenting side of toggle comments slightly more robust
* fixed a bug where some extra spaces werent being removed (although
the currect options were set)
2.1.12
- added support for patran and dakota, thx to Jacobo Diaz for the email
- added support for gentoo-env-d, gentoo-init-d, gentoo-make-conf, grub,
modconf and sudoers filetypes, thx to Li Jin for the patch.
- added support for SVNdiff, gitAnnotate, gitdiff. Thx to nicothakis for
posting the issue
2.1.11
- fixed a bug with the selection option and visual commenting (again).
Thanks to Ingo Karkat (again).
2.1.10
- added support for Wikipedia (thanks to Chen Xing)
- added support for mplayerconf
- bugfixes (thanks to Ingo Karkat for the bug report/patch)
- added support for mkd (thanks to Stefano Zacchiroli)
2.1.9
- added support for mrxvtrc and aap, thx to Marco for the emails
- added dummy support for SVNAnnotate, SVKAnnotate and CVSAnnotate, thx to
nicothakis for posting the issue
2.1.8
- fixed a couple of bugs with the NERDSpaceDelims option, thx to
David Miani and Jeremy Hinegardner
- added dummy support for lhaskell, thx to pipp for posting the issue
- added an alternative set of delims for the plsql filetype, thx to Kuchma
Michael
- added support for spectre, thx to Brett Warneke
- added support for scala, thx to Renald Buter
- added support for asymptote, thx to Vladimir Lomov
- made NERDDefaultNesting enabled by default as this seems more intuitive,
thx to marco for the suggestion
2.1.7
- added support for haml, thx to Greb Weber
- added support for asterisk, thx to Laurent ARNOUD
- added support for objcpp, thx to Nicolas Weber
- added support for the factor filetype, thx to Aaron Schaefer
- fixed a bug with the passwd filetype setup, thx to Yongwei Wu
- fixed a bug that was forcing filetypes with an alternative set of delims
to have at least one multipart set.
- split out the help file out from the script and repackaged everything as
a zip
2.1.6
- added support for gentoo-conf-d thanks to tinoucas for posting the issue
and the patch
- added support for the D filetype. Thanks to Greg Weber for the email.
- added dummy support for cobol, cheers to timberke for posting the issue.
- added support for velocity. Thanks to Bruce Sherrod for the email.
2.1.5
- added support for lilypond, bbx and lytex. Thanks to Eyolf Østrem for
the email.
- added an alterative set of delimiters for the dosbatch filetype, thanks
to Ingo Karkat for the email.
- added support for the markdown filetype. Thanks to Nicolas Weber for the
posting the issue.
2.1.4
- added support for the ahk filetype. Cheers to Don Hatlestad for the
email.
- added support for desktop and xsd filetypes. Thanks to Christophe Benz.
- added dummy support for Rails-log
- fixed a bunch of bugs in the comment delimiter setup process, thanks to
Cheng Fang for the email :D
- hardcore refactoring and removal of seldomly used, overly-complex
functionality.
- the script now requires vim 7
2.1.3
- fixed numerous bugs that were causing tabs to permanently be converted
to spaces, even if noexpandtab was set. Thanks to Heptite on #vim for
working with me to track them down :)
- added dummy support for "lookupfile". Thanks to David Fishburn for the
email.
- added support for "rst", thanks to Niels Aan de Brugh for the email.
2.1.2
- added support for the vera and ldif filetypes. Thanks to Normandie
Azucena and Florian Apolloner for the emails.
2.1.1
- added dummy support for SVNcommitlog and vcscommit. Thanks to John
O'Shea for the email.
- added support for Groovy. Thanks to Jason Mills for the email.
2.1.0
- now the script resets the delimiters when the filetype of the buffer
changes (thanks to James Hales for the patch)
- added formal support/doc for prepending a count to many of the
commenting maps so you can go, eg, 5,cc to comment 5 lines from normal
mode. Thanks again to James Hales for the patch.
- added support for the "gams" filetype that Jorge Rodrigues created.
- added support for the "objc" filetype, thanks to Rainer Müller for the
email.
- added support for the "sass" filetype that Dmitry Ilyashevich created.
2.0.7
- Added support for eclass and ebuild filetypes. Thanks to Alex Tarkovsky
for the email.
2.0.6
- Changed the default setting of NERDMapleader to ",c", meaning all the
maps now start with ,c instead of \c. This is to stop a major mapping
clash with the vcscommand plugin. Anyone wanting to keep the \c map
leader should read :help NERDMapleader.
- Added support for debcontrol and dummy support for debchangelog
filetypes, thanks to Stefano Zacchiroli for the email.
- Made it so that the NERDShutUp option now only controls the "Pleeease
email the delimiters..." requests. It no longer affects the general
output of the script.
- Simplified the names of the help tags.
2.0.5
- Added support for autoit, autohotkey and docbk filetypes (thanks to
Michael Böhler)
- Added support for cmake (thanks to Aaron Small)
- Added support for htmldjango and django filetypes (thanks to Ramiro
Morales)
- Improved the delimiters for eruby again
- Applied a patch from Seth Mason to fix some pathing issues with the help
file installation.
2.0.4
- Added support for verilog_systemverilog and systemverilog filetypes
(Thanks to Alexey for the email)
- Added support for fstab, thanks to Lizendir for the email.
- Added support for the smarty filetype.
- Improved the delimiters for eruby.
- Added dummy support for changelog filetype.
2.0.3
- Added dummy support for the csv filetype (thx to Mark Woodward for the
email)
- Added dummy support for vo_base and otl filetypes (thanks to fREW for
the email)
2.0.2:
- Minor bug fix that was stopping nested comments from working
2.0.1:
- Fixed the visual bell for the |NERDComToEOLMap| map.
- Added another possible value to the NERDMenuMode option which causes the
menu to be displayed under 'Plugin -> Comment'. See :h NERDMenuMode.
This new menu mode is now the default.
- Added support for the occam filetype (thanks to Anders for emailing me)
- Made the main commenting function (NERDComment) available outside the
script.
- bug fixes and refactoring
2.0.0:
- NOTE: renamed the script to NERD_commenter.vim. When you install this
version you must delete the old files: NERD_comments.vim and
NERD_comments.txt.
- Reworked the mappings and main entry point function for the script to
avoid causing visual-bells and screen scrolling.
- Changes to the script options (see |NERD_com-Customisation| for
details):
- They are all camel case now instead of underscored.
- Converted all of the regular expression options into simple boolean
options for simplicity.
- All the options are now stated positively, eg.
NERD_dont_remove_spaces_regexp has become NERDRemoveExtraSpaces.
- Some of the option names have been changed (other than in the above
ways)
- Some have been removed altogether, namely: NERD_create_h_filetype
(why was a commenting script creating a filetype?!),
NERD_left_align_regexp, NERD_right_align_regexp,
- Removed all the NERD_use_alt_style_XXX_coms options and replaced them
with a better system. Now if a filetype has alternative delims, the
script will check whether an option of the form
"NERD_<&filetype>_alt_style" exists, and if it does then alt delims will
be used. See |NERD_com-cust-delims| for details.
- The script no longer removes extra spaces for sexy comments for the
NERDRemoveExtraSpaces option (it will still remove spaces if
NERDSpaceDelims is set).
- Added dummy support for viminfo and rtf.
- Added support for the "gentoo-package-\(keywords\|mask\|use\)"
filetypes.
- Added '#' comments as an alternative for the asm filetype
Thanks to Markus Klinik and Anders for bug reports, and again to Anders
for his patch. Thanks to John O'Shea and fREW for the filetype
information.
==============================================================================
7. Credits *NERDComCredits*
8. Credits *NERDComCredits*
Thanks and respect to the following people:
@@ -1217,6 +953,8 @@ incompatibility with vim7.2. Thanks also to JaGoTerr for posting the issue.
Thanks to Elias Pipping for sending me a bug report about haskell commenting.
Thanks to mntnoe for pointing out incorrect delimiters for haskell.
Not to forget! Thanks to the following people for sending me new filetypes to
support :D
@@ -1228,7 +966,7 @@ Michael Brunner kconfig
Antono Vasiljev netdict
Melissa Reid omlet
Ilia N Ternovich quickfix
John O'Shea RTF, SVNcommitlog and vcscommit
John O'Shea RTF, SVNcommitlog and vcscommit, SVNCommit
Anders occam
Mark Woodward csv
fREW gentoo-package-mask,
@@ -1256,7 +994,7 @@ Nicolas Weber markdown, objcpp
tinoucas gentoo-conf-d
Greg Weber D, haml
Bruce Sherrod velocity
timberke cobol
timberke cobol, calibre
Aaron Schaefer factor
Laurent ARNOUD asterisk, mplayerconf
Kuchma Michael plsql
@@ -1267,7 +1005,7 @@ Vladimir Lomov asymptote
Marco mrxvtrc, aap
nicothakis SVNAnnotate, CVSAnnotate, SVKAnnotate,
SVNdiff, gitAnnotate, gitdiff, dtrace
llvm
llvm, applescript
Chen Xing Wikipedia
Jacobo Diaz dakota, patran
Li Jin gentoo-env-d, gentoo-init-d,
@@ -1284,9 +1022,13 @@ Krzysztof A. Adamski group
Pascal Brueckner mailcap
Jerónimo Carballo stata
Phillip Kovalev xquery
Bernhard Grotz potwiki
sgronblo man
François txt2tags
Giacomo Mariani SVNinfo
==============================================================================
8. License *NERDComLicense*
9. License *NERDComLicense*
The NERD commenter is released under the wtfpl.
See http://sam.zoy.org/wtfpl/COPYING.

View File

@@ -2,8 +2,8 @@
" File: NERD_commenter.vim
" Description: vim global plugin that provides easy code commenting
" Maintainer: Martin Grenfell <martin_grenfell at msn dot com>
" Version: 2.1.17
" Last Change: 27 June, 2008
" Version: 2.2.0
" Last Change: 4th October, 2008
" License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
@@ -59,6 +59,7 @@ call s:InitVariable("g:NERDAllowAnyVisualDelims", 1)
call s:InitVariable("g:NERDBlockComIgnoreEmpty", 0)
call s:InitVariable("g:NERDCommentWholeLinesInVMode", 0)
call s:InitVariable("g:NERDCompactSexyComs", 0)
call s:InitVariable("g:NERDCreateDefaultMappings", 1)
call s:InitVariable("g:NERDDefaultNesting", 1)
call s:InitVariable("g:NERDMenuMode", 3)
call s:InitVariable("g:NERDLPlace", "[>")
@@ -70,24 +71,8 @@ call s:InitVariable("g:NERDShutUp", '0')
call s:InitVariable("g:NERDSpaceDelims", 0)
call s:InitVariable("g:NERDDelimiterRequests", 1)
call s:InitVariable("g:NERDMapleader", ',c')
call s:InitVariable("g:NERDAltComMap", g:NERDMapleader . 'a')
call s:InitVariable("g:NERDAppendComMap", g:NERDMapleader . 'A')
call s:InitVariable("g:NERDComAlignBothMap", g:NERDMapleader . 'b')
call s:InitVariable("g:NERDComAlignLeftMap", g:NERDMapleader . 'l')
call s:InitVariable("g:NERDComAlignRightMap", g:NERDMapleader . 'r')
call s:InitVariable("g:NERDComInInsertMap", '')
call s:InitVariable("g:NERDComLineInvertMap", g:NERDMapleader . 'i')
call s:InitVariable("g:NERDComLineMap", g:NERDMapleader . 'c')
call s:InitVariable("g:NERDComLineNestMap", g:NERDMapleader . 'n')
call s:InitVariable("g:NERDComLineSexyMap", g:NERDMapleader . 's')
call s:InitVariable("g:NERDComLineToggleMap", g:NERDMapleader . '<space>')
call s:InitVariable("g:NERDComLineMinimalMap", g:NERDMapleader . 'm')
call s:InitVariable("g:NERDComLineYankMap", g:NERDMapleader . 'y')
call s:InitVariable("g:NERDComToEOLMap", g:NERDMapleader . '$')
call s:InitVariable("g:NERDPrependComMap", g:NERDMapleader . 'I')
call s:InitVariable("g:NERDUncomLineMap", g:NERDMapleader . 'u')
let s:NERDFileNameEscape="[]#*$%'\" ?`!&();<>\\"
" Section: Comment mapping functions, autocommands and commands {{{1
@@ -95,21 +80,16 @@ let s:NERDFileNameEscape="[]#*$%'\" ?`!&();<>\\"
" Section: Comment enabler autocommands {{{2
" ============================================================================
if !exists("nerd_autocmds_loaded")
let nerd_autocmds_loaded=1
augroup commentEnablers
augroup commentEnablers
"if the user enters a buffer or reads a buffer then we gotta set up
"the comment delimiters for that new filetype
autocmd BufEnter,BufRead * :call s:SetUpForNewFiletype(&filetype, 0)
"if the user enters a buffer or reads a buffer then we gotta set up
"the comment delimiters for that new filetype
autocmd BufEnter,BufRead * :call s:SetUpForNewFiletype(&filetype, 0)
"if the filetype of a buffer changes, force the script to reset the
"delims for the buffer
autocmd Filetype * :call s:SetUpForNewFiletype(&filetype, 1)
augroup END
endif
"if the filetype of a buffer changes, force the script to reset the
"delims for the buffer
autocmd Filetype * :call s:SetUpForNewFiletype(&filetype, 1)
augroup END
" Function: s:SetUpForNewFiletype(filetype) function {{{2
@@ -163,6 +143,8 @@ function s:SetUpForNewFiletype(filetype, forceReset)
call s:MapDelimiters('#', '')
elseif a:filetype == "apachestyle"
call s:MapDelimiters('#', '')
elseif a:filetype == "applescript"
call s:MapDelimitersWithAlternative('--', '', '(*', '*)')
elseif a:filetype == "asm68k"
call s:MapDelimiters(';', '')
elseif a:filetype == "asm"
@@ -209,6 +191,8 @@ function s:SetUpForNewFiletype(filetype, forceReset)
call s:MapDelimiters('', '')
elseif a:filetype == "caos"
call s:MapDelimiters('*', '')
elseif a:filetype == "calibre"
call s:MapDelimiters('//','')
elseif a:filetype == "catalog"
call s:MapDelimiters('--','--')
elseif a:filetype == "c"
@@ -384,7 +368,7 @@ function s:SetUpForNewFiletype(filetype, forceReset)
elseif a:filetype == "gtkrc"
call s:MapDelimiters('#', '')
elseif a:filetype == "haskell"
call s:MapDelimitersWithAlternative('{-','-}', '--', '--')
call s:MapDelimitersWithAlternative('{-','-}', '--', '')
elseif a:filetype == "hb"
call s:MapDelimiters('#', '')
elseif a:filetype == "h"
@@ -493,6 +477,8 @@ function s:SetUpForNewFiletype(filetype, forceReset)
call s:MapDelimiters('#','')
elseif a:filetype == "make"
call s:MapDelimiters('#','')
elseif a:filetype == "man"
call s:MapDelimiters('."', '')
elseif a:filetype == "map"
call s:MapDelimiters('%', '')
elseif a:filetype == "maple"
@@ -619,6 +605,8 @@ function s:SetUpForNewFiletype(filetype, forceReset)
call s:MapDelimiters('#', '')
elseif a:filetype == "postscr"
call s:MapDelimiters('%', '')
elseif a:filetype == "potwiki"
call s:MapDelimiters('', '')
elseif a:filetype == "pov"
call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "povini"
@@ -777,10 +765,14 @@ function s:SetUpForNewFiletype(filetype, forceReset)
call s:MapDelimiters('','')
elseif a:filetype == "SVNAnnotate"
call s:MapDelimiters('','')
elseif a:filetype == "SVNcommit"
call s:MapDelimiters('','')
elseif a:filetype == "SVNcommitlog"
call s:MapDelimiters('','')
elseif a:filetype == "SVNdiff"
call s:MapDelimiters('','')
elseif a:filetype == "SVNinfo"
call s:MapDelimiters('','')
elseif a:filetype == "systemverilog"
call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "tads"
@@ -821,6 +813,8 @@ function s:SetUpForNewFiletype(filetype, forceReset)
call s:MapDelimiters('#', '')
elseif a:filetype == "tssgm"
call s:MapDelimiters("comment = '","'")
elseif a:filetype == "txt2tags"
call s:MapDelimiters('%','')
elseif a:filetype == "uc"
call s:MapDelimitersWithAlternative('//','', '/*','*/')
elseif a:filetype == "uil"
@@ -1157,10 +1151,9 @@ endfunction
" Args:
" -forceNested: a flag indicating whether the called is requesting the comment
" to be nested if need be
" -alignRight/alignLeft: 0/1 if the comments delimiters should/shouldnt be
" aligned left/right
" -align: should be "left" or "both" or "none"
" -firstLine/lastLine: the top and bottom lines to comment
function s:CommentLines(forceNested, alignLeft, alignRight, firstLine, lastLine)
function s:CommentLines(forceNested, align, firstLine, lastLine)
" we need to get the left and right indexes of the leftmost char in the
" block of of lines and the right most char so that we can do alignment of
" the delimiters if the user has specified
@@ -1192,12 +1185,12 @@ function s:CommentLines(forceNested, alignLeft, alignRight, firstLine, lastLine)
" check if we can comment this line
if !isCommented || g:NERDUsePlaceHolders || s:Multipart()
if a:alignLeft
if a:align == "left" || a:align == "both"
let theLine = s:AddLeftDelimAligned(s:GetLeft(0,1,0), theLine, leftAlignIndx)
else
let theLine = s:AddLeftDelim(s:GetLeft(0,1,0), theLine)
endif
if a:alignRight
if a:align == "both"
let theLine = s:AddRightDelimAligned(s:GetRight(0,1,0), theLine, rightAlignIndx)
else
let theLine = s:AddRightDelim(s:GetRight(0,1,0), theLine)
@@ -1446,7 +1439,7 @@ function s:CommentRegion(topLine, topCol, bottomLine, bottomCol, forceNested)
let topOfRange = a:topLine+1
let bottomOfRange = a:bottomLine-1
if topOfRange <= bottomOfRange
call s:CommentLines(a:forceNested, 0, 0, topOfRange, bottomOfRange)
call s:CommentLines(a:forceNested, "none", topOfRange, bottomOfRange)
endif
"comment the bottom line
@@ -1504,15 +1497,15 @@ function s:InvertComment(firstLine, lastLine)
endwhile
endfunction
" Function: NERDComment(isVisual, alignLeft, alignRight, type) function {{{2
" Function: NERDComment(isVisual, type) function {{{2
" This function is a Wrapper for the main commenting functions
"
" Args:
" -isVisual: a flag indicating whether the comment is requested in visual
" mode or not
" -type: the type of commenting requested. Can be 'sexy', 'invert',
" 'minimal', 'toggle', 'alignLeft', 'alignRight', 'alignBoth', 'norm',
" 'nested', 'toEOL', 'prepend', 'append', 'insert', 'uncomment', 'yank'
" 'minimal', 'toggle', 'alignLeft', 'alignBoth', 'norm',
" 'nested', 'toEOL', 'append', 'insert', 'uncomment', 'yank'
function! NERDComment(isVisual, type) range
" we want case sensitivity when commenting
let oldIgnoreCase = &ignorecase
@@ -1538,13 +1531,17 @@ function! NERDComment(isVisual, type) range
elseif a:isVisual && visualmode() == "v" && (g:NERDCommentWholeLinesInVMode==0 || (g:NERDCommentWholeLinesInVMode==2 && s:HasMultipartDelims()))
call s:CommentRegion(firstLine, firstCol, lastLine, lastCol, forceNested)
else
call s:CommentLines(forceNested, 0, 0, firstLine, lastLine)
call s:CommentLines(forceNested, "none", firstLine, lastLine)
endif
elseif a:type == 'alignLeft' || a:type == 'alignRight' || a:type == 'alignBoth'
let alignLeft = (a:type == 'alignLeft' || a:type == 'alignBoth')
let alignRight = (a:type == 'alignRight' || a:type == 'alignBoth')
call s:CommentLines(forceNested, alignLeft, alignRight, firstLine, lastLine)
elseif a:type == 'alignLeft' || a:type == 'alignBoth'
let align = "none"
if a:type == "alignLeft"
let align = "left"
elseif a:type == "alignBoth"
let align = "both"
endif
call s:CommentLines(forceNested, align, firstLine, lastLine)
elseif a:type == 'invert'
call s:InvertComment(firstLine, lastLine)
@@ -1553,7 +1550,7 @@ function! NERDComment(isVisual, type) range
try
call s:CommentLinesSexy(firstLine, lastLine)
catch /NERDCommenter.Delimiters/
call s:CommentLines(forceNested, 0, 0, firstLine, lastLine)
call s:CommentLines(forceNested, "none", firstLine, lastLine)
catch /NERDCommenter.Nesting/
call s:NerdEcho("Sexy comment aborted. Nested sexy cannot be nested", 0)
endtry
@@ -1581,9 +1578,6 @@ function! NERDComment(isVisual, type) range
call s:CommentBlock(firstLine, firstLine, col("."), col("$")-1, 1)
call s:RestoreScreenState()
elseif a:type == 'prepend'
call s:PrependCommentToLine()
elseif a:type == 'append'
call s:AppendCommentToLine()
@@ -1661,46 +1655,6 @@ function s:PlaceDelimitersAndInsBetween()
startinsert
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
" this function is called to remove the first left comment delimiter and the
" last right delimiter of the given line.
@@ -3238,70 +3192,91 @@ function s:UntabbedCol(line, col)
endfunction
" Section: Comment mapping setup {{{1
" ===========================================================================
" This is where the mappings calls are made that set up the commenting key
" mappings.
" set up the mapping to switch to/from alternative delimiters
execute 'nnoremap <silent>' . g:NERDAltComMap . ' :call <SID>SwitchToAlternativeDelimiters(1)<cr>'
" switch to/from alternative delimiters
nnoremap <plug>NERDCommenterAltDelims :call <SID>SwitchToAlternativeDelimiters(1)<cr>
" set up the mappings to comment out lines
execute 'nnoremap <silent>' . g:NERDComLineMap . ' :call NERDComment(0, "norm")<cr>'
execute 'vnoremap <silent>' . g:NERDComLineMap . ' <ESC>:call NERDComment(1, "norm")<cr>'
" comment out lines
nnoremap <silent> <plug>NERDCommenterComment :call NERDComment(0, "norm")<cr>
vnoremap <silent> <plug>NERDCommenterComment <ESC>:call NERDComment(1, "norm")<cr>
" set up the mappings to do toggle comments
execute 'nnoremap <silent>' . g:NERDComLineToggleMap . ' :call NERDComment(0, "toggle")<cr>'
execute 'vnoremap <silent>' . g:NERDComLineToggleMap . ' <ESC>:call NERDComment(1, "toggle")<cr>'
" toggle comments
nnoremap <silent> <plug>NERDCommenterToggle :call NERDComment(0, "toggle")<cr>
vnoremap <silent> <plug>NERDCommenterToggle <ESC>:call NERDComment(1, "toggle")<cr>
" set up the mapp to do minimal comments
execute 'nnoremap <silent>' . g:NERDComLineMinimalMap . ' :call NERDComment(0, "minimal")<cr>'
execute 'vnoremap <silent>' . g:NERDComLineMinimalMap . ' <ESC>:call NERDComment(1, "minimal")<cr>'
" minimal comments
nnoremap <silent> <plug>NERDCommenterMinimal :call NERDComment(0, "minimal")<cr>
vnoremap <silent> <plug>NERDCommenterMinimal <ESC>:call NERDComment(1, "minimal")<cr>
" set up the mappings to comment out lines sexily
execute 'nnoremap <silent>' . g:NERDComLineSexyMap . ' :call NERDComment(0, "sexy")<CR>'
execute 'vnoremap <silent>' . g:NERDComLineSexyMap . ' <ESC>:call NERDComment(1, "sexy")<CR>'
" sexy comments
nnoremap <silent> <plug>NERDCommenterSexy :call NERDComment(0, "sexy")<CR>
vnoremap <silent> <plug>NERDCommenterSexy <ESC>:call NERDComment(1, "sexy")<CR>
" set up the mappings to do invert comments
execute 'nnoremap <silent>' . g:NERDComLineInvertMap . ' :call NERDComment(0, "invert")<CR>'
execute 'vnoremap <silent>' . g:NERDComLineInvertMap . ' <ESC>:call NERDComment(1, "invert")<CR>'
" invert comments
nnoremap <silent> <plug>NERDCommenterInvert :call NERDComment(0, "invert")<CR>
vnoremap <silent> <plug>NERDCommenterInvert <ESC>:call NERDComment(1, "invert")<CR>
" set up the mappings to yank then comment out lines
execute 'nmap <silent>' . g:NERDComLineYankMap . ' :call NERDComment(0, "yank")<CR>'
execute 'vmap <silent>' . g:NERDComLineYankMap . ' <ESC>:call NERDComment(1, "yank")<CR>'
" yank then comment
nmap <silent> <plug>NERDCommenterYank :call NERDComment(0, "yank")<CR>
vmap <silent> <plug>NERDCommenterYank <ESC>:call NERDComment(1, "yank")<CR>
" set up the mappings for left aligned comments
execute 'nnoremap <silent>' . g:NERDComAlignLeftMap . ' :call NERDComment(0, "alignLeft")<cr>'
execute 'vnoremap <silent>' . g:NERDComAlignLeftMap . ' <ESC>:call NERDComment(1, "alignLeft")<cr>'
" left aligned comments
nnoremap <silent> <plug>NERDCommenterAlignLeft :call NERDComment(0, "alignLeft")<cr>
vnoremap <silent> <plug>NERDCommenterAlignLeft <ESC>:call NERDComment(1, "alignLeft")<cr>
" set up the mappings for right aligned comments
execute 'nnoremap <silent>' . g:NERDComAlignRightMap . ' :call NERDComment(0, "alignRight")<cr>'
execute 'vnoremap <silent>' . g:NERDComAlignRightMap . ' <ESC>:call NERDComment(1, "alignRight")<cr>'
" left and right aligned comments
nnoremap <silent> <plug>NERDCommenterAlignBoth :call NERDComment(0, "alignBoth")<cr>
vnoremap <silent> <plug>NERDCommenterAlignBoth <ESC>:call NERDComment(1, "alignBoth")<cr>
" set up the mappings for left and right aligned comments
execute 'nnoremap <silent>' . g:NERDComAlignBothMap . ' :call NERDComment(0, "alignBoth")<cr>'
execute 'vnoremap <silent>' . g:NERDComAlignBothMap . ' <ESC>:call NERDComment(1, "alignBoth")<cr>'
" nested comments
nnoremap <silent> <plug>NERDCommenterNest :call NERDComment(0, "nested")<cr>
vnoremap <silent> <plug>NERDCommenterNest <ESC>:call NERDComment(1, "nested")<cr>
" set up the mappings to do nested comments
execute 'nnoremap <silent>' . g:NERDComLineNestMap . ' :call NERDComment(0, "nested")<cr>'
execute 'vnoremap <silent>' . g:NERDComLineNestMap . ' <ESC>:call NERDComment(1, "nested")<cr>'
" uncomment
nnoremap <silent> <plug>NERDCommenterUncomment :call NERDComment(0, "uncomment")<cr>
vnoremap <silent> <plug>NERDCommenterUncomment :call NERDComment(1, "uncomment")<cr>
" set up the mapping to uncomment a line
execute 'nnoremap <silent>' . g:NERDUncomLineMap . ' :call NERDComment(0, "uncomment")<cr>'
execute 'vnoremap <silent>' . g:NERDUncomLineMap . ' :call NERDComment(1, "uncomment")<cr>'
" comment till the end of the line
nnoremap <silent> <plug>NERDCommenterToEOL :call NERDComment(0, "toEOL")<cr>
" set up the mapping to comment out to the end of the line
execute 'nnoremap <silent>' . g:NERDComToEOLMap . ' :call NERDComment(0, "toEOL")<cr>'
" append comments
nmap <silent> <plug>NERDCommenterAppend :call NERDComment(0, "append")<cr>
" set up the mappings to append comments to the line
execute 'nmap <silent>' . g:NERDAppendComMap . ' :call NERDComment(0, "append")<cr>'
" insert comments
inoremap <silent> <plug>NERDCommenterInInsert <SPACE><BS><ESC>:call NERDComment(0, "insert")<CR>
" set up the mappings to append comments to the line
execute 'nmap <silent>' . g:NERDPrependComMap . ' :call NERDComment(0, "prepend")<cr>'
" set up the mapping to insert comment delims at the cursor position in insert mode
if g:NERDComInInsertMap != ''
execute 'inoremap <silent>' . g:NERDComInInsertMap . ' ' . '<SPACE><BS><ESC>:call NERDComment(0, "insert")<CR>'
function! s:CreateMaps(target, combo)
if !hasmapto(a:target, 'n')
exec 'nmap ' . a:combo . ' ' . a:target
endif
if !hasmapto(a:target, 'v')
exec 'vmap ' . a:combo . ' ' . a:target
endif
endfunction
if g:NERDCreateDefaultMappings
call s:CreateMaps('<plug>NERDCommenterComment', ',cc')
call s:CreateMaps('<plug>NERDCommenterToggle', ',c<space>')
call s:CreateMaps('<plug>NERDCommenterMinimal', ',cm')
call s:CreateMaps('<plug>NERDCommenterSexy', ',cs')
call s:CreateMaps('<plug>NERDCommenterInvert', ',ci')
call s:CreateMaps('<plug>NERDCommenterYank', ',cy')
call s:CreateMaps('<plug>NERDCommenterAlignLeft', ',cl')
call s:CreateMaps('<plug>NERDCommenterAlignBoth', ',cb')
call s:CreateMaps('<plug>NERDCommenterNest', ',cn')
call s:CreateMaps('<plug>NERDCommenterUncomment', ',cu')
call s:CreateMaps('<plug>NERDCommenterToEOL', ',c$')
call s:CreateMaps('<plug>NERDCommenterAppend', ',cA')
if !hasmapto('<plug>NERDCommenterAltDelims', 'n')
nmap ,ca <plug>NERDCommenterAltDelims
endif
endif
" Section: Menu item setup {{{1
" ===========================================================================
"check if the user wants the menu to be displayed
@@ -3316,57 +3291,27 @@ if g:NERDMenuMode != 0
let menuRoot = '&Plugin.&comment'
endif
execute 'nmenu <silent> '. menuRoot .'.Comment<TAB>' . escape(g:NERDComLineMap, '\') . ' :call NERDComment(0, "norm")<CR>'
execute 'vmenu <silent> '. menuRoot .'.Comment<TAB>' . escape(g:NERDComLineMap, '\') . ' <ESC>:call NERDComment(1, "norm")<CR>'
execute 'nmenu <silent> '. menuRoot .'.Comment\ Toggle<TAB>' . escape(g:NERDComLineToggleMap, '\') . ' :call NERDComment(0, "toggle")<CR>'
execute 'vmenu <silent> '. menuRoot .'.Comment\ Toggle<TAB>' . escape(g:NERDComLineToggleMap, '\') . ' <ESC>:call NERDComment(1, "toggle")<CR>'
execute 'nmenu <silent> '. menuRoot .'.Comment\ Minimal<TAB>' . escape(g:NERDComLineMinimalMap, '\') . ' :call NERDComment(0, "minimal")<CR>'
execute 'vmenu <silent> '. menuRoot .'.Comment\ Minimal<TAB>' . escape(g:NERDComLineMinimalMap, '\') . ' <ESC>:call NERDComment(1, "minimal")<CR>'
execute 'nmenu <silent> '. menuRoot .'.Comment\ Nested<TAB>' . escape(g:NERDComLineNestMap, '\') . ' :call NERDComment(0, "nested")<CR>'
execute 'vmenu <silent> '. menuRoot .'.Comment\ Nested<TAB>' . escape(g:NERDComLineNestMap, '\') . ' <ESC>:call NERDComment(1, "nested")<CR>'
execute 'nmenu <silent> '. menuRoot .'.Comment\ To\ EOL<TAB>' . escape(g:NERDComToEOLMap, '\') . ' :call NERDComment(0, "toEOL")<cr>'
execute 'nmenu <silent> '. menuRoot .'.Comment\ Invert<TAB>' . escape(g:NERDComLineInvertMap, '\') . ' :call NERDComment(0,"invert")<CR>'
execute 'vmenu <silent> '. menuRoot .'.Comment\ Invert<TAB>' . escape(g:NERDComLineInvertMap, '\') . ' <ESC>:call NERDComment(1,"invert")<CR>'
execute 'nmenu <silent> '. menuRoot .'.Comment\ Sexily<TAB>' . escape(g:NERDComLineSexyMap, '\') . ' :call NERDComment(0,"sexy")<CR>'
execute 'vmenu <silent> '. menuRoot .'.Comment\ Sexily<TAB>' . escape(g:NERDComLineSexyMap, '\') . ' <ESC>:call NERDComment(1,"sexy")<CR>'
execute 'nmenu <silent> '. menuRoot .'.Yank\ line(s)\ then\ comment<TAB>' . escape(g:NERDComLineYankMap, '\') . ' "0Y' . g:NERDComLineMap
execute 'vmenu <silent> '. menuRoot .'.Yank\ line(s)\ then\ comment<TAB>' . escape(g:NERDComLineYankMap, '\') . ' "0ygv' . g:NERDComLineMap
execute 'nmenu <silent> '. menuRoot .'.Append\ Comment\ to\ Line<TAB>' . escape(g:NERDAppendComMap, '\') . ' :call NERDComment(0, "append")<cr>'
execute 'nmenu <silent> '. menuRoot .'.Prepend\ Comment\ to\ Line<TAB>' . escape(g:NERDPrependComMap, '\') . ' :call NERDComment(0, "prepend")<cr>'
execute 'menu <silent> '. menuRoot .'.-Sep- :'
execute 'nmenu <silent> '. menuRoot .'.Comment\ Align\ Left\ (nested)<TAB>' . escape(g:NERDComAlignLeftMap, '\') . ' :call NERDComment(0, "alignLeft")<CR>'
execute 'vmenu <silent> '. menuRoot .'.Comment\ Align\ Left\ (nested)<TAB>' . escape(g:NERDComAlignLeftMap, '\') . ' <ESC>:call NERDComment(1, "alignLeft")<CR>'
execute 'nmenu <silent> '. menuRoot .'.Comment\ Align\ Right\ (nested)<TAB>' . escape(g:NERDComAlignRightMap, '\') . ' :call NERDComment(0, "alignRight")<CR>'
execute 'vmenu <silent> '. menuRoot .'.Comment\ Align\ Right\ (nested)<TAB>' . escape(g:NERDComAlignRightMap, '\') . ' <ESC>:call NERDComment(1, "alignRight")<CR>'
execute 'nmenu <silent> '. menuRoot .'.Comment\ Align\ Both\ (nested)<TAB>' . escape(g:NERDComAlignBothMap, '\') . ' :call NERDComment(0, "alignBoth")<CR>'
execute 'vmenu <silent> '. menuRoot .'.Comment\ Align\ Both\ (nested)<TAB>' . escape(g:NERDComAlignBothMap, '\') . ' <ESC>:call NERDComment(1, "alignBoth")<CR>'
execute 'menu <silent> '. menuRoot .'.-Sep2- :'
execute 'menu <silent> '. menuRoot .'.Uncomment<TAB>' . escape(g:NERDUncomLineMap, '\') . ' :call NERDComment(0, "uncomment")<cr>'
execute 'vmenu <silent>' . menuRoot.'.Uncomment<TAB>' . escape(g:NERDUncomLineMap, '\') . ' <esc>:call NERDComment(1, "uncomment")<cr>'
execute 'menu <silent> '. menuRoot .'.-Sep3- :'
execute 'nmenu <silent> '. menuRoot .'.Use\ Alternative\ Delimiters<TAB>' . escape(g:NERDAltComMap, '\') . ' :call <SID>SwitchToAlternativeDelimiters(1)<CR>'
execute 'imenu <silent> '. menuRoot .'.Insert\ Delims<TAB>' . escape(g:NERDComInInsertMap, '\') . ' <SPACE><BS><ESC>:call NERDComment(0, "insert")<CR>'
execute 'menu '. menuRoot .'.-Sep4- :'
execute 'menu <silent>'. menuRoot .'.Help<TAB>:help\ NERDCommenterContents :help NERDCommenterContents<CR>'
function! s:CreateMenuItems(target, desc, root)
exec 'nmenu <silent> ' . a:root . '.' . a:desc . ' ' . a:target
exec 'vmenu <silent> ' . a:root . '.' . a:desc . ' ' . a:target
endfunction
call s:CreateMenuItems("<plug>NERDCommenterComment", 'Comment', menuRoot)
call s:CreateMenuItems("<plug>NERDCommenterToggle", 'Toggle', menuRoot)
call s:CreateMenuItems('<plug>NERDCommenterMinimal', 'Minimal', menuRoot)
call s:CreateMenuItems('<plug>NERDCommenterNest', 'Nested', menuRoot)
exec 'nmenu <silent> '. menuRoot .'.To\ EOL <plug>NERDCommenterToEOL'
call s:CreateMenuItems('<plug>NERDCommenterInvert', 'Invert', menuRoot)
call s:CreateMenuItems('<plug>NERDCommenterSexy', 'Sexy', menuRoot)
call s:CreateMenuItems('<plug>NERDCommenterYank', 'Yank\ then\ comment', menuRoot)
exec 'nmenu <silent> '. menuRoot .'.Append <plug>NERDCommenterAppend'
exec 'menu <silent> '. menuRoot .'.-Sep- :'
call s:CreateMenuItems('<plug>NERDCommenterAlignLeft', 'Left\ aligned', menuRoot)
call s:CreateMenuItems('<plug>NERDCommenterAlignBoth', 'Left\ and\ right\ aligned', menuRoot)
exec 'menu <silent> '. menuRoot .'.-Sep2- :'
call s:CreateMenuItems('<plug>NERDCommenterUncomment', 'Uncomment', menuRoot)
exec 'nmenu <silent> '. menuRoot .'.Switch\ Delimiters <plug>NERDCommenterAltDelims'
exec 'imenu <silent> '. menuRoot .'.Insert\ Comment\ Here <plug>NERDCommenterInInsert'
exec 'menu <silent> '. menuRoot .'.-Sep3- :'
exec 'menu <silent>'. menuRoot .'.Help :help NERDCommenterContents<CR>'
endif
" vim: set foldmethod=marker :