73 Commits
2.4.0 ... 2.5.2

Author SHA1 Message Date
fcying
9a32fd2534 Add NERDToggleCheckAllLines option to NERDCommenterToggle (#334) 2018-06-21 11:06:22 +03:00
Jiaobuzuji
e679d8a341 Add support for 'sdc' filetype (#327) 2018-03-03 15:16:47 +03:00
dandersson
670dba1bb5 Add support for Robot Framework files (#323) 2018-02-07 12:19:12 +03:00
Sean
2f973bd4fa Fix Markdown formatting 2018-02-02 12:56:54 +03:00
tlsvc
ff3d8d7d7c Add support for ANSYS Parametric Design Language (apdl) (#317) 2018-01-13 11:47:04 +03:00
Alec Shaw
af8bb4258d Add support for Praat scripting language (#316)
[Praat][1] is a program for phonetics research which has a scripting interface.

[1]: http://www.fon.hum.uva.nl/praat/
2017-12-26 11:02:19 +03:00
Caleb Maclennan
fd61bc71f6 Udate version and date strings 2017-11-07 10:46:22 +03:00
Caleb Maclennan
3e99b39f4f Add sshconfig filetype to complement sshdconfig
Mentioned in #313
2017-11-07 10:38:04 +03:00
Caleb Maclennan
09b07d50ba Merge branch 'pr/266'
Closes #266
2017-11-07 10:17:06 +03:00
Caleb Maclennan
013cfec44d Merge branch 'pr/279'
Closes #279

Since original author of this PR has deleted their Github account
I squashed their two commits and added one to fix the issue with the
implementation as noted in the PR.
2017-11-07 10:12:51 +03:00
Caleb Maclennan
d4548ebb0c Fix implementation of renpy to not include python hack 2017-11-07 10:12:00 +03:00
Komeji Koishi
c321b3460b Added filetype 'renpy' support.
Renpy is an extension of python syntax and it uses '#' comments.
2017-11-07 10:11:59 +03:00
Carlos Eduardo de Andrade
63ba1a1123 Adding support to MiniZinc constraint modeling language. (#311) 2017-10-31 18:53:26 +02:00
Ratan
376838672d Add julia multiline comment chars (#312) 2017-10-31 18:52:28 +02:00
Caleb Maclennan
285902752f Cleanup code formatting in file support matrix 2017-04-07 11:53:35 +03:00
m-pilia
d1ac2382b2 add gl shaders language (#293) 2017-04-06 13:59:25 +03:00
Lyude
a6b3cc6842 Add support for piglit's shader_test files (#292)
This adds support for shader_test files in piglit, the open source
test suite for OpenGL implementations such as mesa. More information on
piglit can be found at:

https://piglit.freedesktop.org/
2017-03-25 13:19:06 +02:00
Caleb Maclennan
d05cfd190b Revert "add support for react/jsx comments (Closes #280) (#290)"
This reverts commit 0e1f6f6866.

Given the unexpected behaviour of this and disruption to people's
established work flows, I'm reverting this until a better solution can
be found that only handles the special comment format inside React code
blocks.
2017-03-15 13:18:09 +03:00
Lucas Charles
0e1f6f6866 add support for react/jsx comments (Closes #280) (#290) 2017-03-12 09:08:58 +02:00
Dylan Baker
41e686824a Add support for the meson build system. (#289) 2017-02-28 08:04:50 +02:00
Zack Youngren
59552f2e88 Add multi-line comments for Elm (#283)
Technically the minimum necessary syntax for block comments requires
only a single hyphen (`-}`, `{-`), but I have found that using a double
hyphen plays a bit more nicely with the elmcast/elm-vim auto-formatting.
Further, uncommenting when using the single dashes leaves an extra level
of indentation (again, when using elmcast/elm-vim).
2017-02-20 09:08:14 +02:00
Alexandr
c5f8cbf70d Fix removing space when uncommenting spaced AltDelims multipart comment (#286) 2017-02-20 09:03:41 +02:00
alejandrogallo
607253203d Add gitignore support (#284) 2017-01-22 08:05:45 +02:00
Chuck Wilson
18cfe81550 Add support for augeas file types (#277) 2016-12-15 10:06:26 +02:00
Chris Linstid
057f6150bd Add ansible file type (#276) 2016-11-17 07:01:25 +02:00
Jorge Marin
ecdde217c0 Remove trailing whitespace for top and bottom line (#269)
Fixes #268

Remove trailing whitespace for top and bottom line when uncommenting a sexy commented block.
2016-11-15 17:20:51 +02:00
Alejandro Gallo
e1af5dae7d Add support for molpro and vasp chemistry packages
Closes #275
2016-11-15 18:15:54 +03:00
Roland Hieber
97cb982f1f add support for M4 macro processor (#271)
M4 knows about two types of ignoring text.  But the concept which the
GNU M4 manual refers to as "comments" [0] (i.e., lines prefixed with
hash signs) is actually telling the interpreter "ignore this text, but
pass it to the output".  Most of the time, people don't want the macro
comments in their output, so instead the `dnl` ("discard to next line")
macro [1] is usually used for comments in the document-my-thoughts
sense.

[0]: https://www.gnu.org/software/m4/manual/m4.html#Comments
[1]: https://www.gnu.org/software/m4/manual/m4.html#Dnl
2016-10-10 17:24:21 +03:00
Caleb Maclennan
3d13266034 Add alternate delimiters for autohotkey (matching ahk)
Fixes #272
2016-10-10 17:21:01 +03:00
Aluriak
c51f5992b2 add support for turtle (.ttl) files 2016-09-10 01:20:29 +02:00
Caleb Maclennan
fdc611c8f4 Enable TrimTrailingWhitespace when commenting (#264)
Previously the `NERDTrimTrailingWhitespace` option was only evaluated when uncommenting a line. However sometimes trailing whitespace was being added when commenting, notably when commenting empty lines. This checks for and removes such space at comment time.
2016-08-31 11:42:37 +03:00
kaidiren
45689b2356 can enable TrimTrailingWhitespace when comment 2016-08-31 14:32:26 +08:00
Wael M. Nasreddine
c3d6a2069b README.md: fix vim-plug installation instructions (#254) 2016-07-14 13:13:26 +03:00
Keunchan Park
ec0f4753d0 Add hive filetype (#255) 2016-07-14 13:12:25 +03:00
Alexandre Constantino
e2d47bec26 Add option to allow deleting trailing whitespace (#251)
Add option g:NERDTrimTrailingWhitespace to allow deleting trailing
whitespace when uncommenting a line.
2016-06-10 17:49:17 +03:00
Alexandre Constantino
e1aeec12be Allow commenting empty lines given configuration (#250)
* Allow commenting empty lines given configuration

    If g:NERDCommentEmptyLines=1 then it will comment empty line, which is
    useful when commenting blocks.

    When uncommenting it will delete any trailing whitespace.

* Add documentation for NERDCommentEmptyLines
2016-06-08 17:00:05 +03:00
Caleb Maclennan
06c3184b2e Merge pull request #249 from xream/master
Add hook functions for NERDComment and SwitchToAlternativeDelimiters
2016-05-31 17:59:10 +03:00
Hsiaoyi Hsu
ce414bf622 Add filetype pug. Jade has been renamed to pug. 2016-05-31 22:30:37 +08:00
Hsiaoyi Hsu
dde288a9cc Add doc for NERDComHooks and fix doc of NERDComSexyComments and NERDComNERDComment 2016-05-31 22:27:10 +08:00
Hsiaoyi Hsu
7f07dcde28 Add hook functions for NERDComment and SwitchToAlternativeDelimiters 2016-05-31 14:28:56 +08:00
Caleb Maclennan
63bd306a7e Sort file type list alphabetically 2016-05-27 09:04:44 +03:00
Lucas Bourneuf
df647acefc fix asp support (doublon) 2016-05-27 08:59:05 +03:00
ARM9
e48cc752f3 Fix rust Alt comments (#248) 2016-05-26 17:25:29 +03:00
Alexander Alzate
4760e57514 Start Insertion in Append Mode When no Right Delim (#234) 2016-05-26 08:24:47 +03:00
dkim
c3afedbe22 Use getbufvar in an old-fashioned way for backward compatibility (#247)
getbufvar accepts only two arguments in Vim 7.3 (at least the one
included in OS X 10.11.5), and returns an empty string when the buffer
or variable does not exist: getbufvar({buffer}, {variable}).

Vim 7.4 has extended the built-in function so that it additionally
accepts an optional argument which determines the default return value:
getbufvar({buffer}, {variable}, [, {default}]). When the third argument
is not given and the buffer or variable does not exists, getbufvar
returns an empty string as before.

getbufvar({buffer}, {variable}) works in both Vim 7.3 and 7.4, and is
practically equivalent to getbufvar({buffer}, {variable}, 0) because an
empty string is coerced to 0 if necessary.
2016-05-25 23:17:10 +03:00
Caleb Maclennan
e91be123f0 Simplify and document the config key for toggling language defaults
Closes #33
2016-05-24 20:55:37 +03:00
Caleb Maclennan
8291af4c7c Merge pull request #155 from saep/master
Implement functionality to chose the alternative comment style
2016-05-24 20:50:59 +03:00
Caleb Maclennan
6af02e1442 Fix powershell blooper 2016-05-24 20:22:04 +03:00
Caleb Maclennan
9425289459 Add common settings and overhaul README formatting, esp. bindings section 2016-05-24 20:14:10 +03:00
Caleb Maclennan
9e8410e1b9 Overhaul installation instructions
See discussion in #241
2016-05-24 19:50:50 +03:00
Caleb Maclennan
d59f0b614f Merge pull request #241 from zwhitchcox/master
alternative pathogen download instructions
2016-05-24 19:09:56 +03:00
zane.hitchcox@one.verizon.com
1158546091 include entire repository in manual install 2016-05-24 11:09:20 -05:00
Zane Hitchcox
0cbbcb5674 alternative pathogen download instructions 2016-05-24 10:41:58 -05:00
Caleb Maclennan
ff0b875c8d Add alt delimiter to R filetype for Roxygen strings 2016-05-24 18:02:14 +03:00
Caleb Maclennan
e0c4a25696 Merge pull request #246 from stevenweaver/master
adding hyphy filetype
2016-05-24 17:42:48 +03:00
Caleb Maclennan
00e9729661 Add multiline delimiter support to ASY file type 2016-05-24 17:36:01 +03:00
Caleb Maclennan
1d07874610 Add ASP filetype support 2016-05-24 17:35:14 +03:00
Caleb Maclennan
560d7f0f77 Merge pull request #245 from hightemp/master
Add ruby multiline comment tags
2016-05-24 17:09:28 +03:00
Caleb Maclennan
0a186faad1 Merge pull request #244 from svermeulen/working
Add file format and function for identifying commented lines from outside plugin
2016-05-24 17:04:55 +03:00
Caleb Maclennan
32cd2b9362 Merge pull request #243 from sailorfeng/master
Add lpc filetype support
2016-05-24 16:57:44 +03:00
Caleb Maclennan
821fa9ad9e Merge pull request #242 from lanjiann/master
Pull in documentation updates from old fork (found in network graph)
2016-05-24 16:56:03 +03:00
Caleb Maclennan
264be25aa1 Use full English names when explaining functions 2016-05-24 16:24:20 +03:00
Caleb Maclennan
ec802fe1d3 Merge pull request #151 from klaasb/realnesting
Support automatic real nesting of comments without placeholders, if supported by the language.
2016-05-24 16:17:09 +03:00
Klaas Boesche
c2fc065b33 Automatic real nesting for languages with support
Removes the placeholder workaround (forceNested) for languages which
allow truly nested comments and automatically applies them.
Enabled for haskell, racket, scheme, scala, lisp, ocaml, sml.
Fixes issue #131
2016-05-24 13:52:21 +02:00
Steven Weaver
60bd8664ba adding hyphy filetype 2016-04-19 15:51:07 -04:00
Sebastian Witte
d4f41d2697 Use state variable to determine whether the alternate delimiters have already been switched 2015-01-14 18:14:08 +01:00
Sebastian Witte
59c79279b5 Implement functionality to configure alternate comment style (fixes #145)
The change requires the variable to have global scope which is also updated in
the documentation.
2014-09-30 12:04:12 +02:00
Anton Panov
1b62184305 Add ruby multiline comment tags 2014-07-30 01:54:34 +04:00
svermeulen
f1a23cde6d Fix for teak 2014-06-16 16:11:42 -03:00
Jian Lan
785386db76 Update NERD_commenter.txt
Add one empty line between every two items. Add a period at the end of a sentence:(regardless of whether NERDSpaceDelims is set)
2013-10-17 03:22:44 -06:00
Jian Lan
8c73eef0ea Update NERD_commenter.txt
Delete the excess the in "If the a selected line is commented then it is uncommented and vice versa. "
2013-10-17 02:52:26 -06:00
sailorfeng
289d2d64ec Update NERD_commenter.vim
add lpc support
2013-09-11 17:40:50 +08:00
svermeulen
fbe3bd3c35 Exposed function to check whether a line is commented 2013-05-25 15:31:00 -03:00
3 changed files with 468 additions and 140 deletions

176
README.md
View File

@@ -1,95 +1,159 @@
# Installation
# NERD Commenter
_\*For simplicity, let's use **[VIM_ROOT]** which will mean ~/.vim (\*nix) or ~/vimfiles (Windows)_
Comment functions so powerful—no comment necessary.
The NERD Commenter requires Vim 7 or higher is comprised of 2 files:
## Installation
plugin/NERD_commenter.vim
doc/NERD_commenter.txt
### Via Plugin Manager (Recommended)
### Classic Install
#### [Vim-Plug](https://github.com/junegunn/vim-plug)
1. Extract the plugin files into your **[VIM_ROOT]**/plugin and **[VIM_ROOT]**/doc folders respectively.
2. Finish the install by updating your help files. Run:
1. Add `Plug 'scrooloose/nerdcommenter'` to your vimrc file.
2. Reload your vimrc or restart
3. Run `:PlugInstall`
<pre><code>:helptags [VIM_ROOT]/doc</code></pre>
#### [Vundle](https://github.com/VundleVim/Vundle.vim) or similar
See **|add-local-help|** for more details.
1. Add `Plugin 'scrooloose/nerdcommenter'` to your vimrc file.
2. Reload your vimrc or restart
3. Run `:BundleInstall`
### Pathogen Install
1. Navigate to your **[VIM_ROOT]/bundle** directory in your local Vim setup
2. `git clone https://github.com/scrooloose/nerdcommenter.git`
#### [NeoBundle](https://github.com/Shougo/neobundle.vim)
### Vundle Install
1. Add `Plugin 'scrooloose/nerdcommenter'` to your .vimrc file.
2. Run `:BundleInstall`
1. Add `NeoBundle 'scrooloose/nerdcommenter'` to your vimrc file.
2. Reload your vimrc or restart
3. Run `:NeoUpdate`
### Post Install
After the **'Classic'** or **'Pathogen'** install, make sure that you have filetype plugins enabled, as the script makes use of
**|'commentstring'|** where possible (which is usually set in a filetype plugin).
See **|filetype-plugin-on|** for details, but basically, stick this in your vimrc:
#### [Pathogen](https://github.com/tpope/vim-pathogen)
filetype plugin on
```sh
cd ~/.vim/bundle
git clone https://github.com/scrooloose/nerdcommenter.git
```
# Usage
### Manual Installation
The following key mappings are provided by default (there is also a menu
provided that contains menu items corresponding to all the below mappings):
#### Unix
Most of the following mappings are for normal/visual mode only. The |NERDComInsertComment| mapping is for insert mode only.
(For Neovim, change `~/.vim/` to `~/.config/nvim/`.)
**[count]\<leader\>cc |NERDComComment|**
Comment out the current line or text selected in visual mode.
```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)
**[count]\<leader\>cn |NERDComNestedComment|**
Same as \<leader\>cc but forces nesting.
```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
**[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.
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
```
**[count]\<leader\>cm |NERDComMinimalComment|**
Comments the given lines using only one set of multipart delimiters.
## Usage
### Documentation
**[count]\<leader\>ci |NERDComInvertComment|**
Toggles the comment state of the selected line(s) individually.
Please see the vim help system for full documentation of all options: `:help nerdcommenter`
### Settings
**[count]\<leader\>cs |NERDComSexyComment|**
Comments out the selected lines ``sexily''
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
**[count]\<leader\>cy |NERDComYankComment|**
Same as \<leader\>cc except that the commented line(s) are yanked first.
" 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'
**\<leader\>c$ |NERDComEOLComment|**
Comments the current line from the cursor to the end of line.
" 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': '*/' } }
**\<leader\>cA |NERDComAppendComment|**
Adds comment delimiters to the end of line and goes into insert mode between
them.
" 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
**|NERDComInsertComment|**
Adds comment delimiters at the current cursor position and inserts between.
Disabled by default.
" Enable NERDCommenterToggle to check all selected lines is commented or not
let g:NERDToggleCheckAllLines = 1
```
### Default mappings
**\<leader\>ca |NERDComAltDelim|**
Switches to the alternative set of delimiters.
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\>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>cc` **|NERDComComment|**
Comment out the current line or text selected in visual mode.
**[count]\<leader\>cu |NERDComUncommentLine|**
Uncomments the selected line(s).
* `[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,8 +28,9 @@ CONTENTS *NERDCommenterContents*
3.2.11 Use alternate delims map...|NERDComAltDelim|
3.2.12 Comment aligned maps.......|NERDComAlignedComment|
3.2.13 Uncomment line map.........|NERDComUncommentLine|
3.4 Sexy Comments.....................|NERDComSexyComments|
3.5 The NERDComment function..........|NERDComNERDComment|
3.3 Sexy Comments.....................|NERDComSexyComments|
3.4 The NERDComment function..........|NERDComNERDComment|
3.5 The Hooks.........................|NERDComHooks|
4.Options.................................|NERDComOptions|
4.1 Options summary...................|NERDComOptionsSummary|
4.2 Options details...................|NERDComOptionsDetails|
@@ -391,6 +392,35 @@ For example, if you typed >
<
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*
@@ -399,44 +429,68 @@ then the script would do a sexy comment on the last visual selection.
4.1 Options summary *NERDComOptionsSummary*
|'loaded_nerd_comments'| Turns off the script.
|'NERDAllowAnyVisualDelims'| Allows multipart alternative delimiters
to be used when commenting in
visual/visual-block mode.
|'NERDBlockComIgnoreEmpty'| Forces right delimiters to be placed
when doing visual-block comments.
|'NERDCommentEmptyLines'| Specifies if empty lines should be
commented (useful with regions).
|'NERDCommentWholeLinesInVMode'| Changes behaviour of visual comments.
|'NERDCreateDefaultMappings'| Turn the default mappings on/off.
|'NERDCustomDelimiters'| Add or override delimiters for any
filetypes.
|'NERDDefaultNesting'| Tells the script to use nested comments
by default.
|'NERDMenuMode'| Specifies how the NERD commenter menu
will appear (if at all).
|'NERDLPlace'| Specifies what to use as the left
delimiter placeholder when nesting
comments.
|'NERDUsePlaceHolders'| Specifies which filetypes may use
placeholders when nesting comments.
|'NERDRemoveAltComs'| Tells the script whether to remove
alternative comment delimiters when
uncommenting.
|'NERDRemoveExtraSpaces'| Tells the script to always remove the
extra spaces when uncommenting
(regardless of whether NERDSpaceDelims
is set)
is set).
|'NERDRPlace'| Specifies what to use as the right
delimiter placeholder when nesting
comments.
|'NERDSpaceDelims'| Specifies whether to add extra spaces
around delimiters when commenting, and
whether to remove them when
uncommenting.
|'NERDTrimTrailingWhitespace'| Specifies if trailing whitespace
should be deleted when uncommenting.
|'NERDCompactSexyComs'| Specifies whether to use the compact
style sexy comments.
|'NERDDefaultAlign'| Specifies the default alignment to use,
one of 'none', 'left', 'start', or
'both'.
|'NERDToggleCheckAllLines'| Enable NERDCommenterToggle to check
all selected lines is commented or not.
------------------------------------------------------------------------------
4.3 Options details *NERDComOptionsDetails*
@@ -514,6 +568,15 @@ 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'*
Values: 0, 1 or 2.
@@ -692,6 +755,15 @@ If you want spaces to be added then set NERDSpaceDelims to 1 in your vimrc.
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'
@@ -731,16 +803,25 @@ 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
again.
------------------------------------------------------------------------------
*'NERDToggleCheckAllLines'*
Values: 0 or 1.
Default 0.
When this option is set to 1, NERDCommenterToggle will check all selected line,
if there have oneline not be commented, then comment all lines.
------------------------------------------------------------------------------
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 g:NERDAltDelims_<filetype> = 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: >
let NERD_java_alt_style=1
let g:NERDAltDelims_java = 1
<
See |NERDComAltDelim| for switching commenting styles at runtime.
@@ -1024,6 +1105,7 @@ Simon Hengel htmlcheetah
Matt Tolton javacc
Ivan Devat javascript.jquery
tpope cucumber,pdf
Lyude Paul piglit shader_test
==============================================================================
10. License *NERDComLicense*

View File

@@ -3,8 +3,8 @@
" Description: vim global plugin that provides easy code commenting
" Author: Martin Grenfell <martin.grenfell at gmail dot com>
" Maintainer: Caleb Maclennan <caleb@alerque.com>
" Version: 2.4.0
" Last Change: Tue May 24 14:03:29 EEST 2016
" Version: 2.5.1
" Last Change: Tue Nov 7 10:45:53 +03 2017
" 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
@@ -64,6 +64,8 @@ call s:InitVariable("g:NERDRemoveExtraSpaces", 0)
call s:InitVariable("g:NERDRPlace", "<]")
call s:InitVariable("g:NERDSpaceDelims", 0)
call s:InitVariable("g:NERDDefaultAlign", "none")
call s:InitVariable("g:NERDTrimTrailingWhitespace", 0)
call s:InitVariable("g:NERDToggleCheckAllLines", 0)
let s:NERDFileNameEscape="[]#*$%'\" ?`!&();<>\\"
@@ -78,19 +80,23 @@ let s:delimiterMap = {
\ 'amiga': { 'left': ';' },
\ 'aml': { 'left': '/*' },
\ 'ampl': { 'left': '#' },
\ 'ansible': { 'left': '#' },
\ 'apache': { 'left': '#' },
\ 'apachestyle': { 'left': '#' },
\ 'asciidoc': { 'left': '//' },
\ 'apdl': { 'left': '!' },
\ 'applescript': { 'left': '--', 'leftAlt': '(*', 'rightAlt': '*)' },
\ 'armasm': { 'left': ';' },
\ 'asm68k': { 'left': ';' },
\ 'asciidoc': { 'left': '//' },
\ 'asm': { 'left': ';', 'leftAlt': '#' },
\ 'asm68k': { 'left': ';' },
\ 'asn': { 'left': '--' },
\ 'asp': { 'left': '%', 'leftAlt': '%*', 'rightAlt': '*%' },
\ 'aspvbs': { 'left': '''', 'leftAlt': '<!--', 'rightAlt': '-->' },
\ 'asterisk': { 'left': ';' },
\ 'asy': { 'left': '//' },
\ 'asy': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'atlas': { 'left': 'C', 'right': '$' },
\ 'autohotkey': { 'left': ';' },
\ 'augeas': { 'left': '(*', 'right': '*)' },
\ 'autohotkey': { 'left': ';', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'autoit': { 'left': ';' },
\ 'ave': { 'left': "'" },
\ 'awk': { 'left': '#' },
@@ -102,11 +108,11 @@ let s:delimiterMap = {
\ 'blade': { 'left': '{{--', 'right': '--}}' },
\ 'bst': { 'left': '%' },
\ 'btm': { 'left': '::' },
\ 'c': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
\ 'cabal': { 'left': '--' },
\ 'caos': { 'left': '*' },
\ 'calibre': { 'left': '//' },
\ 'caos': { 'left': '*' },
\ 'catalog': { 'left': '--', 'right': '--' },
\ 'c': { 'left': '/*','right': '*/', 'leftAlt': '//' },
\ 'cf': { 'left': '<!---', 'right': '--->' },
\ 'cfg': { 'left': '#' },
\ 'cg': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
@@ -121,26 +127,26 @@ let s:delimiterMap = {
\ 'context': { 'left': '%', 'leftAlt': '--' },
\ 'coq': { 'left': '(*', 'right': '*)' },
\ 'cpp': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'cuda': { 'left': '/*','right': '*/', 'leftAlt': '//' },
\ 'crontab': { 'left': '#' },
\ 'cs': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'csp': { 'left': '--' },
\ 'cterm': { 'left': '*' },
\ 'cucumber': { 'left': '#' },
\ 'cython': { 'left': '# ', 'leftAlt': '#' },
\ 'cuda': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
\ 'cvs': { 'left': 'CVS:' },
\ 'cython': { 'left': '# ', 'leftAlt': '#' },
\ 'd': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'dcl': { 'left': '$!' },
\ 'dakota': { 'left': '#' },
\ 'dcl': { 'left': '$!' },
\ 'debcontrol': { 'left': '#' },
\ 'debsources': { 'left': '#' },
\ 'def': { 'left': ';' },
\ 'desktop': { 'left': '#' },
\ 'dhcpd': { 'left': '#' },
\ 'diff': { 'left': '#' },
\ 'django': { 'left': '<!--','right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' },
\ 'docbk': { 'left': '<!--', 'right': '-->' },
\ 'django': { 'left': '<!--', 'right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' },
\ 'dns': { 'left': ';' },
\ 'docbk': { 'left': '<!--', 'right': '-->' },
\ 'dockerfile': { 'left': '#' },
\ 'dosbatch': { 'left': 'REM ', 'leftAlt': '::' },
\ 'dosini': { 'left': ';' },
@@ -155,7 +161,7 @@ let s:delimiterMap = {
\ 'eiffel': { 'left': '--' },
\ 'elf': { 'left': "'" },
\ 'elixir': { 'left': '#' },
\ 'elm': { 'left': '--' },
\ 'elm': { 'left': '--', 'leftAlt': '{--', 'rightAlt': '--}' },
\ 'elmfilt': { 'left': '#' },
\ 'ember-script': { 'left': '#' },
\ 'emblem': { 'left': '/' },
@@ -164,8 +170,8 @@ let s:delimiterMap = {
\ 'esmtprc': { 'left': '#' },
\ 'expect': { 'left': '#' },
\ 'exports': { 'left': '#' },
\ 'fancy': { 'left': '#' },
\ 'factor': { 'left': '! ', 'leftAlt': '!# ' },
\ 'fancy': { 'left': '#' },
\ 'fgl': { 'left': '#' },
\ 'focexec': { 'left': '-*' },
\ 'form': { 'left': '*' },
@@ -179,7 +185,7 @@ let s:delimiterMap = {
\ 'gdb': { 'left': '#' },
\ 'gdmo': { 'left': '--' },
\ 'geek': { 'left': 'GEEK_COMMENT:' },
\ 'genshi': { 'left': '<!--','right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' },
\ 'genshi': { 'left': '<!--', 'right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' },
\ 'gentoo-conf-d': { 'left': '#' },
\ 'gentoo-env-d': { 'left': '#' },
\ 'gentoo-init-d': { 'left': '#' },
@@ -189,31 +195,36 @@ let s:delimiterMap = {
\ 'gentoo-package-use': { 'left': '#' },
\ 'gitcommit': { 'left': '#' },
\ 'gitconfig': { 'left': ';' },
\ 'gitignore': { 'left': '#' },
\ 'gitrebase': { 'left': '#' },
\ 'glsl': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'gnuplot': { 'left': '#' },
\ 'go': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'groovy': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'gsp': { 'left': '<%--', 'right': '--%>', 'leftAlt': '<!--','rightAlt': '-->'},
\ 'gsp': { 'left': '<%--', 'right': '--%>', 'leftAlt': '<!--', 'rightAlt': '-->' },
\ 'gtkrc': { 'left': '#' },
\ 'haskell': { 'left': '{-','right': '-}', 'leftAlt': '--' },
\ 'hb': { 'left': '#' },
\ 'h': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'haml': { 'left': '-#', 'leftAlt': '/' },
\ 'haxe': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'handlebars': { 'left': '{{!-- ', 'right': ' --}}' },
\ 'haskell': { 'left': '{-', 'right': '-}', 'nested': 1, 'leftAlt': '--', 'nestedAlt': 1 },
\ 'haxe': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'hb': { 'left': '#' },
\ 'hbs': { 'left': '{{!-- ', 'right': ' --}}' },
\ 'hercules': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'hive': { 'left': '-- ' },
\ 'hog': { 'left': '#' },
\ 'hostsaccess': { 'left': '#' },
\ 'htmlcheetah': { 'left': '##' },
\ 'htmldjango': { 'left': '<!--','right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' },
\ 'htmldjango': { 'left': '<!--', 'right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' },
\ 'htmlos': { 'left': '#', 'right': '/#' },
\ 'hxml': { 'left': '#' },
\ 'hyphy': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'ia64': { 'left': '#' },
\ 'icon': { 'left': '#' },
\ 'idlang': { 'left': ';' },
\ 'idl': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'idlang': { 'left': ';' },
\ 'idris': { 'leftAlt': '--', 'left': '{-', 'right': '-}' },
\ 'incar': { 'left': '!' },
\ 'inform': { 'left': '!' },
\ 'inittab': { 'left': '#' },
\ 'ishd': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
@@ -226,30 +237,32 @@ let s:delimiterMap = {
\ 'javascript.jquery': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'jess': { 'left': ';' },
\ 'jgraph': { 'left': '(*', 'right': '*)' },
\ 'jinja': { 'left': '<!--','right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' },
\ 'jinja': { 'left': '<!--', 'right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' },
\ 'jproperties': { 'left': '#' },
\ 'jsp': { 'left': '<%--', 'right': '--%>' },
\ 'julia': { 'left': '#' },
\ 'julia': { 'left': '# ', 'leftAlt': '#=', 'rightAlt': '=#' },
\ 'kix': { 'left': ';' },
\ 'kscript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'lace': { 'left': '--' },
\ 'laravel': { 'left': '{{--', 'right': '--}}' },
\ 'laravel': { 'left': '{{--', 'right': '--}}' },
\ 'ldif': { 'left': '#' },
\ 'less': { 'left': '/*','right': '*/' },
\ 'lhaskell': { 'left': '>{-','right': '-}', 'leftAlt': '>-- ' },
\ 'less': { 'left': '/*', 'right': '*/' },
\ 'lhaskell': { 'left': '>{-', 'right': '-}', 'leftAlt': '>-- ' },
\ 'lilo': { 'left': '#' },
\ 'lilypond': { 'left': '%' },
\ 'liquid': { 'left': '{% comment %}', 'right': '{% endcomment %}' },
\ 'lisp': { 'left': ';', 'leftAlt': '#|', 'rightAlt': '|#' },
\ 'lisp': { 'left': ';', 'nested': 1, 'leftAlt': '#|', 'rightAlt': '|#', 'nestedAlt': 1 },
\ 'llvm': { 'left': ';' },
\ 'lotos': { 'left': '(*', 'right': '*)' },
\ 'lout': { 'left': '#' },
\ 'lpc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'lprolog': { 'left': '%' },
\ 'lscript': { 'left': "'" },
\ 'lss': { 'left': '#' },
\ 'lua': { 'left': '--', 'leftAlt': '--[[', 'rightAlt': ']]' },
\ 'lynx': { 'left': '#' },
\ 'lytex': { 'left': '%' },
\ 'm4': { 'left': 'dnl ' },
\ 'mail': { 'left': '> ' },
\ 'mako': { 'left': '##' },
\ 'man': { 'left': '."' },
@@ -261,15 +274,18 @@ let s:delimiterMap = {
\ 'master': { 'left': '$' },
\ 'matlab': { 'left': '%', 'leftAlt': '%{', 'rightAlt': '%}' },
\ 'mel': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'meson': { 'left': '#' },
\ 'mib': { 'left': '--' },
\ 'mips': { 'left': '#'},
\ 'mirah': {'left': '#'},
\ 'minizinc': { 'left': '% ', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'mips': { 'left': '#' },
\ 'mirah': {'left': '#' },
\ 'mkd': { 'left': '<!---', 'right': '-->' },
\ 'mma': { 'left': '(*', 'right': '*)' },
\ 'model': { 'left': '$', 'right': '$' },
\ 'moduala.': { 'left': '(*', 'right': '*)' },
\ 'modula2': { 'left': '(*', 'right': '*)' },
\ 'modula3': { 'left': '(*', 'right': '*)' },
\ 'molpro': { 'left': '!' },
\ 'monk': { 'left': ';' },
\ 'mush': { 'left': '#' },
\ 'mustache': { 'left': '{{!', 'right': '}}' },
@@ -288,7 +304,7 @@ let s:delimiterMap = {
\ 'objc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'objcpp': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'objj': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'ocaml': { 'left': '(*', 'right': '*)' },
\ 'ocaml': { 'left': '(*', 'right': '*)', 'nested': 1 },
\ 'occam': { 'left': '--' },
\ 'octave': { 'left': '%', 'leftAlt': '#' },
\ 'omlet': { 'left': '(*', 'right': '*)' },
@@ -300,7 +316,7 @@ let s:delimiterMap = {
\ 'ox': { 'left': '//' },
\ 'paludis-use-conf': { 'left': '#' },
\ 'pandoc': { 'left': '<!--', 'right': '-->' },
\ 'pascal': { 'left': '{','right': '}', 'leftAlt': '(*', 'rightAlt': '*)' },
\ 'pascal': { 'left': '{', 'right': '}', 'leftAlt': '(*', 'rightAlt': '*)' },
\ 'patran': { 'left': '$', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'pcap': { 'left': '#' },
\ 'pccts': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
@@ -315,50 +331,57 @@ let s:delimiterMap = {
\ 'plm': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'plsql': { 'left': '-- ', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'po': { 'left': '#' },
\ 'poscar': { 'left': '!' },
\ 'postscr': { 'left': '%' },
\ 'pov': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'povini': { 'left': ';' },
\ 'ppd': { 'left': '%' },
\ 'ppwiz': { 'left': ';;' },
\ 'praat': { 'left': '#' },
\ 'privoxy': { 'left': '#' },
\ 'processing': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'prolog': { 'left': '%', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'ps1': { 'left': '#' },
\ 'psf': { 'left': '#' },
\ 'ptcap': { 'left': '#' },
\ 'pug': { 'left': '//-', 'leftAlt': '//' },
\ 'puppet': { 'left': '#' },
\ 'pyrex': { 'left': '# ', 'leftAlt': '#' },
\ 'python': { 'left': '# ', 'leftAlt': '#' },
\ 'racket': { 'left': ';', 'leftAlt': '#|', 'rightAlt': '|#' },
\ 'r': { 'left': '#', 'leftAlt': '#''' },
\ 'racket': { 'left': ';', 'nested': 1, 'leftAlt': '#|', 'rightAlt': '|#', 'nestedAlt': 1 },
\ 'radiance': { 'left': '#' },
\ 'ratpoison': { 'left': '#' },
\ 'r': { 'left': '#' },
\ 'rc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'rebol': { 'left': ';' },
\ 'registry': { 'left': ';' },
\ 'remind': { 'left': '#' },
\ 'renpy': { 'left': '# ' },
\ 'resolv': { 'left': '#' },
\ 'rgb': { 'left': '!' },
\ 'rib': { 'left': '#' },
\ 'rmd': { 'left': '#' },
\ 'robot': { 'left': '#' },
\ 'robots': { 'left': '#' },
\ 'rspec': { 'left': '#' },
\ 'ruby': { 'left': '# ', 'leftAlt': '#' },
\ 'rust': { 'left': '//', 'leftAlt': '///', 'rightAlt': '///' },
\ 'ruby': { 'left': '#', 'leftAlt': '=begin', 'rightAlt': '=end' },
\ 'rust': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'sa': { 'left': '--' },
\ 'samba': { 'left': ';', 'leftAlt': '#' },
\ 'sass': { 'left': '//', 'leftAlt': '/*' },
\ 'sather': { 'left': '--' },
\ 'scala': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'scons': { 'left': '#' },
\ 'scheme': { 'left': ';', 'leftAlt': '#|', 'rightAlt': '|#' },
\ 'scala': { 'left': '//', 'nested': 1, 'leftAlt': '/*', 'rightAlt': '*/', 'nestedAlt': 1 },
\ 'scheme': { 'left': ';', 'nested': 1, 'leftAlt': '#|', 'rightAlt': '|#', 'nestedAlt': 1 },
\ 'scilab': { 'left': '//' },
\ 'scons': { 'left': '#' },
\ 'scsh': { 'left': ';' },
\ 'scss': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/'},
\ 'scss': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'sdc': { 'left': '#' },
\ 'sed': { 'left': '#' },
\ 'sgmldecl': { 'left': '--', 'right': '--' },
\ 'sgmllnx': { 'left': '<!--', 'right': '-->' },
\ 'sh': { 'left': '#' },
\ 'shader_test': { 'left': '#' },
\ 'sicad': { 'left': '*' },
\ 'sile': { 'left': '%' },
\ 'simula': { 'left': '%', 'leftAlt': '--' },
@@ -373,7 +396,7 @@ let s:delimiterMap = {
\ 'smarty': { 'left': '{*', 'right': '*}' },
\ 'smil': { 'left': '<!', 'right': '>' },
\ 'smith': { 'left': ';' },
\ 'sml': { 'left': '(*', 'right': '*)' },
\ 'sml': { 'left': '(*', 'right': '*)', 'nested': 1 },
\ 'snippets': { 'left': '#' },
\ 'snnsnet': { 'left': '#' },
\ 'snnspat': { 'left': '#' },
@@ -390,18 +413,20 @@ let s:delimiterMap = {
\ 'sqr': { 'left': '!' },
\ 'squid': { 'left': '#' },
\ 'ss': { 'left': ';', 'leftAlt': '#|', 'rightAlt': '|#' },
\ 'sshconfig': { 'left': '#' },
\ 'sshdconfig': { 'left': '#' },
\ 'st': { 'left': '"' },
\ 'stan': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'stp': { 'left': '/*','right': '*/', 'leftAlt': '//' },
\ 'swift': { 'left': '/*','right': '*/', 'leftAlt': '//' },
\ 'stp': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
\ 'supercollider': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'swift': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
\ 'systemverilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'tads': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'tags': { 'left': ';' },
\ 'tak': { 'left': '$' },
\ 'tasm': { 'left': ';' },
\ 'tcl': { 'left': '#' },
\ 'teak': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'terraform': { 'left': '#', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'tex': { 'left': '%' },
\ 'texinfo': { 'left': "@c " },
@@ -415,17 +440,19 @@ let s:delimiterMap = {
\ 'tsalt': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'tsscl': { 'left': '#' },
\ 'tssgm': { 'left': "comment = '", 'right': "'" },
\ 'ttl': { 'left': '#' },
\ 'tup': { 'left': '#' },
\ 'twig': { 'left': '{#', 'right': '#}' },
\ 'txt2tags': { 'left': '%' },
\ 'typescript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'twig': { 'left': '{#', 'right': '#}' },
\ 'uc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'uil': { 'left': '!' },
\ 'upstart': { 'left': '#' },
\ 'vala': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'vasp': { 'left': '!' },
\ 'vb': { 'left': "'" },
\ 'velocity': { 'left': "##", 'right': "", 'leftAlt': '#*', 'rightAlt': '*#' },
\ 'vera': { 'left': '/*','right': '*/', 'leftAlt': '//' },
\ 'vera': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
\ 'verilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'verilog_systemverilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'vgrindefs': { 'left': '#' },
@@ -436,7 +463,7 @@ let s:delimiterMap = {
\ 'vsejcl': { 'left': '/*' },
\ 'webmacro': { 'left': '##' },
\ 'wget': { 'left': '#' },
\ 'Wikipedia': { 'left': '<!--', 'right': '-->' },
\ 'wikipedia': { 'left': '<!--', 'right': '-->' },
\ 'winbatch': { 'left': ';' },
\ 'wml': { 'left': '#' },
\ 'wvdial': { 'left': ';' },
@@ -505,6 +532,17 @@ function s:SetUpForNewFiletype(filetype, forceReset)
let b:NERDCommenterDelims[i] = ''
endif
endfor
for i in ['nested', 'nestedAlt']
if !has_key(b:NERDCommenterDelims, i)
let b:NERDCommenterDelims[i] = 0
endif
endfor
" if g:NERD_<filetype>_alt_style is defined, use the alternate style
let b:NERDCommenterFirstInit = getbufvar(1,"NERDCommenterFirstInit")
if exists('g:NERDAltDelims_'.ft) && eval('g:NERDAltDelims_'.ft) && !b:NERDCommenterFirstInit
call s:SwitchToAlternativeDelimiters(0)
let b:NERDCommenterFirstInit = 1
endif
else
let b:NERDCommenterDelims = s:CreateDelimMapFromCms()
endif
@@ -524,8 +562,10 @@ function s:CreateDelimMapFromCms()
return {
\ 'left': substitute(&commentstring, '\([^ \t]*\)\s*%s.*', '\1', ''),
\ 'right': substitute(&commentstring, '.*%s\s*\(.*\)', '\1', 'g'),
\ 'nested': 0,
\ 'leftAlt': '',
\ 'rightAlt': '' }
\ 'rightAlt': '',
\ 'nestedAlt': 0}
endfunction
" Function: s:SwitchToAlternativeDelimiters(printMsgs) function {{{2
@@ -538,6 +578,9 @@ endfunction
" -printMsgs: if this is 1 then a message is echoed to the user telling them
" if this function changed the delimiters or not
function s:SwitchToAlternativeDelimiters(printMsgs)
if exists('*NERDCommenter_before')
exe "call NERDCommenter_before()"
endif
"if both of the alternative delimiters are empty then there is no
"alternative comment style so bail out
if b:NERDCommenterDelims['leftAlt'] == '' && b:NERDCommenterDelims['rightAlt'] == ''
@@ -550,20 +593,28 @@ function s:SwitchToAlternativeDelimiters(printMsgs)
"save the current delimiters
let tempLeft = s:Left()
let tempRight = s:Right()
let tempNested = s:Nested()
"swap current delimiters for alternative
let b:NERDCommenterDelims['left'] = b:NERDCommenterDelims['leftAlt']
let b:NERDCommenterDelims['right'] = b:NERDCommenterDelims['rightAlt']
"set information on whether these are nested
let b:NERDCommenterDelims['nested'] = b:NERDCommenterDelims['nestedAlt']
"set the previously current delimiters to be the new alternative ones
let b:NERDCommenterDelims['leftAlt'] = tempLeft
let b:NERDCommenterDelims['rightAlt'] = tempRight
let b:NERDCommenterDelims['nestedAlt'] = tempNested
"tell the user what comment delimiters they are now using
if a:printMsgs
call s:NerdEcho("Now using " . s:Left() . " " . s:Right() . " to delimit comments", 1)
endif
if exists('*NERDCommenter_after')
exe "call NERDCommenter_after()"
endif
return 1
endfunction
@@ -584,15 +635,17 @@ function s:AppendCommentToLine()
"stick the delimiters down at the end of the line. We have to format the
"comment with spaces as appropriate
execute ":normal! " . insOrApp . (isLineEmpty ? '' : ' ') . left . right
execute ":normal! " . insOrApp . (isLineEmpty ? '' : ' ') . left . right
" if there is a right delimiter then we gotta move the cursor left
" by the length of the right delimiter so we insert between the delimiters
if lenRight > 0
let leftMoveAmount = lenRight - 1
execute ":normal! " . leftMoveAmount . "h"
startinsert
else
startinsert!
endif
startinsert
endfunction
" Function: s:CommentBlock(top, bottom, lSide, rSide, forceNested ) {{{2
@@ -713,6 +766,10 @@ function s:CommentBlock(top, bottom, lSide, rSide, forceNested )
let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif
if g:NERDTrimTrailingWhitespace == 1
let theLine = s:TrimTrailingWhitespace(theLine)
endif
call setline(currentLine, theLine)
endif
@@ -755,7 +812,7 @@ function s:CommentLines(forceNested, align, firstLine, lastLine)
if s:CanCommentLine(a:forceNested, currentLine)
"if the user has specified forceNesting then we check to see if we
"need to switch delimiters for place-holders
if a:forceNested && g:NERDUsePlaceHolders
if a:forceNested && g:NERDUsePlaceHolders && !s:Nested()
let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine)
endif
@@ -783,6 +840,10 @@ function s:CommentLines(forceNested, align, firstLine, lastLine)
let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif
if g:NERDTrimTrailingWhitespace == 1
let theLine = s:TrimTrailingWhitespace(theLine)
endif
" we are done with this line
call setline(currentLine, theLine)
let currentLine = currentLine + 1
@@ -801,9 +862,11 @@ function s:CommentLinesMinimal(firstLine, lastLine)
throw 'NERDCommenter.Delimiters exception: Minimal comments can only be used for filetypes that have multipart delimiters'
endif
let sexyNested = s:SexyNested()
"if we need to use place holders for the comment, make sure they are
"enabled for this filetype
if !g:NERDUsePlaceHolders && s:DoesBlockHaveMultipartDelim(a:firstLine, a:lastLine)
"enabled for this filetype, or the delimiterss allow nesting
if !g:NERDUsePlaceHolders && !sexyNested && s:DoesBlockHaveMultipartDelim(a:firstLine, a:lastLine)
throw 'NERDCommenter.Settings exception: Place holders are required but disabled.'
endif
@@ -813,13 +876,15 @@ function s:CommentLinesMinimal(firstLine, lastLine)
"make sure all multipart delimiters on the lines are replaced with
"placeholders to prevent illegal syntax
let currentLine = a:firstLine
while(currentLine <= a:lastLine)
let theLine = getline(currentLine)
let theLine = s:ReplaceDelims(left, right, g:NERDLPlace, g:NERDRPlace, theLine)
call setline(currentLine, theLine)
let currentLine = currentLine + 1
endwhile
if !sexyNested
let currentLine = a:firstLine
while(currentLine <= a:lastLine)
let theLine = getline(currentLine)
let theLine = s:ReplaceDelims(left, right, g:NERDLPlace, g:NERDRPlace, theLine)
call setline(currentLine, theLine)
let currentLine = currentLine + 1
endwhile
endif
"add the delimiter to the top line
let theLine = getline(a:firstLine)
@@ -839,6 +904,11 @@ function s:CommentLinesMinimal(firstLine, lastLine)
if lineHasLeadingTabs
let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif
if g:NERDTrimTrailingWhitespace == 1
let theLine = s:TrimTrailingWhitespace(theLine)
endif
call setline(a:lastLine, theLine)
endfunction
@@ -859,7 +929,7 @@ function s:CommentLinesSexy(topline, bottomline)
throw 'NERDCommenter.Delimiters exception: cannot perform sexy comments with available delimiters.'
endif
"make sure the lines aren't already commented sexually
"make sure the lines aren't already commented sexually or we can nest
if !s:CanSexyCommentLines(a:topline, a:bottomline)
throw 'NERDCommenter.Nesting exception: cannot nest sexy comments'
endif
@@ -884,7 +954,9 @@ function s:CommentLinesSexy(topline, bottomline)
if lineHasTabs
let theLine = s:ConvertLeadingTabsToSpaces(theLine)
endif
let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine)
if !s:SexyNested()
let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine)
endif
let theLine = s:AddLeftDelimAligned(left . spaceString, theLine, leftAlignIndx)
if lineHasTabs
let theLine = s:ConvertLeadingSpacesToTabs(theLine)
@@ -898,7 +970,9 @@ function s:CommentLinesSexy(topline, bottomline)
if lineHasTabs
let theLine = s:ConvertLeadingTabsToSpaces(theLine)
endif
let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine)
if !s:SexyNested()
let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine)
endif
endif
let theLine = s:AddRightDelim(spaceString . right, theLine)
if lineHasTabs
@@ -943,7 +1017,9 @@ function s:CommentLinesSexy(topline, bottomline)
let theLine = s:ConvertLeadingTabsToSpaces(theLine)
endif
let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine)
if !s:SexyNested()
let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine)
endif
" add the sexyComMarker
let theLine = repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . sexyComMarkerSpaced . strpart(theLine, leftAlignIndx)
@@ -952,6 +1028,9 @@ function s:CommentLinesSexy(topline, bottomline)
let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif
if g:NERDTrimTrailingWhitespace == 1
let theLine = s:TrimTrailingWhitespace(theLine)
endif
" set the line and move onto the next one
call setline(currentLine, theLine)
@@ -985,7 +1064,7 @@ function s:CommentLinesToggle(forceNested, firstLine, lastLine)
"if the user has specified forceNesting then we check to see if we
"need to switch delimiters for place-holders
if g:NERDUsePlaceHolders
if g:NERDUsePlaceHolders && !s:Nested()
let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine)
endif
@@ -1006,6 +1085,10 @@ function s:CommentLinesToggle(forceNested, firstLine, lastLine)
let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif
if g:NERDTrimTrailingWhitespace == 1
let theLine = s:TrimTrailingWhitespace(theLine)
endif
" we are done with this line
call setline(currentLine, theLine)
let currentLine = currentLine + 1
@@ -1103,6 +1186,11 @@ function s:InvertComment(firstLine, lastLine)
endwhile
endfunction
function! NERDCommentIsLineCommented(lineNo)
let theLine = getline(a:lineNo)
return s:IsInSexyComment(a:lineNo) || s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine)
endfunction
" Function: NERDComment(mode, type) function {{{2
" This function is a Wrapper for the main commenting functions
"
@@ -1113,6 +1201,10 @@ endfunction
" 'Minimal', 'Toggle', 'AlignLeft', 'AlignBoth', 'Comment',
" 'Nested', 'ToEOL', 'Append', 'Insert', 'Uncomment', 'Yank'
function! NERDComment(mode, type) range
if exists('*NERDCommenter_before')
exe "call NERDCommenter_before()"
endif
let isVisual = a:mode =~ '[vsx]'
if !exists("g:did_load_ftplugin") || g:did_load_ftplugin != 1
@@ -1167,12 +1259,29 @@ function! NERDComment(mode, type) range
endtry
elseif a:type ==? 'Toggle'
let theLine = getline(firstLine)
if s:IsInSexyComment(firstLine) || s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine)
call s:UncommentLines(firstLine, lastLine)
if g:NERDToggleCheckAllLines ==# 0
let theLine = getline(firstLine)
if s:IsInSexyComment(firstLine) || s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine)
call s:UncommentLines(firstLine, lastLine)
else
call s:CommentLinesToggle(forceNested, firstLine, lastLine)
endif
else
let l:commentAllLines = 0
for i in range(firstLine, lastLine)
let theLine = getline(i)
" if have one line no comment, then comment all lines
if !s:IsInSexyComment(firstLine) && !s:IsCommentedFromStartOfLine(s:Left(), theLine) && !s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine)
let l:commentAllLines = 1
break
else
endif
endfor
if l:commentAllLines ==# 1
call s:CommentLinesToggle(forceNested, firstLine, lastLine)
else
call s:UncommentLines(firstLine, lastLine)
endif
endif
elseif a:type ==? 'Minimal'
@@ -1217,6 +1326,11 @@ function! NERDComment(mode, type) range
else
silent! call repeat#set("\<Plug>NERDCommenter". a:type)
endif
if exists('*NERDCommenter_after')
exe "call NERDCommenter_after()"
endif
endfunction
" Function: s:PlaceDelimitersAndInsBetween() function {{{2
@@ -1305,13 +1419,13 @@ function s:RemoveDelimiters(left, right, line)
endif
"look for the right delimiter, if we find it, remove it
let rightIndx = s:FindDelimiterIndex(a:right, line)
let rightIndx = s:LastIndexOfDelim(a:right, line)
if rightIndx != -1
let line = strpart(line, 0, rightIndx) . strpart(line, rightIndx+lenRight)
"if the user has specified that there is a space before the right delimiter
"then check for the space and remove it if it is there
if delimsSpaced && strpart(line, rightIndx-s:lenSpaceStr, s:lenSpaceStr) == s:spaceStr && s:Multipart()
if delimsSpaced && strpart(line, rightIndx-s:lenSpaceStr, s:lenSpaceStr) == s:spaceStr && (s:Multipart() || s:AltMultipart())
let line = strpart(line, 0, rightIndx-s:lenSpaceStr) . strpart(line, rightIndx)
endif
endif
@@ -1333,7 +1447,7 @@ function s:SetupStateBeforeLineComment(topLine, bottomLine)
let state = {'foldmethod' : &foldmethod,
\'ignorecase' : &ignorecase}
" Vim's foldmethods are evaluated every time we use 'setline', which can
" Vim's foldmethods are evaluated every time we use 'setline', which can
" make commenting wide ranges of lines VERY slow. We'll change it to
" manual, do the commenting stuff and recover it later. To avoid slowing
" down commenting few lines, we avoid doing this for ranges smaller than
@@ -1364,6 +1478,15 @@ function s:RecoverStateAfterLineComment(state)
endif
endfunction
" Function: s:TrimTrailingWhitespace(line) {{{2
" This function removes all the trailing whitespace
" Args:
" -line: the target line
function s:TrimTrailingWhitespace(line)
let toReturn = substitute(a:line, '\s\+$', '', 'g')
return toReturn
endfunction
" Function: s:UncommentLines(topLine, bottomLine) {{{2
" This function uncomments the given lines
"
@@ -1456,6 +1579,10 @@ function s:UncommentLinesSexy(topline, bottomline)
let theLine = s:ConvertLeadingWhiteSpace(theLine)
if g:NERDTrimTrailingWhitespace == 1
let theLine = s:TrimTrailingWhitespace(theLine)
endif
" move onto the next line
call setline(currentLine, theLine)
let currentLine = currentLine + 1
@@ -1525,6 +1652,16 @@ function s:UncommentLinesSexy(topline, bottomline)
let theLine = s:SwapOuterPlaceHoldersForMultiPartDelims(theLine)
call setline(bottomline, theLine)
endif
" remove trailing whitespaces for first and last line
if g:NERDTrimTrailingWhitespace == 1
let theLine = getline(a:bottomline)
let theLine = s:TrimTrailingWhitespace(theLine)
call setline(a:bottomline, theLine)
let theLine = getline(a:topline)
let theLine = s:TrimTrailingWhitespace(theLine)
call setline(a:topline, theLine)
endif
endfunction
" Function: s:UncommentLineNormal(line) {{{2
@@ -1537,8 +1674,8 @@ function s:UncommentLineNormal(line)
"get the positions of all delimiter types on the line
let indxLeft = s:FindDelimiterIndex(s:Left(), line)
let indxLeftAlt = s:FindDelimiterIndex(s:Left({'alt': 1}), line)
let indxRight = s:FindDelimiterIndex(s:Right(), line)
let indxRightAlt = s:FindDelimiterIndex(s:Right({'alt': 1}), line)
let indxRight = s:LastIndexOfDelim(s:Right(), line)
let indxRightAlt = s:LastIndexOfDelim(s:Right({'alt': 1}), line)
"get the comment status on the line so we know how it is commented
let lineCommentStatus = s:IsCommentedOutermost(s:Left(), s:Right(), s:Left({'alt': 1}), s:Right({'alt': 1}), line)
@@ -1597,6 +1734,10 @@ function s:UncommentLineNormal(line)
let line = s:ConvertLeadingWhiteSpace(line)
if g:NERDTrimTrailingWhitespace == 1
let line = s:TrimTrailingWhitespace(line)
endif
return line
endfunction
@@ -1671,6 +1812,12 @@ function s:AltMultipart()
return b:NERDCommenterDelims['rightAlt'] != ''
endfunction
" Function: s:AltNested() {{{2
" returns 1 if the alternate multipart (if any) delimiters allow nesting
function s:AltNested()
return b:NERDCommenterDelims['nestedAlt']
endfunction
" Function: s:CanCommentLine(forceNested, line) {{{2
"This function is used to determine whether the given line can be commented.
"It returns 1 if it can be and 0 otherwise
@@ -1701,7 +1848,7 @@ function s:CanCommentLine(forceNested, lineNum)
endif
"if the line is commented but nesting is allowed then return true
if a:forceNested && (!s:Multipart() || g:NERDUsePlaceHolders)
if s:Nested() || (a:forceNested && (!s:Multipart() || g:NERDUsePlaceHolders))
return 1
endif
@@ -1723,6 +1870,11 @@ endfunction
" Return: 1 if the given lines can be commented sexually, 0 otherwise
function s:CanSexyCommentLines(topline, bottomline)
" see if the selected regions have any sexy comments
" however, if the language allows nested comments,
" we allow nested sexy comments
if s:SexyNested()
return 1
endif
let currentLine = a:topline
while(currentLine <= a:bottomline)
if s:IsInSexyComment(currentLine)
@@ -1744,8 +1896,9 @@ function s:CanToggleCommentLine(forceNested, lineNum)
return 0
endif
" make sure we don't comment lines that are just spaces or tabs or empty.
if theLine =~ "^[ \t]*$"
" make sure we don't comment lines that are just spaces or tabs or empty,
" unless configured otherwise
if g:NERDCommentEmptyLines == 0 && theLine =~ "^[ \t]*$"
return 0
endif
@@ -2056,6 +2209,29 @@ function s:GetSexyComMarker(space, esc)
return sexyComMarker
endfunction
" Function: s:SexyNested() {{{2
" Returns 1 if the sexy delimeters allow nesting
" TODO this is ugly copy&paste from the GetSexyComLeft/Right functions,
" these could all be cleaned up
function s:SexyNested()
let lenLeft = strlen(s:Left())
let lenLeftAlt = strlen(s:Left({'alt': 1}))
"assume c style sexy comments if possible
if s:HasCStyleComments()
return (s:Left() == '/*' && s:Nested()) || (s:Left({'alt': 1}) == '/*' && s:AltNested())
else
"grab the longest left delim that has a right
if s:Multipart() && lenLeft >= lenLeftAlt
return s:Nested()
elseif s:AltMultipart()
return s:AltNested()
else
return 0
endif
endif
endfunction
" Function: s:GetSexyComLeft(space, esc) {{{2
" Returns the left delimiter for sexy comments for this filetype or -1 if
" there is none. C style sexy comments are used if possible
@@ -2183,7 +2359,7 @@ endfunction
" -left/right: the left and right delimiters to check for
function s:IsCommented(left, right, line)
"if the line isn't commented return true
if s:FindDelimiterIndex(a:left, a:line) != -1 && (s:FindDelimiterIndex(a:right, a:line) != -1 || !s:Multipart())
if s:FindDelimiterIndex(a:left, a:line) != -1 && (s:LastIndexOfDelim(a:right, a:line) != -1 || !s:Multipart())
return 1
endif
return 0
@@ -2407,7 +2583,7 @@ function s:IsSexyComment(topline, bottomline)
endif
"if there is a right delimiter on the top line then this isn't a sexy comment
if s:FindDelimiterIndex(right, getline(a:topline)) != -1
if s:LastIndexOfDelim(right, getline(a:topline)) != -1
return 0
endif
@@ -2436,7 +2612,7 @@ function s:IsSexyComment(topline, bottomline)
"if there is a right delimiter in an intermediate line then the block isn't
"a sexy comment
if s:FindDelimiterIndex(right, theLine) != -1
if s:LastIndexOfDelim(right, theLine) != -1
return 0
endif
@@ -2573,6 +2749,12 @@ function s:NerdEcho(msg, typeOfMsg)
endif
endfunction
" Function: s:Nested() {{{2
" returns 1 if the current multipart (if any) delimiters allow nesting
function s:Nested()
return b:NERDCommenterDelims['nested']
endfunction
" Function: s:NumberOfLeadingTabs(s) {{{2
" returns the number of leading tabs in the given string
function s:NumberOfLeadingTabs(s)