mirror of
https://github.com/preservim/nerdcommenter.git
synced 2025-11-08 09:53:47 -05:00
Compare commits
346 Commits
2.2.2
...
houl-autol
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0d58015ca | ||
|
|
c888c82828 | ||
|
|
20f9e88395 | ||
|
|
17b68e47d7 | ||
|
|
67950d4b5d | ||
|
|
f46226bcd6 | ||
|
|
5100f47542 | ||
|
|
5ac43900e9 | ||
|
|
3427b2f4ef | ||
|
|
371e4d0e09 | ||
|
|
d24868bc85 | ||
|
|
fdf950f20b | ||
|
|
f9dd87271a | ||
|
|
9a32fd2534 | ||
|
|
e679d8a341 | ||
|
|
8718240a51 | ||
|
|
670dba1bb5 | ||
|
|
2f973bd4fa | ||
|
|
ff3d8d7d7c | ||
|
|
af8bb4258d | ||
|
|
f18bb5b223 | ||
|
|
fd61bc71f6 | ||
|
|
3e99b39f4f | ||
|
|
09b07d50ba | ||
|
|
013cfec44d | ||
|
|
d4548ebb0c | ||
|
|
c321b3460b | ||
|
|
9d1b1d5827 | ||
|
|
14004e00e0 | ||
|
|
c5bf6053f3 | ||
|
|
5fce03e259 | ||
|
|
63ba1a1123 | ||
|
|
376838672d | ||
|
|
e935614365 | ||
|
|
285902752f | ||
|
|
d1ac2382b2 | ||
|
|
9b5b930b72 | ||
|
|
a6b3cc6842 | ||
|
|
d05cfd190b | ||
|
|
0e1f6f6866 | ||
|
|
41e686824a | ||
|
|
59552f2e88 | ||
|
|
c5f8cbf70d | ||
|
|
607253203d | ||
|
|
398a3e22a4 | ||
|
|
b4827d552e | ||
|
|
0b2a2b0641 | ||
|
|
cb8527ed3f | ||
|
|
032143ad23 | ||
|
|
f5571fd82f | ||
|
|
3ebd9b56ff | ||
|
|
80eb7ff3fd | ||
|
|
18cfe81550 | ||
|
|
057f6150bd | ||
|
|
ecdde217c0 | ||
|
|
e1af5dae7d | ||
|
|
97cb982f1f | ||
|
|
3d13266034 | ||
|
|
c51f5992b2 | ||
|
|
fdc611c8f4 | ||
|
|
45689b2356 | ||
|
|
c3d6a2069b | ||
|
|
ec0f4753d0 | ||
|
|
e2d47bec26 | ||
|
|
e1aeec12be | ||
|
|
06c3184b2e | ||
|
|
ce414bf622 | ||
|
|
dde288a9cc | ||
|
|
7f07dcde28 | ||
|
|
63bd306a7e | ||
|
|
df647acefc | ||
|
|
e48cc752f3 | ||
|
|
4760e57514 | ||
|
|
c3afedbe22 | ||
|
|
e91be123f0 | ||
|
|
8291af4c7c | ||
|
|
6af02e1442 | ||
|
|
9425289459 | ||
|
|
9e8410e1b9 | ||
|
|
d59f0b614f | ||
|
|
1158546091 | ||
|
|
0cbbcb5674 | ||
|
|
ff0b875c8d | ||
|
|
e0c4a25696 | ||
|
|
00e9729661 | ||
|
|
1d07874610 | ||
|
|
560d7f0f77 | ||
|
|
0a186faad1 | ||
|
|
32cd2b9362 | ||
|
|
821fa9ad9e | ||
|
|
264be25aa1 | ||
|
|
ec802fe1d3 | ||
|
|
c2fc065b33 | ||
|
|
2b3714bff6 | ||
|
|
45d94964ba | ||
|
|
dad084190d | ||
|
|
917bc892dc | ||
|
|
dcd63ec026 | ||
|
|
ef692d5a91 | ||
|
|
887232b8fe | ||
|
|
9b86e000f2 | ||
|
|
a5b5caff08 | ||
|
|
08689c3f5c | ||
|
|
1d4e02c670 | ||
|
|
38d77f64cf | ||
|
|
4ebe5a9c5c | ||
|
|
90315ecf20 | ||
|
|
902837e2b1 | ||
|
|
247421c0ba | ||
|
|
81d0709db4 | ||
|
|
e482d8a9c4 | ||
|
|
a6f2bc084a | ||
|
|
6d97fbbd16 | ||
|
|
bfd80feb6f | ||
|
|
c3a82f40c2 | ||
|
|
180d46c300 | ||
|
|
b2dca140df | ||
|
|
e6e67e9470 | ||
|
|
bc40eac0c6 | ||
|
|
34e885bb8c | ||
|
|
0efb6c92bc | ||
|
|
cdf903440d | ||
|
|
f129cd81c8 | ||
|
|
3e269b53e4 | ||
|
|
6e6de4e2a4 | ||
|
|
789c248ad4 | ||
|
|
c7f339ee4e | ||
|
|
a7f679d3b8 | ||
|
|
d237cd666d | ||
|
|
6210dfa635 | ||
|
|
27108c45bc | ||
|
|
00592883c1 | ||
|
|
a458fcc036 | ||
|
|
8c9ae8c1ac | ||
|
|
e5b202fd43 | ||
|
|
88ef57e098 | ||
|
|
d9f96ceaf3 | ||
|
|
a35f1ebd0b | ||
|
|
f26ec29dd4 | ||
|
|
969219e62b | ||
|
|
2d702c9619 | ||
|
|
d672296a34 | ||
|
|
0d1fd7ff66 | ||
|
|
e5b0235247 | ||
|
|
cb98e173e7 | ||
|
|
5c61776994 | ||
|
|
4fc52fd698 | ||
|
|
7e75415e4d | ||
|
|
7bc40e53c0 | ||
|
|
d5b14f2c51 | ||
|
|
8d3dcc26a6 | ||
|
|
34e0115ffa | ||
|
|
60bd8664ba | ||
|
|
ca46be883e | ||
|
|
76afa5ba37 | ||
|
|
d1de6136ba | ||
|
|
94ecc6c282 | ||
|
|
668c8a7336 | ||
|
|
8fd8e9599f | ||
|
|
40007efa1a | ||
|
|
92de964f61 | ||
|
|
94bc2d62c6 | ||
|
|
40c4c66f7a | ||
|
|
1f4bfd5992 | ||
|
|
0bbb2da023 | ||
|
|
a3030b9625 | ||
|
|
05de4871ce | ||
|
|
534329d1b8 | ||
|
|
5cc672a4f2 | ||
|
|
cf4912d36c | ||
|
|
6bdeaaa3d4 | ||
|
|
3a60b6b1ec | ||
|
|
6591d08b24 | ||
|
|
776f69e684 | ||
|
|
2bffc66a42 | ||
|
|
e1029104f1 | ||
|
|
d4f41d2697 | ||
|
|
dbe8023a70 | ||
|
|
536779375d | ||
|
|
59c79279b5 | ||
|
|
1b62184305 | ||
|
|
6549cfde45 | ||
|
|
f1a23cde6d | ||
|
|
956431914f | ||
|
|
f5fba7c6c0 | ||
|
|
d4858b5c5b | ||
|
|
e107ccc9b3 | ||
|
|
785386db76 | ||
|
|
8c73eef0ea | ||
|
|
8c525a27aa | ||
|
|
1f06d8a4dd | ||
|
|
26558db9f1 | ||
|
|
289d2d64ec | ||
|
|
8fff061222 | ||
|
|
c73514084a | ||
|
|
4b049b83fa | ||
|
|
fbe3bd3c35 | ||
|
|
f234d01408 | ||
|
|
7770913088 | ||
|
|
785026abef | ||
|
|
58e34664d2 | ||
|
|
4f3d9c0e12 | ||
|
|
0c04654498 | ||
|
|
5724385b2f | ||
|
|
0b3d928dce | ||
|
|
00e41958df | ||
|
|
ab1fe7f5f0 | ||
|
|
c3756d1ecc | ||
|
|
8cf43a4057 | ||
|
|
7b127e63aa | ||
|
|
6983efa244 | ||
|
|
eb5720c365 | ||
|
|
fa7c2cdc2a | ||
|
|
f87a5f4b51 | ||
|
|
362f6706c6 | ||
|
|
f6137c7fc8 | ||
|
|
b660938045 | ||
|
|
1eb2eba5d3 | ||
|
|
06cf7e7c38 | ||
|
|
8f6abbe22a | ||
|
|
e5f6111856 | ||
|
|
f4b1a46a41 | ||
|
|
17168b0d61 | ||
|
|
4c03b5ac3f | ||
|
|
e983cf27e7 | ||
|
|
baa453aad8 | ||
|
|
7d49ac038d | ||
|
|
d64d909c9e | ||
|
|
27979e7194 | ||
|
|
fc04e4e8c1 | ||
|
|
ed45f9211b | ||
|
|
21222675c7 | ||
|
|
6f69cbcdd8 | ||
|
|
12b15e9804 | ||
|
|
7b78a83120 | ||
|
|
1671f8aa71 | ||
|
|
6e020aa61c | ||
|
|
2eecb5b6f2 | ||
|
|
2f62560dd6 | ||
|
|
d16e2ab1cf | ||
|
|
e2e786c59f | ||
|
|
cb242a9cb4 | ||
|
|
bfa37cdb8b | ||
|
|
68d496339a | ||
|
|
1b6058a597 | ||
|
|
cef3a9ce39 | ||
|
|
4afef1116c | ||
|
|
57ffc642e1 | ||
|
|
73b3fe939c | ||
|
|
69c5335553 | ||
|
|
f6a3b192b8 | ||
|
|
fc1988e573 | ||
|
|
93cdbafd7f | ||
|
|
20e089f6b9 | ||
|
|
4dd72ab0af | ||
|
|
ddb2952fdc | ||
|
|
98cec44ef6 | ||
|
|
86f4d493d9 | ||
|
|
f4d9f99f67 | ||
|
|
8f2af9a6d7 | ||
|
|
006a151a43 | ||
|
|
0c75ae7e7b | ||
|
|
27580f8777 | ||
|
|
fb4df3e71b | ||
|
|
0fe4938d22 | ||
|
|
63bf3811ce | ||
|
|
2c3409d97f | ||
|
|
95d04c69a2 | ||
|
|
785ad99c0b | ||
|
|
0bffc1a119 | ||
|
|
5dc223d8a6 | ||
|
|
f198e9ffce | ||
|
|
22e798edf5 | ||
|
|
a3ecc6dab5 | ||
|
|
754d5a5b2e | ||
|
|
e777829d34 | ||
|
|
d4a5479c2c | ||
|
|
68cfa2f3c5 | ||
|
|
0bb5f7e889 | ||
|
|
9b9c253680 | ||
|
|
1d40b1965c | ||
|
|
b141adda9e | ||
|
|
e5b158fe75 | ||
|
|
4a91777538 | ||
|
|
d5fed4daff | ||
|
|
a346df98e7 | ||
|
|
0a30bbe20c | ||
|
|
b28e7be632 | ||
|
|
cdb6db91cc | ||
|
|
1b78f253c2 | ||
|
|
5a9371437f | ||
|
|
ecb2715965 | ||
|
|
c83ec79110 | ||
|
|
6bd08739c1 | ||
|
|
37f684dbe8 | ||
|
|
b9e907d8fb | ||
|
|
4e5456522d | ||
|
|
d541c7d9b1 | ||
|
|
f98f73221c | ||
|
|
cb7bdd553a | ||
|
|
afe8d0d3fe | ||
|
|
38630ff5eb | ||
|
|
27b0ebe8d6 | ||
|
|
b4d04f36c5 | ||
|
|
3df2ca5285 | ||
|
|
c8d8318257 | ||
|
|
94cce2cc54 | ||
|
|
63b252ad40 | ||
|
|
2b60d872ba | ||
|
|
5dcab6ec82 | ||
|
|
0bcdac6c38 | ||
|
|
5084aa7653 | ||
|
|
69a575e70a | ||
|
|
197ce731be | ||
|
|
f8be02f10a | ||
|
|
90cf828ac0 | ||
|
|
9f955640ee | ||
|
|
47d9833740 | ||
|
|
1577f77ef4 | ||
|
|
17141e2244 | ||
|
|
29f8ebc7f5 | ||
|
|
ca6c791114 | ||
|
|
760df35273 | ||
|
|
591dd3e1fd | ||
|
|
4447e9e6e8 | ||
|
|
24c68a6852 | ||
|
|
ecf20b005c | ||
|
|
59094ae107 | ||
|
|
dc55b10bd7 | ||
|
|
8ef3473c2e | ||
|
|
8ed440ea20 | ||
|
|
930be32a23 | ||
|
|
d54bcbfc98 | ||
|
|
33e3ace742 | ||
|
|
c0d7109c6b | ||
|
|
5c9359d3cf | ||
|
|
02c726c6d1 | ||
|
|
d868eae71b | ||
|
|
e0191f2ce9 | ||
|
|
cea72da179 | ||
|
|
9c8343c939 | ||
|
|
a1b4c3b94a | ||
|
|
4d933f01d6 | ||
|
|
bca88e735b | ||
|
|
5d42b2ec5c | ||
|
|
ae430a62fc |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
*~
|
||||
*.swp
|
||||
tags
|
||||
|
||||
159
README.md
Normal file
159
README.md
Normal file
@@ -0,0 +1,159 @@
|
||||
# NERD Commenter
|
||||
|
||||
Comment functions so powerful—no comment necessary.
|
||||
|
||||
## Installation
|
||||
|
||||
### Via Plugin Manager (Recommended)
|
||||
|
||||
#### [Vim-Plug](https://github.com/junegunn/vim-plug)
|
||||
|
||||
1. Add `Plug 'scrooloose/nerdcommenter'` to your vimrc file.
|
||||
2. Reload your vimrc or restart
|
||||
3. Run `:PlugInstall`
|
||||
|
||||
#### [Vundle](https://github.com/VundleVim/Vundle.vim) or similar
|
||||
|
||||
1. Add `Plugin 'scrooloose/nerdcommenter'` to your vimrc file.
|
||||
2. Reload your vimrc or restart
|
||||
3. Run `:BundleInstall`
|
||||
|
||||
#### [NeoBundle](https://github.com/Shougo/neobundle.vim)
|
||||
|
||||
1. Add `NeoBundle 'scrooloose/nerdcommenter'` to your vimrc file.
|
||||
2. Reload your vimrc or restart
|
||||
3. Run `:NeoUpdate`
|
||||
|
||||
#### [Pathogen](https://github.com/tpope/vim-pathogen)
|
||||
|
||||
```sh
|
||||
cd ~/.vim/bundle
|
||||
git clone https://github.com/scrooloose/nerdcommenter.git
|
||||
```
|
||||
|
||||
### Manual Installation
|
||||
|
||||
#### Unix
|
||||
|
||||
(For Neovim, change `~/.vim/` to `~/.config/nvim/`.)
|
||||
|
||||
```sh
|
||||
curl -fLo ~/.vim/plugin/NERD_Commenter.vim --create-dirs \
|
||||
https://raw.githubusercontent.com/scrooloose/nerdcommenter/master/plugin/NERD_commenter.vim
|
||||
curl -fLo ~/.vim/doc/NERD_Commenter.txt --create-dirs \
|
||||
https://raw.githubusercontent.com/scrooloose/nerdcommenter/master/doc/NERD_commenter.txt
|
||||
```
|
||||
|
||||
#### Windows (PowerShell)
|
||||
|
||||
```powershell
|
||||
md ~\vimfiles\plugin
|
||||
md ~\vimfiles\doc
|
||||
$pluguri = 'https://raw.githubusercontent.com/scrooloose/nerdcommenter/master/plugin/NERD_commenter.vim'
|
||||
$docsuri = 'https://raw.githubusercontent.com/scrooloose/nerdcommenter/master/doc/NERD_commenter.txt'
|
||||
(New-Object Net.WebClient).DownloadFile($pluguri, $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("~\vimfiles\plugin\NERD_commenter.vim"))
|
||||
(New-Object Net.WebClient).DownloadFile($docsuri, $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("~\vimfiles\doc\NERD_commenter.txt"))
|
||||
```
|
||||
|
||||
### Post Installation
|
||||
|
||||
Make sure that you have filetype plugins enabled, as the plugin makes use of **|commentstring|** where possible (which is usually set in a filetype plugin). See **|filetype-plugin-on|** for details, but the short version is make sure this line appears in your vimrc:
|
||||
|
||||
```sh
|
||||
filetype plugin on
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Documentation
|
||||
|
||||
Please see the vim help system for full documentation of all options: `:help nerdcommenter`
|
||||
|
||||
### Settings
|
||||
|
||||
Several settings can be added to your vimrc to change the default behavior. Some examples:
|
||||
|
||||
```vim
|
||||
" Add spaces after comment delimiters by default
|
||||
let g:NERDSpaceDelims = 1
|
||||
|
||||
" Use compact syntax for prettified multi-line comments
|
||||
let g:NERDCompactSexyComs = 1
|
||||
|
||||
" Align line-wise comment delimiters flush left instead of following code indentation
|
||||
let g:NERDDefaultAlign = 'left'
|
||||
|
||||
" Set a language to use its alternate delimiters by default
|
||||
let g:NERDAltDelims_java = 1
|
||||
|
||||
" Add your own custom formats or override the defaults
|
||||
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }
|
||||
|
||||
" Allow commenting and inverting empty lines (useful when commenting a region)
|
||||
let g:NERDCommentEmptyLines = 1
|
||||
|
||||
" Enable trimming of trailing whitespace when uncommenting
|
||||
let g:NERDTrimTrailingWhitespace = 1
|
||||
|
||||
" Enable NERDCommenterToggle to check all selected lines is commented or not
|
||||
let g:NERDToggleCheckAllLines = 1
|
||||
```
|
||||
|
||||
### Default mappings
|
||||
|
||||
The following key mappings are provided by default (there is also a menu provided that contains menu items corresponding to all the below mappings):
|
||||
|
||||
Most of the following mappings are for normal/visual mode only. The **|NERDComInsertComment|** mapping is for insert mode only.
|
||||
|
||||
* `[count]<leader>cc` **|NERDComComment|**
|
||||
|
||||
Comment out the current line or text selected in visual mode.
|
||||
|
||||
* `[count]<leader>cn` **|NERDComNestedComment|**
|
||||
|
||||
Same as <leader>cc but forces nesting.
|
||||
|
||||
* `[count]<leader>c<space>` **|NERDComToggleComment|**
|
||||
|
||||
Toggles the comment state of the selected line(s). If the topmost selected line is commented, all selected lines are uncommented and vice versa.
|
||||
|
||||
* `[count]<leader>cm` **|NERDComMinimalComment|**
|
||||
|
||||
Comments the given lines using only one set of multipart delimiters.
|
||||
|
||||
* `[count]<leader>ci` **|NERDComInvertComment|**
|
||||
|
||||
Toggles the comment state of the selected line(s) individually.
|
||||
|
||||
* `[count]<leader>cs` **|NERDComSexyComment|**
|
||||
|
||||
Comments out the selected lines with a pretty block formatted layout.
|
||||
|
||||
* `[count]<leader>cy` **|NERDComYankComment|**
|
||||
|
||||
Same as <leader>cc except that the commented line(s) are yanked first.
|
||||
|
||||
* `<leader>c$` **|NERDComEOLComment|**
|
||||
|
||||
Comments the current line from the cursor to the end of line.
|
||||
|
||||
* `<leader>cA` **|NERDComAppendComment|**
|
||||
|
||||
Adds comment delimiters to the end of line and goes into insert mode between them.
|
||||
|
||||
* **|NERDComInsertComment|**
|
||||
|
||||
Adds comment delimiters at the current cursor position and inserts between. Disabled by default.
|
||||
|
||||
* `<leader>ca` **|NERDComAltDelim|**
|
||||
|
||||
Switches to the alternative set of delimiters.
|
||||
|
||||
* `[count]<leader>cl`
|
||||
`[count]<leader>cb` **|NERDComAlignedComment|**
|
||||
|
||||
Same as **|NERDComComment|** except that the delimiters are aligned down the left side (`<leader>cl`) or both sides (`<leader>cb`).
|
||||
|
||||
* `[count]<leader>cu` **|NERDComUncommentLine|**
|
||||
|
||||
Uncomments the selected line(s).
|
||||
80
Rakefile
80
Rakefile
@@ -1,18 +1,76 @@
|
||||
desc "Copy the vim/doc files into ~/.vim"
|
||||
task :deploy_local do
|
||||
run "cp plugin/NERD_commenter.vim ~/.vim/plugin"
|
||||
run "cp doc/NERD_commenter.txt ~/.vim/doc"
|
||||
end
|
||||
# written by travis jeffery <travisjeffery@gmail.com>
|
||||
# contributions by scrooloose <github:scrooloose>
|
||||
|
||||
require 'rake'
|
||||
require 'find'
|
||||
require 'pathname'
|
||||
|
||||
desc "Create a zip archive for release to vim.org"
|
||||
IGNORE = [/\.gitignore$/, /Rakefile$/]
|
||||
|
||||
files = `git ls-files`.split("\n")
|
||||
files.reject! { |f| IGNORE.any? { |re| f.match(re) } }
|
||||
|
||||
desc 'Zip up the project files'
|
||||
task :zip do
|
||||
abort "NERD_commenter.zip already exists, aborting" if File.exist?("NERD_commenter.zip")
|
||||
run "zip NERD_commenter.zip plugin/NERD_commenter.vim doc/NERD_commenter.txt"
|
||||
zip_name = File.basename(File.dirname(__FILE__))
|
||||
zip_name.gsub!(/ /, '_')
|
||||
zip_name = "#{zip_name}.zip"
|
||||
|
||||
if File.exist?(zip_name)
|
||||
abort("Zip file #{zip_name} already exists. Remove it first.")
|
||||
end
|
||||
|
||||
puts "Creating zip file: #{zip_name}"
|
||||
system("zip #{zip_name} #{files.join(" ")}")
|
||||
end
|
||||
|
||||
def run(cmd)
|
||||
puts "Executing: #{cmd}"
|
||||
system cmd
|
||||
desc 'Install plugin and documentation'
|
||||
task :install do
|
||||
vimfiles = if ENV['VIMFILES']
|
||||
ENV['VIMFILES']
|
||||
elsif RUBY_PLATFORM =~ /(win|w)32$/
|
||||
File.expand_path("~/vimfiles")
|
||||
else
|
||||
File.expand_path("~/.vim")
|
||||
end
|
||||
files.each do |file|
|
||||
target_file = File.join(vimfiles, file)
|
||||
FileUtils.mkdir_p File.dirname(target_file)
|
||||
FileUtils.cp file, target_file
|
||||
|
||||
puts "Installed #{file} to #{target_file}"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
desc 'Pulls from origin'
|
||||
task :pull do
|
||||
puts "Updating local repo..."
|
||||
system("cd " << Dir.new(File.dirname(__FILE__)).path << " && git pull")
|
||||
end
|
||||
|
||||
desc 'Calls pull task and then install task'
|
||||
task :update => ['pull', 'install'] do
|
||||
puts "Update of vim script complete."
|
||||
end
|
||||
|
||||
desc 'Uninstall plugin and documentation'
|
||||
task :uninstall do
|
||||
vimfiles = if ENV['VIMFILES']
|
||||
ENV['VIMFILES']
|
||||
elsif RUBY_PLATFORM =~ /(win|w)32$/
|
||||
File.expand_path("~/vimfiles")
|
||||
else
|
||||
File.expand_path("~/.vim")
|
||||
end
|
||||
files.each do |file|
|
||||
target_file = File.join(vimfiles, file)
|
||||
FileUtils.rm target_file
|
||||
|
||||
puts "Uninstalled #{target_file}"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
task :default => ['update']
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,37 +11,38 @@
|
||||
CONTENTS *NERDCommenterContents*
|
||||
|
||||
1.Intro...................................|NERDCommenter|
|
||||
2.Functionality provided..................|NERDComFunctionality|
|
||||
2.1 Functionality Summary.............|NERDComFunctionalitySummary|
|
||||
2.2 Functionality Details.............|NERDComFunctionalityDetails|
|
||||
2.2.1 Comment map.................|NERDComComment|
|
||||
2.2.2 Nested comment map..........|NERDComNestedComment|
|
||||
2.2.3 Toggle comment map..........|NERDComToggleComment|
|
||||
2.2.4 Minimal comment map.........|NERDComMinimalComment|
|
||||
2.2.5 Invert comment map..........|NERDComInvertComment|
|
||||
2.2.6 Sexy comment map............|NERDComSexyComment|
|
||||
2.2.7 Yank comment map............|NERDComYankComment|
|
||||
2.2.8 Comment to EOL map..........|NERDComEOLComment|
|
||||
2.2.9 Append com to line map......|NERDComAppendComment|
|
||||
2.2.10 Insert comment map.........|NERDComInsertComment|
|
||||
2.2.11 Use alternate delims map...|NERDComAltDelim|
|
||||
2.2.12 Comment aligned maps.......|NERDComAlignedComment|
|
||||
2.2.13 Uncomment line map.........|NERDComUncommentLine|
|
||||
2.3 Supported filetypes...............|NERDComFiletypes|
|
||||
2.4 Sexy Comments.....................|NERDComSexyComments|
|
||||
2.5 The NERDComment function..........|NERDComNERDComment|
|
||||
3.Options.................................|NERDComOptions|
|
||||
3.1 Options summary...................|NERDComOptionsSummary|
|
||||
3.2 Options details...................|NERDComOptionsDetails|
|
||||
3.3 Default delimiter Options.........|NERDComDefaultDelims|
|
||||
4. Customising key mappings...............|NERDComMappings|
|
||||
5. Issues with the script.................|NERDComIssues|
|
||||
5.1 Delimiter detection heuristics....|NERDComHeuristics|
|
||||
5.2 Nesting issues....................|NERDComNesting|
|
||||
6.About.. ............................|NERDComAbout|
|
||||
7.Changelog...............................|NERDComChangelog|
|
||||
8.Credits.................................|NERDComCredits|
|
||||
9.License.................................|NERDComLicense|
|
||||
2.Installation............................|NERDComInstallation|
|
||||
3.Functionality provided..................|NERDComFunctionality|
|
||||
3.1 Functionality Summary.............|NERDComFunctionalitySummary|
|
||||
3.2 Functionality Details.............|NERDComFunctionalityDetails|
|
||||
3.2.1 Comment map.................|NERDComComment|
|
||||
3.2.2 Nested comment map..........|NERDComNestedComment|
|
||||
3.2.3 Toggle comment map..........|NERDComToggleComment|
|
||||
3.2.4 Minimal comment map.........|NERDComMinimalComment|
|
||||
3.2.5 Invert comment map..........|NERDComInvertComment|
|
||||
3.2.6 Sexy comment map............|NERDComSexyComment|
|
||||
3.2.7 Yank comment map............|NERDComYankComment|
|
||||
3.2.8 Comment to EOL map..........|NERDComEOLComment|
|
||||
3.2.9 Append com to line map......|NERDComAppendComment|
|
||||
3.2.10 Insert comment map.........|NERDComInsertComment|
|
||||
3.2.11 Use alternate delims map...|NERDComAltDelim|
|
||||
3.2.12 Comment aligned maps.......|NERDComAlignedComment|
|
||||
3.2.13 Uncomment line map.........|NERDComUncommentLine|
|
||||
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|
|
||||
4.3 Default delimiter Options.........|NERDComDefaultDelims|
|
||||
5. Customising key mappings...............|NERDComMappings|
|
||||
6. Issues with the script.................|NERDComIssues|
|
||||
6.1 Delimiter detection heuristics....|NERDComHeuristics|
|
||||
6.2 Nesting issues....................|NERDComNesting|
|
||||
7.About.. ............................|NERDComAbout|
|
||||
8.Changelog...............................|NERDComChangelog|
|
||||
9.Credits.................................|NERDComCredits|
|
||||
10.License................................|NERDComLicense|
|
||||
|
||||
==============================================================================
|
||||
1. Intro *NERDCommenter*
|
||||
@@ -54,48 +55,69 @@ There are also options that allow to tweak the commenting engine to your
|
||||
taste.
|
||||
|
||||
==============================================================================
|
||||
2. Functionality provided *NERDComFunctionality*
|
||||
2. Installation *NERDComInstallation*
|
||||
|
||||
The NERD Commenter requires Vim 7 or higher.
|
||||
|
||||
Extract the plugin files in your ~/.vim (*nix) or ~/vimfiles (Windows). You
|
||||
should have 2 files: >
|
||||
plugin/NERD_commenter.vim
|
||||
doc/NERD_commenter.txt
|
||||
<
|
||||
Next, to finish installing the help file run: >
|
||||
:helptags ~/.vim/doc
|
||||
<
|
||||
See |add-local-help| for more details.
|
||||
|
||||
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
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
3. Functionality provided *NERDComFunctionality*
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.1 Functionality summary *NERDComFunctionalitySummary*
|
||||
3.1 Functionality summary *NERDComFunctionalitySummary*
|
||||
|
||||
The following key mappings are provided by default (there is also a menu
|
||||
with items corresponding to all the mappings below):
|
||||
|
||||
[count],cc |NERDComComment|
|
||||
[count]|<Leader>|cc |NERDComComment|
|
||||
Comment out the current line or text selected in visual mode.
|
||||
|
||||
|
||||
[count],cn |NERDComNestedComment|
|
||||
Same as ,cc but forces nesting.
|
||||
[count]|<Leader>|cn |NERDComNestedComment|
|
||||
Same as |<Leader>|cc but forces nesting.
|
||||
|
||||
|
||||
[count],c<space> |NERDComToggleComment|
|
||||
[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],cm |NERDComMinimalComment|
|
||||
[count]|<Leader>|cm |NERDComMinimalComment|
|
||||
Comments the given lines using only one set of multipart delimiters.
|
||||
|
||||
|
||||
[count],ci |NERDComInvertComment|
|
||||
[count]|<Leader>|ci |NERDComInvertComment|
|
||||
Toggles the comment state of the selected line(s) individually.
|
||||
|
||||
|
||||
[count],cs |NERDComSexyComment|
|
||||
[count]|<Leader>|cs |NERDComSexyComment|
|
||||
Comments out the selected lines ``sexily''
|
||||
|
||||
|
||||
[count],cy |NERDComYankComment|
|
||||
Same as ,cc except that the commented line(s) are yanked first.
|
||||
[count]|<Leader>|cy |NERDComYankComment|
|
||||
Same as |<Leader>|cc except that the commented line(s) are yanked first.
|
||||
|
||||
|
||||
,c$ |NERDComEOLComment|
|
||||
|<Leader>|c$ |NERDComEOLComment|
|
||||
Comments the current line from the cursor to the end of line.
|
||||
|
||||
|
||||
,cA |NERDComAppendComment|
|
||||
|<Leader>|cA |NERDComAppendComment|
|
||||
Adds comment delimiters to the end of line and goes into insert mode between
|
||||
them.
|
||||
|
||||
@@ -105,26 +127,30 @@ Adds comment delimiters at the current cursor position and inserts between.
|
||||
Disabled by default.
|
||||
|
||||
|
||||
,ca |NERDComAltDelim|
|
||||
|<Leader>|ca |NERDComAltDelim|
|
||||
Switches to the alternative set of delimiters.
|
||||
|
||||
|
||||
[count],cl
|
||||
[count],cb |NERDComAlignedComment|
|
||||
[count]|<Leader>|cl
|
||||
[count]|<Leader>|cb |NERDComAlignedComment|
|
||||
Same as |NERDComComment| except that the delimiters are aligned down the
|
||||
left side (,cl) or both sides (,cb).
|
||||
left side (|<Leader>|cl) or both sides (|<Leader>|cb).
|
||||
|
||||
|
||||
[count],cu |NERDComUncommentLine|
|
||||
[count]|<Leader>|cu |NERDComUncommentLine|
|
||||
Uncomments the selected line(s).
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2 Functionality details *NERDComFunctionalityDetails*
|
||||
|
||||
With the optional repeat.vim plugin (vimscript #2136), the mappings can also
|
||||
be repeated via |.|
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.1 Comment map *NERDComComment*
|
||||
3.2 Functionality details *NERDComFunctionalityDetails*
|
||||
|
||||
Default mapping: [count],cc
|
||||
------------------------------------------------------------------------------
|
||||
3.2.1 Comment map *NERDComComment*
|
||||
|
||||
Default mapping: [count]|<Leader>|cc
|
||||
Mapped to: <plug>NERDCommenterComment
|
||||
Applicable modes: normal visual visual-line visual-block.
|
||||
|
||||
@@ -138,14 +164,14 @@ If a [count] is given in normal mode, the mapping works as though that many
|
||||
lines were selected in visual-line mode.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.2 Nested comment map *NERDComNestedComment*
|
||||
3.2.2 Nested comment map *NERDComNestedComment*
|
||||
|
||||
Default mapping: [count],cn
|
||||
Mapped to: <plug>NERDCommenterNest
|
||||
Default mapping: [count]|<Leader>|cn
|
||||
Mapped to: <plug>NERDCommenterNested
|
||||
Applicable modes: normal visual visual-line visual-block.
|
||||
|
||||
Performs nested commenting. Works the same as ,cc except that if a line is
|
||||
already commented then it will be commented again.
|
||||
Performs nested commenting. Works the same as |<Leader>|cc except that if a line
|
||||
is already commented then it will be commented again.
|
||||
|
||||
If |'NERDUsePlaceHolders'| is set then the previous comment delimiters will
|
||||
be replaced by place-holder delimiters if needed. Otherwise the nested
|
||||
@@ -159,9 +185,9 @@ Related options:
|
||||
|'NERDDefaultNesting'|
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.3 Toggle comment map *NERDComToggleComment*
|
||||
3.2.3 Toggle comment map *NERDComToggleComment*
|
||||
|
||||
Default mapping: [count],c<space>
|
||||
Default mapping: [count]|<Leader>|c<space>
|
||||
Mapped to: <plug>NERDCommenterToggle
|
||||
Applicable modes: normal visual-line.
|
||||
|
||||
@@ -176,17 +202,17 @@ If a [count] is given in normal mode, the mapping works as though that many
|
||||
lines were selected in visual-line mode.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.4 Minimal comment map *NERDComMinimalComment*
|
||||
3.2.4 Minimal comment map *NERDComMinimalComment*
|
||||
|
||||
Default mapping: [count],cm
|
||||
Default mapping: [count]|<Leader>|cm
|
||||
Mapped to: <plug>NERDCommenterMinimal
|
||||
Applicable modes: normal visual-line.
|
||||
|
||||
Comments the selected lines using one set of multipart delimiters if possible.
|
||||
|
||||
For example: if you are programming in c and you select 5 lines and press ,cm
|
||||
then a '/*' will be placed at the start of the top line and a '*/' will be
|
||||
placed at the end of the last line.
|
||||
For example: if you are programming in c and you select 5 lines and press
|
||||
|<Leader>|cm then a '/*' will be placed at the start of the top line and a '*/'
|
||||
will be placed at the end of the last line.
|
||||
|
||||
Sets of multipart comment delimiters that are between the top and bottom
|
||||
selected lines are replaced with place holders (see |'NERDLPlace'|) if
|
||||
@@ -198,13 +224,13 @@ If a [count] is given in normal mode, the mapping works as though that many
|
||||
lines were selected in visual-line mode.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.5 Invert comment map *NERDComInvertComment*
|
||||
3.2.5 Invert comment map *NERDComInvertComment*
|
||||
|
||||
Default mapping: ,ci
|
||||
Default mapping: |<Leader>|ci
|
||||
Mapped to: <plug>NERDCommenterInvert
|
||||
Applicable modes: normal visual-line.
|
||||
|
||||
Inverts the commented state of each selected line. If the a selected line is
|
||||
Inverts the commented state of each selected line. If the selected line is
|
||||
commented then it is uncommented and vice versa. Each line is examined and
|
||||
commented/uncommented individually.
|
||||
|
||||
@@ -215,13 +241,13 @@ If a [count] is given in normal mode, the mapping works as though that many
|
||||
lines were selected in visual-line mode.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.6 Sexy comment map *NERDComSexyComment*
|
||||
3.2.6 Sexy comment map *NERDComSexyComment*
|
||||
|
||||
Default mapping: [count],cs
|
||||
Default mapping: [count]|<Leader>|cs
|
||||
Mapped to: <plug>NERDCommenterSexy
|
||||
Applicable modes: normal, visual-line.
|
||||
|
||||
Comments the selected line(s) ``sexily''... see |NERDComSexyComments| for
|
||||
Comments the selected line(s) ``sexily''. See |NERDComSexyComments| for
|
||||
a description of what sexy comments are. Can only be done on filetypes for
|
||||
which there is at least one set of multipart comment delimiters specified.
|
||||
|
||||
@@ -235,18 +261,18 @@ Related options:
|
||||
|'NERDCompactSexyComs'|
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.7 Yank comment map *NERDComYankComment*
|
||||
3.2.7 Yank comment map *NERDComYankComment*
|
||||
|
||||
Default mapping: [count],cy
|
||||
Default mapping: [count]|<Leader>|cy
|
||||
Mapped to: <plug>NERDCommenterYank
|
||||
Applicable modes: normal visual visual-line visual-block.
|
||||
|
||||
Same as ,cc except that it yanks the line(s) that are commented first.
|
||||
Same as |<Leader>|cc except that it yanks the line(s) that are commented first.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.8 Comment to EOL map *NERDComEOLComment*
|
||||
3.2.8 Comment to EOL map *NERDComEOLComment*
|
||||
|
||||
Default mapping: ,c$
|
||||
Default mapping: |<Leader>|c$
|
||||
Mapped to: <plug>NERDCommenterToEOL
|
||||
Applicable modes: normal.
|
||||
|
||||
@@ -254,9 +280,9 @@ Comments the current line from the current cursor position up to the end of
|
||||
the line.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.9 Append com to line map *NERDComAppendComment*
|
||||
3.2.9 Append com to line map *NERDComAppendComment*
|
||||
|
||||
Default mapping: ,cA
|
||||
Default mapping: |<Leader>|cA
|
||||
Mapped to: <plug>NERDCommenterAppend
|
||||
Applicable modes: normal.
|
||||
|
||||
@@ -264,53 +290,53 @@ Appends comment delimiters to the end of the current line and goes
|
||||
to insert mode between the new delimiters.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.10 Insert comment map *NERDComInsertComment*
|
||||
3.2.10 Insert comment map *NERDComInsertComment*
|
||||
|
||||
Default mapping: disabled by default.
|
||||
Map it to: <plug>NERDCommenterInInsert
|
||||
Map it to: <plug>NERDCommenterInsert
|
||||
Applicable modes: insert.
|
||||
|
||||
Adds comment delimiters at the current cursor position and inserts
|
||||
between them.
|
||||
|
||||
NOTE: prior to version 2.1.17 this was mapped to ctrl-c. To restore this
|
||||
NOTE: prior to version 2.1.17 this was mapped to <C-c>. To restore this
|
||||
mapping add >
|
||||
let NERDComInsertMap='<c-c>'
|
||||
imap <C-c> <plug>NERDCommenterInsert
|
||||
<
|
||||
to your vimrc.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.11 Use alternate delims map *NERDComAltDelim*
|
||||
3.2.11 Use alternate delims map *NERDComAltDelim*
|
||||
|
||||
Default mapping: ,ca
|
||||
Default mapping: |<Leader>|ca
|
||||
Mapped to: <plug>NERDCommenterAltDelims
|
||||
Applicable modes: normal.
|
||||
|
||||
Changes to the alternative commenting style if one is available. For example,
|
||||
if the user is editing a c++ file using // comments and they hit ,ca
|
||||
if the user is editing a c++ file using // comments and they hit |<Leader>|ca
|
||||
then they will be switched over to /**/ comments.
|
||||
|
||||
See also |NERDComDefaultDelims|
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.12 Comment aligned maps *NERDComAlignedComment*
|
||||
3.2.12 Comment aligned maps *NERDComAlignedComment*
|
||||
|
||||
Default mappings: [count],cl [count],cb
|
||||
Default mappings: [count]|<Leader>|cl [count]|<Leader>|cb
|
||||
Mapped to: <plug>NERDCommenterAlignLeft
|
||||
<plug>NERDCommenterAlignBoth
|
||||
Applicable modes: normal visual-line.
|
||||
|
||||
Same as ,cc except that the comment delimiters are aligned on the left side or
|
||||
both sides respectively. These comments are always nested if the line(s) are
|
||||
already commented.
|
||||
Same as |<Leader>|cc except that the comment delimiters are aligned on the left
|
||||
side or both sides respectively. These comments are always nested if the
|
||||
line(s) are already commented.
|
||||
|
||||
If a [count] is given in normal mode, the mapping works as though that many
|
||||
lines were selected in visual-line mode.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.2.13 Uncomment line map *NERDComUncommentLine*
|
||||
3.2.13 Uncomment line map *NERDComUncommentLine*
|
||||
|
||||
Default mapping: [count],cu
|
||||
Default mapping: [count]|<Leader>|cu
|
||||
Mapped to: <plug>NERDCommenterUncomment
|
||||
Applicable modes: normal visual visual-line visual-block.
|
||||
|
||||
@@ -318,9 +344,9 @@ Uncomments the current line. If multiple lines are selected in
|
||||
visual mode then they are all uncommented.
|
||||
|
||||
When uncommenting, if the line contains multiple sets of delimiters then the
|
||||
``outtermost'' pair of delimiters will be removed.
|
||||
``outermost'' pair of delimiters will be removed.
|
||||
|
||||
The script uses a set of heurisics to distinguish ``real'' delimiters from
|
||||
The script uses a set of heuristics to distinguish ``real'' delimiters from
|
||||
``fake'' ones when uncommenting. See |NERDComIssues| for details.
|
||||
|
||||
If a [count] is given in normal mode, the mapping works as though that many
|
||||
@@ -331,41 +357,7 @@ Related options:
|
||||
|'NERDRemoveExtraSpaces'|
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.3 Supported filetypes *NERDComFiletypes*
|
||||
|
||||
Filetypes that can be commented by this plugin:
|
||||
abaqus abc acedb ada ahdl amiga aml ampl ant apache apachestyle asm68k asm asn
|
||||
aspvbs atlas autohotkey autoit automake ave awk basic b bc bdf bib bindzone
|
||||
bst btm caos catalog c cfg cg ch changelog cl clean clipper cmake conf config
|
||||
context cpp crontab cs csc csp css cterm cupl csv cvs dcl debchangelog
|
||||
debcontrol debsources def diff django docbk dns dosbatch dosini dot dracula
|
||||
dsl dtd dtml dylan ecd eiffel elf elmfilt erlang eruby eterm expect exports
|
||||
fetchmail fgl focexec form fortran foxpro fstab fvwm fx gdb gdmo geek
|
||||
gentoo-package-keywords' gentoo-package-mask' gentoo-package-use' gnuplot
|
||||
gtkrc haskell hb h help hercules hog html htmldjango htmlos ia64 icon idlang
|
||||
idl indent inform inittab ishd iss ist jam java javascript jess jgraph
|
||||
jproperties jproperties jsp kconfig kix kscript lace lex lftp lifelines lilo
|
||||
lisp lite lotos lout lprolog lscript lss lua lynx m4 mail make maple masm
|
||||
master matlab mel mf mib mma model moduala. modula2 modula3 monk mush muttrc
|
||||
named nasm nastran natural ncf netdict netrw nqc nroff nsis objc ocaml occam
|
||||
omlet omnimark openroad opl ora otl ox pascal passwd pcap pccts perl pfmain
|
||||
php phtml pic pike pilrc pine plaintex plm plsql po postscr pov povini ppd
|
||||
ppwiz procmail progress prolog psf ptcap python python qf radiance ratpoison r
|
||||
rc readline rebol registry remind rexx robots rpl rtf ruby sa samba sas sass
|
||||
sather scheme scilab screen scsh sdl sed selectbuf sgml sgmldecl sgmllnx sh
|
||||
sicad simula sinda skill slang sl slrnrc sm smarty smil smith sml snnsnet
|
||||
snnspat snnsres snobol4 spec specman spice sql sqlforms sqlj sqr squid st stp
|
||||
strace svn systemverilog tads taglist tags tak tasm tcl terminfo tex text
|
||||
plaintex texinfo texmf tf tidy tli trasys tsalt tsscl tssgm uc uil vb verilog
|
||||
verilog_systemverilog vgrindefs vhdl vim viminfo virata vo_base vrml vsejcl
|
||||
webmacro wget winbatch wml wvdial xdefaults xf86conf xhtml xkb xmath xml
|
||||
xmodmap xpm2 xpm xslt yacc yaml z8a
|
||||
|
||||
If a language is not in the list of hardcoded supported filetypes then the
|
||||
&commentstring vim option is used.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.4 Sexy Comments *NERDComSexyComments*
|
||||
3.3 Sexy Comments *NERDComSexyComments*
|
||||
These are comments that use one set of multipart comment delimiters as well as
|
||||
one other marker symbol. For example: >
|
||||
/*
|
||||
@@ -380,21 +372,19 @@ one other marker symbol. For example: >
|
||||
Here the multipart delimiters are /* and */ and the marker is *.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
2.5 The NERDComment function *NERDComNERDComment*
|
||||
3.4 The NERDComment function *NERDComNERDComment*
|
||||
|
||||
All of the NERD commenter mappings and menu items invoke a single function
|
||||
which delegates the commenting work to other functions. This function is
|
||||
public and has the prototype: >
|
||||
function! NERDComment(isVisual, type)
|
||||
function! NERDComment(mode, type)
|
||||
<
|
||||
The arguments to this function are simple:
|
||||
- isVisual: if you wish to do any kind of visual comment then set this to
|
||||
1 and the function will use the '< and '> marks to find the comment
|
||||
boundries. If set to 0 then the function will operate on the current
|
||||
line.
|
||||
- mode: a character indicating the mode in which the comment is requested:
|
||||
'n' for Normal mode, 'x' for Visual mode
|
||||
- type: is used to specify what type of commenting operation is to be
|
||||
performed, and it can be one of the following: "sexy", "invert",
|
||||
"minimal", "toggle", "alignLeft", "alignBoth", "norm", "nested",
|
||||
"minimal", "toggle", "alignLeft", "alignBoth", "comment", "nested",
|
||||
"toEOL", "append", "insert", "uncomment", "yank"
|
||||
|
||||
For example, if you typed >
|
||||
@@ -402,49 +392,107 @@ 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
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
3. Options *NERDComOptions*
|
||||
4. Options *NERDComOptions*
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.1 Options summary *NERDComOptionsSummary*
|
||||
4.1 Options summary *NERDComOptionsSummary*
|
||||
|
||||
|'loaded_nerd_comments'| Turns off the script.
|
||||
|'NERDAllowAnyVisualDelims'| Allows multipart alternative delims to
|
||||
be used when commenting in
|
||||
|
||||
|'NERDAllowAnyVisualDelims'| Allows multipart alternative delimiters
|
||||
to be used when commenting in
|
||||
visual/visual-block mode.
|
||||
|'NERDBlockComIgnoreEmpty'| Forces right delims to be placed when
|
||||
doing visual-block comments.
|
||||
|
||||
|'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.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.3 Options details *NERDComOptionsDetails*
|
||||
4.3 Options details *NERDComOptionsDetails*
|
||||
|
||||
To enable any of the below options you should put the given line in your
|
||||
~/.vimrc
|
||||
@@ -470,8 +518,8 @@ example if we are editing the following java code: >
|
||||
<
|
||||
If we are using // comments and select the "foo" and "bar" in visual-block
|
||||
mode, as shown left below (where '|'s are used to represent the visual-block
|
||||
boundary), and comment it then the script will use the alternative delims as
|
||||
shown on the right: >
|
||||
boundary), and comment it then the script will use the alternative delimiters
|
||||
as shown on the right: >
|
||||
|
||||
float |foo| = 1221; float /*foo*/ = 1221;
|
||||
float |bar| = 324; float /*bar*/ = 324;
|
||||
@@ -520,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.
|
||||
@@ -547,7 +604,7 @@ If you prefer the second option then stick this line in your vimrc: >
|
||||
<
|
||||
|
||||
If the filetype you are editing only has no multipart delimiters (for example
|
||||
a shell script) and you hadnt set this option then the above would become >
|
||||
a shell script) and you hadn't set this option then the above would become >
|
||||
in#t foo = 3;
|
||||
#int bar = 9;
|
||||
<
|
||||
@@ -563,7 +620,7 @@ Note that this option does not affect the behaviour of commenting in
|
||||
|visual-block| mode.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDCreateDefaultMappings'*
|
||||
*'NERDCreateDefaultMappings'*
|
||||
Values: 0 or 1.
|
||||
Default: 1.
|
||||
|
||||
@@ -571,6 +628,25 @@ If set to 0, none of the default mappings will be created.
|
||||
|
||||
See also |NERDComMappings|.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDCustomDelimiters'*
|
||||
Values: A map (format specified below).
|
||||
Default: {}
|
||||
|
||||
Use this option if you have new filetypes you want the script to handle, or if
|
||||
you want to override the default delimiters of a filetype.
|
||||
|
||||
Example: >
|
||||
let g:NERDCustomDelimiters = {
|
||||
\ 'ruby': { 'left': '#', 'leftAlt': 'FOO', 'rightAlt': 'BAR' },
|
||||
\ 'grondle': { 'left': '{{', 'right': '}}' }
|
||||
\ }
|
||||
<
|
||||
|
||||
Here we override the delimiter settings for ruby and add FOO/BAR as alternative
|
||||
delimiters. We also add {{ and }} as delimiters for a new filetype called
|
||||
'grondle'.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDRemoveAltComs'*
|
||||
Values: 0 or 1.
|
||||
@@ -581,7 +657,7 @@ this option tells the script whether to look for, and remove, comment
|
||||
delimiters of the alternative style.
|
||||
|
||||
For example, if you are editing a c++ file using // style comments and you go
|
||||
,cu on this line: >
|
||||
|<Leader>|cu on this line: >
|
||||
/* This is a c++ comment baby! */
|
||||
<
|
||||
It will not be uncommented if the NERDRemoveAltComs is set to 0.
|
||||
@@ -589,7 +665,7 @@ It will not be uncommented if the NERDRemoveAltComs is set to 0.
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDRemoveExtraSpaces'*
|
||||
Values: 0 or 1.
|
||||
Default: 1.
|
||||
Default: 0.
|
||||
|
||||
By default, the NERD commenter will remove spaces around comment delimiters if
|
||||
either:
|
||||
@@ -612,8 +688,14 @@ Otherwise they would become: >
|
||||
int bar = 10;
|
||||
int baz = foo + bar
|
||||
<
|
||||
If you want the spaces to be removed only if |'NERDSpaceDelims'| is set then
|
||||
set NERDRemoveExtraSpaces to 0.
|
||||
|
||||
Note: When using 'start' as the default alignment, the enabling of
|
||||
NERDRemoveExtraSpaces will still result in the removal of a space after the
|
||||
delimiter. This can be undesirable since aligning the delimiters at the very
|
||||
start of the line (index 0) will usually result in spaces between the comment
|
||||
delimiters and the text which probably shouldn't be removed. So when using
|
||||
'start' as the default alignment, take care to also disable
|
||||
NERDRemoveExtraSpaces.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDLPlace'*
|
||||
@@ -633,7 +715,7 @@ To set these options use lines like: >
|
||||
Following the above example, if we have line of c code: >
|
||||
/* int horse */
|
||||
<
|
||||
and we comment it with ,cn it will be changed to: >
|
||||
and we comment it with |<Leader>|cn it will be changed to: >
|
||||
/*FOO int horse BAR*/
|
||||
<
|
||||
When we uncomment this line it will go back to what it was.
|
||||
@@ -646,7 +728,7 @@ Default: 3
|
||||
This option can take 4 values:
|
||||
"0": Turns the menu off.
|
||||
"1": Turns the 'comment' menu on with no menu shortcut.
|
||||
"2": Turns the 'comment 'menu on with <alt>-c as the shortcut.
|
||||
"2": Turns the 'comment' menu on with <alt>-c as the shortcut.
|
||||
"3": Turns the 'Plugin -> comment' menu on with <alt>-c as the shortcut.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
@@ -673,6 +755,26 @@ 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'
|
||||
Default 'none'.
|
||||
|
||||
Specifies the default alignment to use when inserting comments.
|
||||
|
||||
Note: When using 'start' as the default alignment be sure to disable
|
||||
NERDRemoveExtraSpaces. See the note at the bottom of |NERDRemoveExtraSpaces|
|
||||
for more details.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDCompactSexyComs'*
|
||||
Values: 0 or 1.
|
||||
@@ -698,24 +800,58 @@ Values: 0 or 1.
|
||||
Default 1.
|
||||
|
||||
When this option is set to 1, comments are nested automatically. That is, if
|
||||
you hit ,cc on a line that is already commented it will be commented again
|
||||
you hit |<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.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDDisableTabsInBlockComm'*
|
||||
Values: 0 or 1.
|
||||
Default 0.
|
||||
|
||||
When this option is set to 1, NERDDisableTabsInBlockComm will not add
|
||||
whitespaces align the start location of the ending comment symbol with the
|
||||
end location of the starting comment symbol. For example, in Fortran, the new
|
||||
style will be as the following: >
|
||||
close (inpt,iostat=ierr,iomsg=error_message)
|
||||
call io_error(pname,input_fname,2,__LINE__,__FILE__,ierr,error_message)
|
||||
<
|
||||
to >
|
||||
!===BEGIN===!
|
||||
! close (inpt,iostat=ierr,iomsg=error_message)
|
||||
! call io_error(pname,input_fname,2,__LINE__,__FILE__,ierr,error_message)
|
||||
!===END===!
|
||||
<
|
||||
for the block comment style if customized comment symbols are set up in vimrc
|
||||
file by the following line >
|
||||
let g:NERDCustomDelimiters = {
|
||||
\ 'fortran':{'left':'!','leftAlt':'!===BEGIN===!','rightAlt':'!===END===!'}
|
||||
\ }
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
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.
|
||||
|
||||
==============================================================================
|
||||
4. Key mapping customisation *NERDComMappings*
|
||||
5. Key mapping customisation *NERDComMappings*
|
||||
|
||||
To change a mapping just map another key combo to the internal <plug> mapping.
|
||||
For example, to remap the |NERDComComment| mapping to ",omg" you would put
|
||||
@@ -730,17 +866,17 @@ map to.
|
||||
See also |'NERDCreateDefaultMappings'|.
|
||||
|
||||
==============================================================================
|
||||
5. Issues with the script *NERDComIssues*
|
||||
6. Issues with the script *NERDComIssues*
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
5.1 Delimiter detection heuristics *NERDComHeuristics*
|
||||
6.1 Delimiter detection heuristics *NERDComHeuristics*
|
||||
|
||||
Heuristics are used to distinguish the real comment delimiters
|
||||
|
||||
Because we have comment mappings that place delimiters in the middle of lines,
|
||||
removing comment delimiters is a bit tricky. This is because if comment
|
||||
delimiters appear in a line doesnt mean they really ARE delimiters. For
|
||||
delimiters appear in a line doesn't mean they really ARE delimiters. For
|
||||
example, Java uses // comments but the line >
|
||||
System.out.println("//");
|
||||
<
|
||||
@@ -754,17 +890,17 @@ string. These heuristics, while usually pretty accurate, will not work for all
|
||||
cases.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
5.2 Nesting issues *NERDComNesting*
|
||||
6.2 Nesting issues *NERDComNesting*
|
||||
|
||||
If we have some line of code like this: >
|
||||
/*int foo */ = /*5 + 9;*/
|
||||
<
|
||||
This will not be uncommented legally. The NERD commenter will remove the
|
||||
"outter most" delimiters so the line will become: >
|
||||
"outer most" delimiters so the line will become: >
|
||||
int foo */ = /*5 + 9;
|
||||
<
|
||||
which almost certainly will not be what you want. Nested sets of comments will
|
||||
uncomment fine though. Eg: >
|
||||
uncomment fine though. E.g.: >
|
||||
/*int/* foo =*/ 5 + 9;*/
|
||||
<
|
||||
will become: >
|
||||
@@ -774,14 +910,14 @@ will become: >
|
||||
for simplicity)
|
||||
|
||||
==============================================================================
|
||||
6. About *NERDComAbout*
|
||||
7. About *NERDComAbout*
|
||||
|
||||
The author of the NERD commenter is Martyzillatron --- the half robot, half
|
||||
dinosaur bastard son of Megatron and Godzilla. He enjoys destroying
|
||||
metropolises and eating tourist busses.
|
||||
metropolises and eating tourist buses.
|
||||
|
||||
Drop him a line at martin_grenfell at msn.com. He would love to hear from you.
|
||||
its a lonely life being the worlds premier terror machine. How would you feel
|
||||
It's a lonely life being the worlds premier terror machine. How would you feel
|
||||
if your face looked like a toaster and a t-rex put together? :(
|
||||
|
||||
The latest stable versions can be found at
|
||||
@@ -793,6 +929,15 @@ The latest dev versions are on github
|
||||
==============================================================================
|
||||
8. Changelog *NERDComChangelog*
|
||||
|
||||
2.3.0
|
||||
- remove all filetypes which have a &commentstring in the standard vim
|
||||
runtime for vim > 7.0 unless the script stores an alternate set of
|
||||
delimiters
|
||||
- make the script complain if the user doesn't have filetype plugins enabled
|
||||
- use |<Leader>| instead of comma to start the default mappings
|
||||
- fix a couple of bugs with sexy comments - thanks to Tim Smart
|
||||
- lots of refactoring
|
||||
|
||||
2.2.2
|
||||
- remove the NERDShutup option and the message is suppresses, this makes
|
||||
the plugin silently rely on &commentstring for unknown filetypes.
|
||||
@@ -848,7 +993,7 @@ The latest dev versions are on github
|
||||
NERDComInsertComment if you wish to restore it
|
||||
|
||||
==============================================================================
|
||||
8. Credits *NERDComCredits*
|
||||
9. Credits *NERDComCredits*
|
||||
|
||||
Thanks to the follow people for suggestions and patches:
|
||||
|
||||
@@ -984,8 +1129,9 @@ Simon Hengel htmlcheetah
|
||||
Matt Tolton javacc
|
||||
Ivan Devat javascript.jquery
|
||||
tpope cucumber,pdf
|
||||
Lyude Paul piglit shader_test
|
||||
==============================================================================
|
||||
9. License *NERDComLicense*
|
||||
10. License *NERDComLicense*
|
||||
|
||||
The NERD commenter is released under the wtfpl.
|
||||
See http://sam.zoy.org/wtfpl/COPYING.
|
||||
|
||||
Reference in New Issue
Block a user