67 Commits
2.4.0 ... 2.5.1

Author SHA1 Message Date
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 427 additions and 136 deletions

173
README.md
View File

@@ -1,95 +1,156 @@
# 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 ### Via Plugin Manager (Recommended)
doc/NERD_commenter.txt
### 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. 1. Add `Plug 'scrooloose/nerdcommenter'` to your vimrc file.
2. Finish the install by updating your help files. Run: 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 #### [NeoBundle](https://github.com/Shougo/neobundle.vim)
1. Navigate to your **[VIM_ROOT]/bundle** directory in your local Vim setup
2. `git clone https://github.com/scrooloose/nerdcommenter.git`
### Vundle Install 1. Add `NeoBundle 'scrooloose/nerdcommenter'` to your vimrc file.
1. Add `Plugin 'scrooloose/nerdcommenter'` to your .vimrc file. 2. Reload your vimrc or restart
2. Run `:BundleInstall` 3. Run `:NeoUpdate``
### Post Install #### [Pathogen](https://github.com/tpope/vim-pathogen)
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:
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 #### Unix
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. (For Neovim, change `~/.vim/` to `~/.config/nvim/`.)
**[count]\<leader\>cc |NERDComComment|** ```sh
Comment out the current line or text selected in visual mode. 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|** ```powershell
Same as \<leader\>cc but forces nesting. 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|** 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:
Toggles the comment state of the selected line(s). If the topmost selected
line is commented, all selected lines are uncommented and vice versa.
```sh
filetype plugin on
```
**[count]\<leader\>cm |NERDComMinimalComment|** ## Usage
Comments the given lines using only one set of multipart delimiters.
### Documentation
**[count]\<leader\>ci |NERDComInvertComment|** Please see the vim help system for full documentation of all options: `:help nerdcommenter`
Toggles the comment state of the selected line(s) individually.
### Settings
**[count]\<leader\>cs |NERDComSexyComment|** Several settings can be added to your vimrc to change the default behavior. Some examples:
Comments out the selected lines ``sexily''
```vim
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
**[count]\<leader\>cy |NERDComYankComment|** " Use compact syntax for prettified multi-line comments
Same as \<leader\>cc except that the commented line(s) are yanked first. let g:NERDCompactSexyComs = 1
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
**\<leader\>c$ |NERDComEOLComment|** " Set a language to use its alternate delimiters by default
Comments the current line from the cursor to the end of line. let g:NERDAltDelims_java = 1
" Add your own custom formats or override the defaults
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }
**\<leader\>cA |NERDComAppendComment|** " Allow commenting and inverting empty lines (useful when commenting a region)
Adds comment delimiters to the end of line and goes into insert mode between let g:NERDCommentEmptyLines = 1
them.
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1
```
**|NERDComInsertComment|** ### Default mappings
Adds comment delimiters at the current cursor position and inserts between.
Disabled by default.
The following key mappings are provided by default (there is also a menu provided that contains menu items corresponding to all the below mappings):
**\<leader\>ca |NERDComAltDelim|** Most of the following mappings are for normal/visual mode only. The **|NERDComInsertComment|** mapping is for insert mode only.
Switches to the alternative set of delimiters.
* `[count]<leader>cc` **|NERDComComment|**
**[count]\<leader\>cl** Comment out the current line or text selected in visual mode.
**[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>cn` **|NERDComNestedComment|**
**[count]\<leader\>cu |NERDComUncommentLine|** Same as <leader>cc but forces nesting.
Uncomments the selected line(s).
* `[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.11 Use alternate delims map...|NERDComAltDelim|
3.2.12 Comment aligned maps.......|NERDComAlignedComment| 3.2.12 Comment aligned maps.......|NERDComAlignedComment|
3.2.13 Uncomment line map.........|NERDComUncommentLine| 3.2.13 Uncomment line map.........|NERDComUncommentLine|
3.4 Sexy Comments.....................|NERDComSexyComments| 3.3 Sexy Comments.....................|NERDComSexyComments|
3.5 The NERDComment function..........|NERDComNERDComment| 3.4 The NERDComment function..........|NERDComNERDComment|
3.5 The Hooks.........................|NERDComHooks|
4.Options.................................|NERDComOptions| 4.Options.................................|NERDComOptions|
4.1 Options summary...................|NERDComOptionsSummary| 4.1 Options summary...................|NERDComOptionsSummary|
4.2 Options details...................|NERDComOptionsDetails| 4.2 Options details...................|NERDComOptionsDetails|
@@ -391,6 +392,35 @@ For example, if you typed >
< <
then the script would do a sexy comment on the last visual selection. then the script would do a sexy comment on the last visual selection.
------------------------------------------------------------------------------
3.5 The hooks *NERDComHooks*
|fu! NERDCommenter_before()| Before NERDComment/SwitchToAlternativeDelimiters
|fu! NERDCommenter_after()| After NERDComment/SwitchToAlternativeDelimiters
For example, in order to handle different language blocks embedded in the same
file such as |vim-vue|, you can change the filetype, comment something and
change the filetype back: >
let g:ft = ''
fu! NERDCommenter_before()
if &ft == 'vue'
let g:ft = 'vue'
let stack = synstack(line('.'), col('.'))
if len(stack) > 0
let syn = synIDattr((stack)[0], 'name')
if len(syn) > 0
let syn = tolower(syn)
exe 'setf '.syn
endif
endif
endif
endfu
fu! NERDCommenter_after()
if g:ft == 'vue'
setf vue
let g:ft = ''
endif
endfu
<
============================================================================== ==============================================================================
4. Options *NERDComOptions* 4. Options *NERDComOptions*
@@ -399,40 +429,61 @@ then the script would do a sexy comment on the last visual selection.
4.1 Options summary *NERDComOptionsSummary* 4.1 Options summary *NERDComOptionsSummary*
|'loaded_nerd_comments'| Turns off the script. |'loaded_nerd_comments'| Turns off the script.
|'NERDAllowAnyVisualDelims'| Allows multipart alternative delimiters |'NERDAllowAnyVisualDelims'| Allows multipart alternative delimiters
to be used when commenting in to be used when commenting in
visual/visual-block mode. visual/visual-block mode.
|'NERDBlockComIgnoreEmpty'| Forces right delimiters to be placed |'NERDBlockComIgnoreEmpty'| Forces right delimiters to be placed
when doing visual-block comments. when doing visual-block comments.
|'NERDCommentEmptyLines'| Specifies if empty lines should be
commented (useful with regions).
|'NERDCommentWholeLinesInVMode'| Changes behaviour of visual comments. |'NERDCommentWholeLinesInVMode'| Changes behaviour of visual comments.
|'NERDCreateDefaultMappings'| Turn the default mappings on/off. |'NERDCreateDefaultMappings'| Turn the default mappings on/off.
|'NERDCustomDelimiters'| Add or override delimiters for any |'NERDCustomDelimiters'| Add or override delimiters for any
filetypes. filetypes.
|'NERDDefaultNesting'| Tells the script to use nested comments |'NERDDefaultNesting'| Tells the script to use nested comments
by default. by default.
|'NERDMenuMode'| Specifies how the NERD commenter menu |'NERDMenuMode'| Specifies how the NERD commenter menu
will appear (if at all). will appear (if at all).
|'NERDLPlace'| Specifies what to use as the left |'NERDLPlace'| Specifies what to use as the left
delimiter placeholder when nesting delimiter placeholder when nesting
comments. comments.
|'NERDUsePlaceHolders'| Specifies which filetypes may use |'NERDUsePlaceHolders'| Specifies which filetypes may use
placeholders when nesting comments. placeholders when nesting comments.
|'NERDRemoveAltComs'| Tells the script whether to remove |'NERDRemoveAltComs'| Tells the script whether to remove
alternative comment delimiters when alternative comment delimiters when
uncommenting. uncommenting.
|'NERDRemoveExtraSpaces'| Tells the script to always remove the |'NERDRemoveExtraSpaces'| Tells the script to always remove the
extra spaces when uncommenting extra spaces when uncommenting
(regardless of whether NERDSpaceDelims (regardless of whether NERDSpaceDelims
is set) is set).
|'NERDRPlace'| Specifies what to use as the right |'NERDRPlace'| Specifies what to use as the right
delimiter placeholder when nesting delimiter placeholder when nesting
comments. comments.
|'NERDSpaceDelims'| Specifies whether to add extra spaces |'NERDSpaceDelims'| Specifies whether to add extra spaces
around delimiters when commenting, and around delimiters when commenting, and
whether to remove them when whether to remove them when
uncommenting. uncommenting.
|'NERDTrimTrailingWhitespace'| Specifies if trailing whitespace
should be deleted when uncommenting.
|'NERDCompactSexyComs'| Specifies whether to use the compact |'NERDCompactSexyComs'| Specifies whether to use the compact
style sexy comments. style sexy comments.
|'NERDDefaultAlign'| Specifies the default alignment to use, |'NERDDefaultAlign'| Specifies the default alignment to use,
one of 'none', 'left', 'start', or one of 'none', 'left', 'start', or
'both'. 'both'.
@@ -514,6 +565,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'* *'NERDCommentWholeLinesInVMode'*
Values: 0, 1 or 2. Values: 0, 1 or 2.
@@ -692,6 +752,15 @@ If you want spaces to be added then set NERDSpaceDelims to 1 in your vimrc.
See also |'NERDRemoveExtraSpaces'|. See also |'NERDRemoveExtraSpaces'|.
------------------------------------------------------------------------------
*'NERDTrimTrailingWhitespace'*
Values: 0 or 1.
Default 0.
When uncommenting an empty line some whitespace may be left as a result of
alignment padding. With this option enabled any trailing whitespace will be
deleted when uncommenting a line.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*'NERDDefaultAlign'* *'NERDDefaultAlign'*
Values: 'none', 'left', 'start', 'both' Values: 'none', 'left', 'start', 'both'
@@ -736,11 +805,11 @@ again.
If you want the NERD commenter to use the alternative delimiters for a If you want the NERD commenter to use the alternative delimiters for a
specific filetype by default then put a line of this form into your vimrc: > specific filetype by default then put a line of this form into your vimrc: >
let NERD_<filetype>_alt_style=1 let g:NERDAltDelims_<filetype> = 1
< <
Example: java uses // style comments by default, but you want it to default to Example: java uses // style comments by default, but you want it to default to
/* */ style comments instead. You would put this line in your vimrc: > /* */ style comments instead. You would put this line in your vimrc: >
let NERD_java_alt_style=1 let g:NERDAltDelims_java = 1
< <
See |NERDComAltDelim| for switching commenting styles at runtime. See |NERDComAltDelim| for switching commenting styles at runtime.
@@ -1024,6 +1093,7 @@ Simon Hengel htmlcheetah
Matt Tolton javacc Matt Tolton javacc
Ivan Devat javascript.jquery Ivan Devat javascript.jquery
tpope cucumber,pdf tpope cucumber,pdf
Lyude Paul piglit shader_test
============================================================================== ==============================================================================
10. License *NERDComLicense* 10. License *NERDComLicense*

View File

@@ -3,8 +3,8 @@
" Description: vim global plugin that provides easy code commenting " Description: vim global plugin that provides easy code commenting
" Author: Martin Grenfell <martin.grenfell at gmail dot com> " Author: Martin Grenfell <martin.grenfell at gmail dot com>
" Maintainer: Caleb Maclennan <caleb@alerque.com> " Maintainer: Caleb Maclennan <caleb@alerque.com>
" Version: 2.4.0 " Version: 2.5.1
" Last Change: Tue May 24 14:03:29 EEST 2016 " Last Change: Tue Nov 7 10:45:53 +03 2017
" License: This program is free software. It comes without any warranty, " License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute " 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 " it and/or modify it under the terms of the Do What The Fuck You
@@ -64,6 +64,7 @@ call s:InitVariable("g:NERDRemoveExtraSpaces", 0)
call s:InitVariable("g:NERDRPlace", "<]") call s:InitVariable("g:NERDRPlace", "<]")
call s:InitVariable("g:NERDSpaceDelims", 0) call s:InitVariable("g:NERDSpaceDelims", 0)
call s:InitVariable("g:NERDDefaultAlign", "none") call s:InitVariable("g:NERDDefaultAlign", "none")
call s:InitVariable("g:NERDTrimTrailingWhitespace", 0)
let s:NERDFileNameEscape="[]#*$%'\" ?`!&();<>\\" let s:NERDFileNameEscape="[]#*$%'\" ?`!&();<>\\"
@@ -78,19 +79,22 @@ let s:delimiterMap = {
\ 'amiga': { 'left': ';' }, \ 'amiga': { 'left': ';' },
\ 'aml': { 'left': '/*' }, \ 'aml': { 'left': '/*' },
\ 'ampl': { 'left': '#' }, \ 'ampl': { 'left': '#' },
\ 'ansible': { 'left': '#' },
\ 'apache': { 'left': '#' }, \ 'apache': { 'left': '#' },
\ 'apachestyle': { 'left': '#' }, \ 'apachestyle': { 'left': '#' },
\ 'asciidoc': { 'left': '//' },
\ 'applescript': { 'left': '--', 'leftAlt': '(*', 'rightAlt': '*)' }, \ 'applescript': { 'left': '--', 'leftAlt': '(*', 'rightAlt': '*)' },
\ 'armasm': { 'left': ';' }, \ 'armasm': { 'left': ';' },
\ 'asm68k': { 'left': ';' }, \ 'asciidoc': { 'left': '//' },
\ 'asm': { 'left': ';', 'leftAlt': '#' }, \ 'asm': { 'left': ';', 'leftAlt': '#' },
\ 'asm68k': { 'left': ';' },
\ 'asn': { 'left': '--' }, \ 'asn': { 'left': '--' },
\ 'asp': { 'left': '%', 'leftAlt': '%*', 'rightAlt': '*%' },
\ 'aspvbs': { 'left': '''', 'leftAlt': '<!--', 'rightAlt': '-->' }, \ 'aspvbs': { 'left': '''', 'leftAlt': '<!--', 'rightAlt': '-->' },
\ 'asterisk': { 'left': ';' }, \ 'asterisk': { 'left': ';' },
\ 'asy': { 'left': '//' }, \ 'asy': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'atlas': { 'left': 'C', 'right': '$' }, \ 'atlas': { 'left': 'C', 'right': '$' },
\ 'autohotkey': { 'left': ';' }, \ 'augeas': { 'left': '(*', 'right': '*)' },
\ 'autohotkey': { 'left': ';', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'autoit': { 'left': ';' }, \ 'autoit': { 'left': ';' },
\ 'ave': { 'left': "'" }, \ 'ave': { 'left': "'" },
\ 'awk': { 'left': '#' }, \ 'awk': { 'left': '#' },
@@ -102,11 +106,11 @@ let s:delimiterMap = {
\ 'blade': { 'left': '{{--', 'right': '--}}' }, \ 'blade': { 'left': '{{--', 'right': '--}}' },
\ 'bst': { 'left': '%' }, \ 'bst': { 'left': '%' },
\ 'btm': { 'left': '::' }, \ 'btm': { 'left': '::' },
\ 'c': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
\ 'cabal': { 'left': '--' }, \ 'cabal': { 'left': '--' },
\ 'caos': { 'left': '*' },
\ 'calibre': { 'left': '//' }, \ 'calibre': { 'left': '//' },
\ 'caos': { 'left': '*' },
\ 'catalog': { 'left': '--', 'right': '--' }, \ 'catalog': { 'left': '--', 'right': '--' },
\ 'c': { 'left': '/*','right': '*/', 'leftAlt': '//' },
\ 'cf': { 'left': '<!---', 'right': '--->' }, \ 'cf': { 'left': '<!---', 'right': '--->' },
\ 'cfg': { 'left': '#' }, \ 'cfg': { 'left': '#' },
\ 'cg': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'cg': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
@@ -121,26 +125,26 @@ let s:delimiterMap = {
\ 'context': { 'left': '%', 'leftAlt': '--' }, \ 'context': { 'left': '%', 'leftAlt': '--' },
\ 'coq': { 'left': '(*', 'right': '*)' }, \ 'coq': { 'left': '(*', 'right': '*)' },
\ 'cpp': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'cpp': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'cuda': { 'left': '/*','right': '*/', 'leftAlt': '//' },
\ 'crontab': { 'left': '#' }, \ 'crontab': { 'left': '#' },
\ 'cs': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'cs': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'csp': { 'left': '--' }, \ 'csp': { 'left': '--' },
\ 'cterm': { 'left': '*' }, \ 'cterm': { 'left': '*' },
\ 'cucumber': { 'left': '#' }, \ 'cucumber': { 'left': '#' },
\ 'cython': { 'left': '# ', 'leftAlt': '#' }, \ 'cuda': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
\ 'cvs': { 'left': 'CVS:' }, \ 'cvs': { 'left': 'CVS:' },
\ 'cython': { 'left': '# ', 'leftAlt': '#' },
\ 'd': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'd': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'dcl': { 'left': '$!' },
\ 'dakota': { 'left': '#' }, \ 'dakota': { 'left': '#' },
\ 'dcl': { 'left': '$!' },
\ 'debcontrol': { 'left': '#' }, \ 'debcontrol': { 'left': '#' },
\ 'debsources': { 'left': '#' }, \ 'debsources': { 'left': '#' },
\ 'def': { 'left': ';' }, \ 'def': { 'left': ';' },
\ 'desktop': { 'left': '#' }, \ 'desktop': { 'left': '#' },
\ 'dhcpd': { 'left': '#' }, \ 'dhcpd': { 'left': '#' },
\ 'diff': { 'left': '#' }, \ 'diff': { 'left': '#' },
\ 'django': { 'left': '<!--','right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' }, \ 'django': { 'left': '<!--', 'right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' },
\ 'docbk': { 'left': '<!--', 'right': '-->' },
\ 'dns': { 'left': ';' }, \ 'dns': { 'left': ';' },
\ 'docbk': { 'left': '<!--', 'right': '-->' },
\ 'dockerfile': { 'left': '#' }, \ 'dockerfile': { 'left': '#' },
\ 'dosbatch': { 'left': 'REM ', 'leftAlt': '::' }, \ 'dosbatch': { 'left': 'REM ', 'leftAlt': '::' },
\ 'dosini': { 'left': ';' }, \ 'dosini': { 'left': ';' },
@@ -155,7 +159,7 @@ let s:delimiterMap = {
\ 'eiffel': { 'left': '--' }, \ 'eiffel': { 'left': '--' },
\ 'elf': { 'left': "'" }, \ 'elf': { 'left': "'" },
\ 'elixir': { 'left': '#' }, \ 'elixir': { 'left': '#' },
\ 'elm': { 'left': '--' }, \ 'elm': { 'left': '--', 'leftAlt': '{--', 'rightAlt': '--}' },
\ 'elmfilt': { 'left': '#' }, \ 'elmfilt': { 'left': '#' },
\ 'ember-script': { 'left': '#' }, \ 'ember-script': { 'left': '#' },
\ 'emblem': { 'left': '/' }, \ 'emblem': { 'left': '/' },
@@ -164,8 +168,8 @@ let s:delimiterMap = {
\ 'esmtprc': { 'left': '#' }, \ 'esmtprc': { 'left': '#' },
\ 'expect': { 'left': '#' }, \ 'expect': { 'left': '#' },
\ 'exports': { 'left': '#' }, \ 'exports': { 'left': '#' },
\ 'fancy': { 'left': '#' },
\ 'factor': { 'left': '! ', 'leftAlt': '!# ' }, \ 'factor': { 'left': '! ', 'leftAlt': '!# ' },
\ 'fancy': { 'left': '#' },
\ 'fgl': { 'left': '#' }, \ 'fgl': { 'left': '#' },
\ 'focexec': { 'left': '-*' }, \ 'focexec': { 'left': '-*' },
\ 'form': { 'left': '*' }, \ 'form': { 'left': '*' },
@@ -179,7 +183,7 @@ let s:delimiterMap = {
\ 'gdb': { 'left': '#' }, \ 'gdb': { 'left': '#' },
\ 'gdmo': { 'left': '--' }, \ 'gdmo': { 'left': '--' },
\ 'geek': { 'left': 'GEEK_COMMENT:' }, \ 'geek': { 'left': 'GEEK_COMMENT:' },
\ 'genshi': { 'left': '<!--','right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' }, \ 'genshi': { 'left': '<!--', 'right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' },
\ 'gentoo-conf-d': { 'left': '#' }, \ 'gentoo-conf-d': { 'left': '#' },
\ 'gentoo-env-d': { 'left': '#' }, \ 'gentoo-env-d': { 'left': '#' },
\ 'gentoo-init-d': { 'left': '#' }, \ 'gentoo-init-d': { 'left': '#' },
@@ -189,31 +193,36 @@ let s:delimiterMap = {
\ 'gentoo-package-use': { 'left': '#' }, \ 'gentoo-package-use': { 'left': '#' },
\ 'gitcommit': { 'left': '#' }, \ 'gitcommit': { 'left': '#' },
\ 'gitconfig': { 'left': ';' }, \ 'gitconfig': { 'left': ';' },
\ 'gitignore': { 'left': '#' },
\ 'gitrebase': { 'left': '#' }, \ 'gitrebase': { 'left': '#' },
\ 'glsl': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'gnuplot': { 'left': '#' }, \ 'gnuplot': { 'left': '#' },
\ 'go': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'go': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'groovy': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'groovy': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'gsp': { 'left': '<%--', 'right': '--%>', 'leftAlt': '<!--','rightAlt': '-->'}, \ 'gsp': { 'left': '<%--', 'right': '--%>', 'leftAlt': '<!--', 'rightAlt': '-->' },
\ 'gtkrc': { 'left': '#' }, \ 'gtkrc': { 'left': '#' },
\ 'haskell': { 'left': '{-','right': '-}', 'leftAlt': '--' },
\ 'hb': { 'left': '#' },
\ 'h': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'h': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'haml': { 'left': '-#', 'leftAlt': '/' }, \ 'haml': { 'left': '-#', 'leftAlt': '/' },
\ 'haxe': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'handlebars': { 'left': '{{!-- ', 'right': ' --}}' }, \ 'handlebars': { 'left': '{{!-- ', 'right': ' --}}' },
\ 'haskell': { 'left': '{-', 'right': '-}', 'nested': 1, 'leftAlt': '--', 'nestedAlt': 1 },
\ 'haxe': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'hb': { 'left': '#' },
\ 'hbs': { 'left': '{{!-- ', 'right': ' --}}' }, \ 'hbs': { 'left': '{{!-- ', 'right': ' --}}' },
\ 'hercules': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'hercules': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'hive': { 'left': '-- ' },
\ 'hog': { 'left': '#' }, \ 'hog': { 'left': '#' },
\ 'hostsaccess': { 'left': '#' }, \ 'hostsaccess': { 'left': '#' },
\ 'htmlcheetah': { 'left': '##' }, \ 'htmlcheetah': { 'left': '##' },
\ 'htmldjango': { 'left': '<!--','right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' }, \ 'htmldjango': { 'left': '<!--', 'right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' },
\ 'htmlos': { 'left': '#', 'right': '/#' }, \ 'htmlos': { 'left': '#', 'right': '/#' },
\ 'hxml': { 'left': '#' }, \ 'hxml': { 'left': '#' },
\ 'hyphy': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'ia64': { 'left': '#' }, \ 'ia64': { 'left': '#' },
\ 'icon': { 'left': '#' }, \ 'icon': { 'left': '#' },
\ 'idlang': { 'left': ';' },
\ 'idl': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'idl': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'idlang': { 'left': ';' },
\ 'idris': { 'leftAlt': '--', 'left': '{-', 'right': '-}' }, \ 'idris': { 'leftAlt': '--', 'left': '{-', 'right': '-}' },
\ 'incar': { 'left': '!' },
\ 'inform': { 'left': '!' }, \ 'inform': { 'left': '!' },
\ 'inittab': { 'left': '#' }, \ 'inittab': { 'left': '#' },
\ 'ishd': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'ishd': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
@@ -226,30 +235,32 @@ let s:delimiterMap = {
\ 'javascript.jquery': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'javascript.jquery': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'jess': { 'left': ';' }, \ 'jess': { 'left': ';' },
\ 'jgraph': { 'left': '(*', 'right': '*)' }, \ 'jgraph': { 'left': '(*', 'right': '*)' },
\ 'jinja': { 'left': '<!--','right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' }, \ 'jinja': { 'left': '<!--', 'right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' },
\ 'jproperties': { 'left': '#' }, \ 'jproperties': { 'left': '#' },
\ 'jsp': { 'left': '<%--', 'right': '--%>' }, \ 'jsp': { 'left': '<%--', 'right': '--%>' },
\ 'julia': { 'left': '#' }, \ 'julia': { 'left': '# ', 'leftAlt': '#=', 'rightAlt': '=#' },
\ 'kix': { 'left': ';' }, \ 'kix': { 'left': ';' },
\ 'kscript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'kscript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'lace': { 'left': '--' }, \ 'lace': { 'left': '--' },
\ 'laravel': { 'left': '{{--', 'right': '--}}' }, \ 'laravel': { 'left': '{{--', 'right': '--}}' },
\ 'ldif': { 'left': '#' }, \ 'ldif': { 'left': '#' },
\ 'less': { 'left': '/*','right': '*/' }, \ 'less': { 'left': '/*', 'right': '*/' },
\ 'lhaskell': { 'left': '>{-','right': '-}', 'leftAlt': '>-- ' }, \ 'lhaskell': { 'left': '>{-', 'right': '-}', 'leftAlt': '>-- ' },
\ 'lilo': { 'left': '#' }, \ 'lilo': { 'left': '#' },
\ 'lilypond': { 'left': '%' }, \ 'lilypond': { 'left': '%' },
\ 'liquid': { 'left': '{% comment %}', 'right': '{% endcomment %}' }, \ 'liquid': { 'left': '{% comment %}', 'right': '{% endcomment %}' },
\ 'lisp': { 'left': ';', 'leftAlt': '#|', 'rightAlt': '|#' }, \ 'lisp': { 'left': ';', 'nested': 1, 'leftAlt': '#|', 'rightAlt': '|#', 'nestedAlt': 1 },
\ 'llvm': { 'left': ';' }, \ 'llvm': { 'left': ';' },
\ 'lotos': { 'left': '(*', 'right': '*)' }, \ 'lotos': { 'left': '(*', 'right': '*)' },
\ 'lout': { 'left': '#' }, \ 'lout': { 'left': '#' },
\ 'lpc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'lprolog': { 'left': '%' }, \ 'lprolog': { 'left': '%' },
\ 'lscript': { 'left': "'" }, \ 'lscript': { 'left': "'" },
\ 'lss': { 'left': '#' }, \ 'lss': { 'left': '#' },
\ 'lua': { 'left': '--', 'leftAlt': '--[[', 'rightAlt': ']]' }, \ 'lua': { 'left': '--', 'leftAlt': '--[[', 'rightAlt': ']]' },
\ 'lynx': { 'left': '#' }, \ 'lynx': { 'left': '#' },
\ 'lytex': { 'left': '%' }, \ 'lytex': { 'left': '%' },
\ 'm4': { 'left': 'dnl ' },
\ 'mail': { 'left': '> ' }, \ 'mail': { 'left': '> ' },
\ 'mako': { 'left': '##' }, \ 'mako': { 'left': '##' },
\ 'man': { 'left': '."' }, \ 'man': { 'left': '."' },
@@ -261,15 +272,18 @@ let s:delimiterMap = {
\ 'master': { 'left': '$' }, \ 'master': { 'left': '$' },
\ 'matlab': { 'left': '%', 'leftAlt': '%{', 'rightAlt': '%}' }, \ 'matlab': { 'left': '%', 'leftAlt': '%{', 'rightAlt': '%}' },
\ 'mel': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'mel': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'meson': { 'left': '#' },
\ 'mib': { 'left': '--' }, \ 'mib': { 'left': '--' },
\ 'mips': { 'left': '#'}, \ 'minizinc': { 'left': '% ', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'mirah': {'left': '#'}, \ 'mips': { 'left': '#' },
\ 'mirah': {'left': '#' },
\ 'mkd': { 'left': '<!---', 'right': '-->' }, \ 'mkd': { 'left': '<!---', 'right': '-->' },
\ 'mma': { 'left': '(*', 'right': '*)' }, \ 'mma': { 'left': '(*', 'right': '*)' },
\ 'model': { 'left': '$', 'right': '$' }, \ 'model': { 'left': '$', 'right': '$' },
\ 'moduala.': { 'left': '(*', 'right': '*)' }, \ 'moduala.': { 'left': '(*', 'right': '*)' },
\ 'modula2': { 'left': '(*', 'right': '*)' }, \ 'modula2': { 'left': '(*', 'right': '*)' },
\ 'modula3': { 'left': '(*', 'right': '*)' }, \ 'modula3': { 'left': '(*', 'right': '*)' },
\ 'molpro': { 'left': '!' },
\ 'monk': { 'left': ';' }, \ 'monk': { 'left': ';' },
\ 'mush': { 'left': '#' }, \ 'mush': { 'left': '#' },
\ 'mustache': { 'left': '{{!', 'right': '}}' }, \ 'mustache': { 'left': '{{!', 'right': '}}' },
@@ -288,7 +302,7 @@ let s:delimiterMap = {
\ 'objc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'objc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'objcpp': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'objcpp': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'objj': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'objj': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'ocaml': { 'left': '(*', 'right': '*)' }, \ 'ocaml': { 'left': '(*', 'right': '*)', 'nested': 1 },
\ 'occam': { 'left': '--' }, \ 'occam': { 'left': '--' },
\ 'octave': { 'left': '%', 'leftAlt': '#' }, \ 'octave': { 'left': '%', 'leftAlt': '#' },
\ 'omlet': { 'left': '(*', 'right': '*)' }, \ 'omlet': { 'left': '(*', 'right': '*)' },
@@ -300,7 +314,7 @@ let s:delimiterMap = {
\ 'ox': { 'left': '//' }, \ 'ox': { 'left': '//' },
\ 'paludis-use-conf': { 'left': '#' }, \ 'paludis-use-conf': { 'left': '#' },
\ 'pandoc': { 'left': '<!--', 'right': '-->' }, \ 'pandoc': { 'left': '<!--', 'right': '-->' },
\ 'pascal': { 'left': '{','right': '}', 'leftAlt': '(*', 'rightAlt': '*)' }, \ 'pascal': { 'left': '{', 'right': '}', 'leftAlt': '(*', 'rightAlt': '*)' },
\ 'patran': { 'left': '$', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'patran': { 'left': '$', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'pcap': { 'left': '#' }, \ 'pcap': { 'left': '#' },
\ 'pccts': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'pccts': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
@@ -315,6 +329,7 @@ let s:delimiterMap = {
\ 'plm': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'plm': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'plsql': { 'left': '-- ', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'plsql': { 'left': '-- ', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'po': { 'left': '#' }, \ 'po': { 'left': '#' },
\ 'poscar': { 'left': '!' },
\ 'postscr': { 'left': '%' }, \ 'postscr': { 'left': '%' },
\ 'pov': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'pov': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'povini': { 'left': ';' }, \ 'povini': { 'left': ';' },
@@ -326,39 +341,42 @@ let s:delimiterMap = {
\ 'ps1': { 'left': '#' }, \ 'ps1': { 'left': '#' },
\ 'psf': { 'left': '#' }, \ 'psf': { 'left': '#' },
\ 'ptcap': { 'left': '#' }, \ 'ptcap': { 'left': '#' },
\ 'pug': { 'left': '//-', 'leftAlt': '//' },
\ 'puppet': { 'left': '#' }, \ 'puppet': { 'left': '#' },
\ 'pyrex': { 'left': '# ', 'leftAlt': '#' }, \ 'pyrex': { 'left': '# ', 'leftAlt': '#' },
\ 'python': { 'left': '# ', 'leftAlt': '#' }, \ 'python': { 'left': '# ', 'leftAlt': '#' },
\ 'racket': { 'left': ';', 'leftAlt': '#|', 'rightAlt': '|#' }, \ 'r': { 'left': '#', 'leftAlt': '#''' },
\ 'racket': { 'left': ';', 'nested': 1, 'leftAlt': '#|', 'rightAlt': '|#', 'nestedAlt': 1 },
\ 'radiance': { 'left': '#' }, \ 'radiance': { 'left': '#' },
\ 'ratpoison': { 'left': '#' }, \ 'ratpoison': { 'left': '#' },
\ 'r': { 'left': '#' },
\ 'rc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'rc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'rebol': { 'left': ';' }, \ 'rebol': { 'left': ';' },
\ 'registry': { 'left': ';' }, \ 'registry': { 'left': ';' },
\ 'remind': { 'left': '#' }, \ 'remind': { 'left': '#' },
\ 'renpy': { 'left': '# ' },
\ 'resolv': { 'left': '#' }, \ 'resolv': { 'left': '#' },
\ 'rgb': { 'left': '!' }, \ 'rgb': { 'left': '!' },
\ 'rib': { 'left': '#' }, \ 'rib': { 'left': '#' },
\ 'rmd': { 'left': '#' }, \ 'rmd': { 'left': '#' },
\ 'robots': { 'left': '#' }, \ 'robots': { 'left': '#' },
\ 'rspec': { 'left': '#' }, \ 'rspec': { 'left': '#' },
\ 'ruby': { 'left': '# ', 'leftAlt': '#' }, \ 'ruby': { 'left': '#', 'leftAlt': '=begin', 'rightAlt': '=end' },
\ 'rust': { 'left': '//', 'leftAlt': '///', 'rightAlt': '///' }, \ 'rust': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'sa': { 'left': '--' }, \ 'sa': { 'left': '--' },
\ 'samba': { 'left': ';', 'leftAlt': '#' }, \ 'samba': { 'left': ';', 'leftAlt': '#' },
\ 'sass': { 'left': '//', 'leftAlt': '/*' }, \ 'sass': { 'left': '//', 'leftAlt': '/*' },
\ 'sather': { 'left': '--' }, \ 'sather': { 'left': '--' },
\ 'scala': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'scala': { 'left': '//', 'nested': 1, 'leftAlt': '/*', 'rightAlt': '*/', 'nestedAlt': 1 },
\ 'scons': { 'left': '#' }, \ 'scheme': { 'left': ';', 'nested': 1, 'leftAlt': '#|', 'rightAlt': '|#', 'nestedAlt': 1 },
\ 'scheme': { 'left': ';', 'leftAlt': '#|', 'rightAlt': '|#' },
\ 'scilab': { 'left': '//' }, \ 'scilab': { 'left': '//' },
\ 'scons': { 'left': '#' },
\ 'scsh': { 'left': ';' }, \ 'scsh': { 'left': ';' },
\ 'scss': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/'}, \ 'scss': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'sed': { 'left': '#' }, \ 'sed': { 'left': '#' },
\ 'sgmldecl': { 'left': '--', 'right': '--' }, \ 'sgmldecl': { 'left': '--', 'right': '--' },
\ 'sgmllnx': { 'left': '<!--', 'right': '-->' }, \ 'sgmllnx': { 'left': '<!--', 'right': '-->' },
\ 'sh': { 'left': '#' }, \ 'sh': { 'left': '#' },
\ 'shader_test': { 'left': '#' },
\ 'sicad': { 'left': '*' }, \ 'sicad': { 'left': '*' },
\ 'sile': { 'left': '%' }, \ 'sile': { 'left': '%' },
\ 'simula': { 'left': '%', 'leftAlt': '--' }, \ 'simula': { 'left': '%', 'leftAlt': '--' },
@@ -373,7 +391,7 @@ let s:delimiterMap = {
\ 'smarty': { 'left': '{*', 'right': '*}' }, \ 'smarty': { 'left': '{*', 'right': '*}' },
\ 'smil': { 'left': '<!', 'right': '>' }, \ 'smil': { 'left': '<!', 'right': '>' },
\ 'smith': { 'left': ';' }, \ 'smith': { 'left': ';' },
\ 'sml': { 'left': '(*', 'right': '*)' }, \ 'sml': { 'left': '(*', 'right': '*)', 'nested': 1 },
\ 'snippets': { 'left': '#' }, \ 'snippets': { 'left': '#' },
\ 'snnsnet': { 'left': '#' }, \ 'snnsnet': { 'left': '#' },
\ 'snnspat': { 'left': '#' }, \ 'snnspat': { 'left': '#' },
@@ -390,18 +408,20 @@ let s:delimiterMap = {
\ 'sqr': { 'left': '!' }, \ 'sqr': { 'left': '!' },
\ 'squid': { 'left': '#' }, \ 'squid': { 'left': '#' },
\ 'ss': { 'left': ';', 'leftAlt': '#|', 'rightAlt': '|#' }, \ 'ss': { 'left': ';', 'leftAlt': '#|', 'rightAlt': '|#' },
\ 'sshconfig': { 'left': '#' },
\ 'sshdconfig': { 'left': '#' }, \ 'sshdconfig': { 'left': '#' },
\ 'st': { 'left': '"' }, \ 'st': { 'left': '"' },
\ 'stan': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'stan': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'stp': { 'left': '/*','right': '*/', 'leftAlt': '//' }, \ 'stp': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
\ 'swift': { 'left': '/*','right': '*/', 'leftAlt': '//' },
\ 'supercollider': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'supercollider': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'swift': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
\ 'systemverilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'systemverilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'tads': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'tads': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'tags': { 'left': ';' }, \ 'tags': { 'left': ';' },
\ 'tak': { 'left': '$' }, \ 'tak': { 'left': '$' },
\ 'tasm': { 'left': ';' }, \ 'tasm': { 'left': ';' },
\ 'tcl': { 'left': '#' }, \ 'tcl': { 'left': '#' },
\ 'teak': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'terraform': { 'left': '#', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'terraform': { 'left': '#', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'tex': { 'left': '%' }, \ 'tex': { 'left': '%' },
\ 'texinfo': { 'left': "@c " }, \ 'texinfo': { 'left': "@c " },
@@ -415,17 +435,19 @@ let s:delimiterMap = {
\ 'tsalt': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'tsalt': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'tsscl': { 'left': '#' }, \ 'tsscl': { 'left': '#' },
\ 'tssgm': { 'left': "comment = '", 'right': "'" }, \ 'tssgm': { 'left': "comment = '", 'right': "'" },
\ 'ttl': { 'left': '#' },
\ 'tup': { 'left': '#' }, \ 'tup': { 'left': '#' },
\ 'twig': { 'left': '{#', 'right': '#}' },
\ 'txt2tags': { 'left': '%' }, \ 'txt2tags': { 'left': '%' },
\ 'typescript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'typescript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'twig': { 'left': '{#', 'right': '#}' },
\ 'uc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'uc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'uil': { 'left': '!' }, \ 'uil': { 'left': '!' },
\ 'upstart': { 'left': '#' }, \ 'upstart': { 'left': '#' },
\ 'vala': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'vala': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'vasp': { 'left': '!' },
\ 'vb': { 'left': "'" }, \ 'vb': { 'left': "'" },
\ 'velocity': { 'left': "##", 'right': "", 'leftAlt': '#*', 'rightAlt': '*#' }, \ 'velocity': { 'left': "##", 'right': "", 'leftAlt': '#*', 'rightAlt': '*#' },
\ 'vera': { 'left': '/*','right': '*/', 'leftAlt': '//' }, \ 'vera': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
\ 'verilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'verilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'verilog_systemverilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'verilog_systemverilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'vgrindefs': { 'left': '#' }, \ 'vgrindefs': { 'left': '#' },
@@ -436,7 +458,7 @@ let s:delimiterMap = {
\ 'vsejcl': { 'left': '/*' }, \ 'vsejcl': { 'left': '/*' },
\ 'webmacro': { 'left': '##' }, \ 'webmacro': { 'left': '##' },
\ 'wget': { 'left': '#' }, \ 'wget': { 'left': '#' },
\ 'Wikipedia': { 'left': '<!--', 'right': '-->' }, \ 'wikipedia': { 'left': '<!--', 'right': '-->' },
\ 'winbatch': { 'left': ';' }, \ 'winbatch': { 'left': ';' },
\ 'wml': { 'left': '#' }, \ 'wml': { 'left': '#' },
\ 'wvdial': { 'left': ';' }, \ 'wvdial': { 'left': ';' },
@@ -505,6 +527,17 @@ function s:SetUpForNewFiletype(filetype, forceReset)
let b:NERDCommenterDelims[i] = '' let b:NERDCommenterDelims[i] = ''
endif endif
endfor 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 else
let b:NERDCommenterDelims = s:CreateDelimMapFromCms() let b:NERDCommenterDelims = s:CreateDelimMapFromCms()
endif endif
@@ -524,8 +557,10 @@ function s:CreateDelimMapFromCms()
return { return {
\ 'left': substitute(&commentstring, '\([^ \t]*\)\s*%s.*', '\1', ''), \ 'left': substitute(&commentstring, '\([^ \t]*\)\s*%s.*', '\1', ''),
\ 'right': substitute(&commentstring, '.*%s\s*\(.*\)', '\1', 'g'), \ 'right': substitute(&commentstring, '.*%s\s*\(.*\)', '\1', 'g'),
\ 'nested': 0,
\ 'leftAlt': '', \ 'leftAlt': '',
\ 'rightAlt': '' } \ 'rightAlt': '',
\ 'nestedAlt': 0}
endfunction endfunction
" Function: s:SwitchToAlternativeDelimiters(printMsgs) function {{{2 " Function: s:SwitchToAlternativeDelimiters(printMsgs) function {{{2
@@ -538,6 +573,9 @@ endfunction
" -printMsgs: if this is 1 then a message is echoed to the user telling them " -printMsgs: if this is 1 then a message is echoed to the user telling them
" if this function changed the delimiters or not " if this function changed the delimiters or not
function s:SwitchToAlternativeDelimiters(printMsgs) 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 "if both of the alternative delimiters are empty then there is no
"alternative comment style so bail out "alternative comment style so bail out
if b:NERDCommenterDelims['leftAlt'] == '' && b:NERDCommenterDelims['rightAlt'] == '' if b:NERDCommenterDelims['leftAlt'] == '' && b:NERDCommenterDelims['rightAlt'] == ''
@@ -550,20 +588,28 @@ function s:SwitchToAlternativeDelimiters(printMsgs)
"save the current delimiters "save the current delimiters
let tempLeft = s:Left() let tempLeft = s:Left()
let tempRight = s:Right() let tempRight = s:Right()
let tempNested = s:Nested()
"swap current delimiters for alternative "swap current delimiters for alternative
let b:NERDCommenterDelims['left'] = b:NERDCommenterDelims['leftAlt'] let b:NERDCommenterDelims['left'] = b:NERDCommenterDelims['leftAlt']
let b:NERDCommenterDelims['right'] = b:NERDCommenterDelims['rightAlt'] 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 "set the previously current delimiters to be the new alternative ones
let b:NERDCommenterDelims['leftAlt'] = tempLeft let b:NERDCommenterDelims['leftAlt'] = tempLeft
let b:NERDCommenterDelims['rightAlt'] = tempRight let b:NERDCommenterDelims['rightAlt'] = tempRight
let b:NERDCommenterDelims['nestedAlt'] = tempNested
"tell the user what comment delimiters they are now using "tell the user what comment delimiters they are now using
if a:printMsgs if a:printMsgs
call s:NerdEcho("Now using " . s:Left() . " " . s:Right() . " to delimit comments", 1) call s:NerdEcho("Now using " . s:Left() . " " . s:Right() . " to delimit comments", 1)
endif endif
if exists('*NERDCommenter_after')
exe "call NERDCommenter_after()"
endif
return 1 return 1
endfunction endfunction
@@ -591,8 +637,10 @@ function s:AppendCommentToLine()
if lenRight > 0 if lenRight > 0
let leftMoveAmount = lenRight - 1 let leftMoveAmount = lenRight - 1
execute ":normal! " . leftMoveAmount . "h" execute ":normal! " . leftMoveAmount . "h"
endif
startinsert startinsert
else
startinsert!
endif
endfunction endfunction
" Function: s:CommentBlock(top, bottom, lSide, rSide, forceNested ) {{{2 " Function: s:CommentBlock(top, bottom, lSide, rSide, forceNested ) {{{2
@@ -713,6 +761,10 @@ function s:CommentBlock(top, bottom, lSide, rSide, forceNested )
let theLine = s:ConvertLeadingSpacesToTabs(theLine) let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif endif
if g:NERDTrimTrailingWhitespace == 1
let theLine = s:TrimTrailingWhitespace(theLine)
endif
call setline(currentLine, theLine) call setline(currentLine, theLine)
endif endif
@@ -755,7 +807,7 @@ function s:CommentLines(forceNested, align, firstLine, lastLine)
if s:CanCommentLine(a:forceNested, currentLine) if s:CanCommentLine(a:forceNested, currentLine)
"if the user has specified forceNesting then we check to see if we "if the user has specified forceNesting then we check to see if we
"need to switch delimiters for place-holders "need to switch delimiters for place-holders
if a:forceNested && g:NERDUsePlaceHolders if a:forceNested && g:NERDUsePlaceHolders && !s:Nested()
let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine) let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine)
endif endif
@@ -783,6 +835,10 @@ function s:CommentLines(forceNested, align, firstLine, lastLine)
let theLine = s:ConvertLeadingSpacesToTabs(theLine) let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif endif
if g:NERDTrimTrailingWhitespace == 1
let theLine = s:TrimTrailingWhitespace(theLine)
endif
" we are done with this line " we are done with this line
call setline(currentLine, theLine) call setline(currentLine, theLine)
let currentLine = currentLine + 1 let currentLine = currentLine + 1
@@ -801,9 +857,11 @@ function s:CommentLinesMinimal(firstLine, lastLine)
throw 'NERDCommenter.Delimiters exception: Minimal comments can only be used for filetypes that have multipart delimiters' throw 'NERDCommenter.Delimiters exception: Minimal comments can only be used for filetypes that have multipart delimiters'
endif endif
let sexyNested = s:SexyNested()
"if we need to use place holders for the comment, make sure they are "if we need to use place holders for the comment, make sure they are
"enabled for this filetype "enabled for this filetype, or the delimiterss allow nesting
if !g:NERDUsePlaceHolders && s:DoesBlockHaveMultipartDelim(a:firstLine, a:lastLine) if !g:NERDUsePlaceHolders && !sexyNested && s:DoesBlockHaveMultipartDelim(a:firstLine, a:lastLine)
throw 'NERDCommenter.Settings exception: Place holders are required but disabled.' throw 'NERDCommenter.Settings exception: Place holders are required but disabled.'
endif endif
@@ -813,6 +871,7 @@ function s:CommentLinesMinimal(firstLine, lastLine)
"make sure all multipart delimiters on the lines are replaced with "make sure all multipart delimiters on the lines are replaced with
"placeholders to prevent illegal syntax "placeholders to prevent illegal syntax
if !sexyNested
let currentLine = a:firstLine let currentLine = a:firstLine
while(currentLine <= a:lastLine) while(currentLine <= a:lastLine)
let theLine = getline(currentLine) let theLine = getline(currentLine)
@@ -820,6 +879,7 @@ function s:CommentLinesMinimal(firstLine, lastLine)
call setline(currentLine, theLine) call setline(currentLine, theLine)
let currentLine = currentLine + 1 let currentLine = currentLine + 1
endwhile endwhile
endif
"add the delimiter to the top line "add the delimiter to the top line
let theLine = getline(a:firstLine) let theLine = getline(a:firstLine)
@@ -839,6 +899,11 @@ function s:CommentLinesMinimal(firstLine, lastLine)
if lineHasLeadingTabs if lineHasLeadingTabs
let theLine = s:ConvertLeadingSpacesToTabs(theLine) let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif endif
if g:NERDTrimTrailingWhitespace == 1
let theLine = s:TrimTrailingWhitespace(theLine)
endif
call setline(a:lastLine, theLine) call setline(a:lastLine, theLine)
endfunction endfunction
@@ -859,7 +924,7 @@ function s:CommentLinesSexy(topline, bottomline)
throw 'NERDCommenter.Delimiters exception: cannot perform sexy comments with available delimiters.' throw 'NERDCommenter.Delimiters exception: cannot perform sexy comments with available delimiters.'
endif 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) if !s:CanSexyCommentLines(a:topline, a:bottomline)
throw 'NERDCommenter.Nesting exception: cannot nest sexy comments' throw 'NERDCommenter.Nesting exception: cannot nest sexy comments'
endif endif
@@ -884,7 +949,9 @@ function s:CommentLinesSexy(topline, bottomline)
if lineHasTabs if lineHasTabs
let theLine = s:ConvertLeadingTabsToSpaces(theLine) let theLine = s:ConvertLeadingTabsToSpaces(theLine)
endif endif
if !s:SexyNested()
let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine) let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine)
endif
let theLine = s:AddLeftDelimAligned(left . spaceString, theLine, leftAlignIndx) let theLine = s:AddLeftDelimAligned(left . spaceString, theLine, leftAlignIndx)
if lineHasTabs if lineHasTabs
let theLine = s:ConvertLeadingSpacesToTabs(theLine) let theLine = s:ConvertLeadingSpacesToTabs(theLine)
@@ -898,8 +965,10 @@ function s:CommentLinesSexy(topline, bottomline)
if lineHasTabs if lineHasTabs
let theLine = s:ConvertLeadingTabsToSpaces(theLine) let theLine = s:ConvertLeadingTabsToSpaces(theLine)
endif endif
if !s:SexyNested()
let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine) let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine)
endif endif
endif
let theLine = s:AddRightDelim(spaceString . right, theLine) let theLine = s:AddRightDelim(spaceString . right, theLine)
if lineHasTabs if lineHasTabs
let theLine = s:ConvertLeadingSpacesToTabs(theLine) let theLine = s:ConvertLeadingSpacesToTabs(theLine)
@@ -943,7 +1012,9 @@ function s:CommentLinesSexy(topline, bottomline)
let theLine = s:ConvertLeadingTabsToSpaces(theLine) let theLine = s:ConvertLeadingTabsToSpaces(theLine)
endif endif
if !s:SexyNested()
let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine) let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine)
endif
" add the sexyComMarker " add the sexyComMarker
let theLine = repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . sexyComMarkerSpaced . strpart(theLine, leftAlignIndx) let theLine = repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . sexyComMarkerSpaced . strpart(theLine, leftAlignIndx)
@@ -952,6 +1023,9 @@ function s:CommentLinesSexy(topline, bottomline)
let theLine = s:ConvertLeadingSpacesToTabs(theLine) let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif endif
if g:NERDTrimTrailingWhitespace == 1
let theLine = s:TrimTrailingWhitespace(theLine)
endif
" set the line and move onto the next one " set the line and move onto the next one
call setline(currentLine, theLine) call setline(currentLine, theLine)
@@ -985,7 +1059,7 @@ function s:CommentLinesToggle(forceNested, firstLine, lastLine)
"if the user has specified forceNesting then we check to see if we "if the user has specified forceNesting then we check to see if we
"need to switch delimiters for place-holders "need to switch delimiters for place-holders
if g:NERDUsePlaceHolders if g:NERDUsePlaceHolders && !s:Nested()
let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine) let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine)
endif endif
@@ -1006,6 +1080,10 @@ function s:CommentLinesToggle(forceNested, firstLine, lastLine)
let theLine = s:ConvertLeadingSpacesToTabs(theLine) let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif endif
if g:NERDTrimTrailingWhitespace == 1
let theLine = s:TrimTrailingWhitespace(theLine)
endif
" we are done with this line " we are done with this line
call setline(currentLine, theLine) call setline(currentLine, theLine)
let currentLine = currentLine + 1 let currentLine = currentLine + 1
@@ -1103,6 +1181,11 @@ function s:InvertComment(firstLine, lastLine)
endwhile endwhile
endfunction 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 " Function: NERDComment(mode, type) function {{{2
" This function is a Wrapper for the main commenting functions " This function is a Wrapper for the main commenting functions
" "
@@ -1113,6 +1196,10 @@ endfunction
" 'Minimal', 'Toggle', 'AlignLeft', 'AlignBoth', 'Comment', " 'Minimal', 'Toggle', 'AlignLeft', 'AlignBoth', 'Comment',
" 'Nested', 'ToEOL', 'Append', 'Insert', 'Uncomment', 'Yank' " 'Nested', 'ToEOL', 'Append', 'Insert', 'Uncomment', 'Yank'
function! NERDComment(mode, type) range function! NERDComment(mode, type) range
if exists('*NERDCommenter_before')
exe "call NERDCommenter_before()"
endif
let isVisual = a:mode =~ '[vsx]' let isVisual = a:mode =~ '[vsx]'
if !exists("g:did_load_ftplugin") || g:did_load_ftplugin != 1 if !exists("g:did_load_ftplugin") || g:did_load_ftplugin != 1
@@ -1217,6 +1304,11 @@ function! NERDComment(mode, type) range
else else
silent! call repeat#set("\<Plug>NERDCommenter". a:type) silent! call repeat#set("\<Plug>NERDCommenter". a:type)
endif endif
if exists('*NERDCommenter_after')
exe "call NERDCommenter_after()"
endif
endfunction endfunction
" Function: s:PlaceDelimitersAndInsBetween() function {{{2 " Function: s:PlaceDelimitersAndInsBetween() function {{{2
@@ -1305,13 +1397,13 @@ function s:RemoveDelimiters(left, right, line)
endif endif
"look for the right delimiter, if we find it, remove it "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 if rightIndx != -1
let line = strpart(line, 0, rightIndx) . strpart(line, rightIndx+lenRight) let line = strpart(line, 0, rightIndx) . strpart(line, rightIndx+lenRight)
"if the user has specified that there is a space before the right delimiter "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 "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) let line = strpart(line, 0, rightIndx-s:lenSpaceStr) . strpart(line, rightIndx)
endif endif
endif endif
@@ -1364,6 +1456,15 @@ function s:RecoverStateAfterLineComment(state)
endif endif
endfunction 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 " Function: s:UncommentLines(topLine, bottomLine) {{{2
" This function uncomments the given lines " This function uncomments the given lines
" "
@@ -1456,6 +1557,10 @@ function s:UncommentLinesSexy(topline, bottomline)
let theLine = s:ConvertLeadingWhiteSpace(theLine) let theLine = s:ConvertLeadingWhiteSpace(theLine)
if g:NERDTrimTrailingWhitespace == 1
let theLine = s:TrimTrailingWhitespace(theLine)
endif
" move onto the next line " move onto the next line
call setline(currentLine, theLine) call setline(currentLine, theLine)
let currentLine = currentLine + 1 let currentLine = currentLine + 1
@@ -1525,6 +1630,16 @@ function s:UncommentLinesSexy(topline, bottomline)
let theLine = s:SwapOuterPlaceHoldersForMultiPartDelims(theLine) let theLine = s:SwapOuterPlaceHoldersForMultiPartDelims(theLine)
call setline(bottomline, theLine) call setline(bottomline, theLine)
endif 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 endfunction
" Function: s:UncommentLineNormal(line) {{{2 " Function: s:UncommentLineNormal(line) {{{2
@@ -1537,8 +1652,8 @@ function s:UncommentLineNormal(line)
"get the positions of all delimiter types on the line "get the positions of all delimiter types on the line
let indxLeft = s:FindDelimiterIndex(s:Left(), line) let indxLeft = s:FindDelimiterIndex(s:Left(), line)
let indxLeftAlt = s:FindDelimiterIndex(s:Left({'alt': 1}), line) let indxLeftAlt = s:FindDelimiterIndex(s:Left({'alt': 1}), line)
let indxRight = s:FindDelimiterIndex(s:Right(), line) let indxRight = s:LastIndexOfDelim(s:Right(), line)
let indxRightAlt = s:FindDelimiterIndex(s:Right({'alt': 1}), line) let indxRightAlt = s:LastIndexOfDelim(s:Right({'alt': 1}), line)
"get the comment status on the line so we know how it is commented "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) let lineCommentStatus = s:IsCommentedOutermost(s:Left(), s:Right(), s:Left({'alt': 1}), s:Right({'alt': 1}), line)
@@ -1597,6 +1712,10 @@ function s:UncommentLineNormal(line)
let line = s:ConvertLeadingWhiteSpace(line) let line = s:ConvertLeadingWhiteSpace(line)
if g:NERDTrimTrailingWhitespace == 1
let line = s:TrimTrailingWhitespace(line)
endif
return line return line
endfunction endfunction
@@ -1671,6 +1790,12 @@ function s:AltMultipart()
return b:NERDCommenterDelims['rightAlt'] != '' return b:NERDCommenterDelims['rightAlt'] != ''
endfunction 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 " Function: s:CanCommentLine(forceNested, line) {{{2
"This function is used to determine whether the given line can be commented. "This function is used to determine whether the given line can be commented.
"It returns 1 if it can be and 0 otherwise "It returns 1 if it can be and 0 otherwise
@@ -1701,7 +1826,7 @@ function s:CanCommentLine(forceNested, lineNum)
endif endif
"if the line is commented but nesting is allowed then return true "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 return 1
endif endif
@@ -1723,6 +1848,11 @@ endfunction
" Return: 1 if the given lines can be commented sexually, 0 otherwise " Return: 1 if the given lines can be commented sexually, 0 otherwise
function s:CanSexyCommentLines(topline, bottomline) function s:CanSexyCommentLines(topline, bottomline)
" see if the selected regions have any sexy comments " 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 let currentLine = a:topline
while(currentLine <= a:bottomline) while(currentLine <= a:bottomline)
if s:IsInSexyComment(currentLine) if s:IsInSexyComment(currentLine)
@@ -1744,8 +1874,9 @@ function s:CanToggleCommentLine(forceNested, lineNum)
return 0 return 0
endif endif
" make sure we don't comment lines that are just spaces or tabs or empty. " make sure we don't comment lines that are just spaces or tabs or empty,
if theLine =~ "^[ \t]*$" " unless configured otherwise
if g:NERDCommentEmptyLines == 0 && theLine =~ "^[ \t]*$"
return 0 return 0
endif endif
@@ -2056,6 +2187,29 @@ function s:GetSexyComMarker(space, esc)
return sexyComMarker return sexyComMarker
endfunction 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 " Function: s:GetSexyComLeft(space, esc) {{{2
" Returns the left delimiter for sexy comments for this filetype or -1 if " Returns the left delimiter for sexy comments for this filetype or -1 if
" there is none. C style sexy comments are used if possible " there is none. C style sexy comments are used if possible
@@ -2183,7 +2337,7 @@ endfunction
" -left/right: the left and right delimiters to check for " -left/right: the left and right delimiters to check for
function s:IsCommented(left, right, line) function s:IsCommented(left, right, line)
"if the line isn't commented return true "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 return 1
endif endif
return 0 return 0
@@ -2407,7 +2561,7 @@ function s:IsSexyComment(topline, bottomline)
endif endif
"if there is a right delimiter on the top line then this isn't a sexy comment "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 return 0
endif endif
@@ -2436,7 +2590,7 @@ function s:IsSexyComment(topline, bottomline)
"if there is a right delimiter in an intermediate line then the block isn't "if there is a right delimiter in an intermediate line then the block isn't
"a sexy comment "a sexy comment
if s:FindDelimiterIndex(right, theLine) != -1 if s:LastIndexOfDelim(right, theLine) != -1
return 0 return 0
endif endif
@@ -2573,6 +2727,12 @@ function s:NerdEcho(msg, typeOfMsg)
endif endif
endfunction 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 " Function: s:NumberOfLeadingTabs(s) {{{2
" returns the number of leading tabs in the given string " returns the number of leading tabs in the given string
function s:NumberOfLeadingTabs(s) function s:NumberOfLeadingTabs(s)