mirror of
https://github.com/preservim/nerdcommenter.git
synced 2025-11-08 18:03:46 -05:00
Compare commits
61 Commits
doc-overha
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02a3b6455f | ||
|
|
66c07e4083 | ||
|
|
3f860f2d98 | ||
|
|
c9b1078807 | ||
|
|
7bb1f72e80 | ||
|
|
fea637c3c2 | ||
|
|
e361a44230 | ||
|
|
da948e160d | ||
|
|
c52b6e731c | ||
|
|
d2e21d417f | ||
|
|
ab2ae4d502 | ||
|
|
844b211a4c | ||
|
|
b0b09ea46c | ||
|
|
2045211689 | ||
|
|
277bdfc679 | ||
|
|
1fe9e1cfea | ||
|
|
e23f55e735 | ||
|
|
91499c76a7 | ||
|
|
bd1a29536d | ||
|
|
c6766698d8 | ||
|
|
c5b0f78820 | ||
|
|
78029a0e90 | ||
|
|
457b383767 | ||
|
|
d069f7fb56 | ||
|
|
06f6166e5d | ||
|
|
c406bba57d | ||
|
|
ea6a4f76fa | ||
|
|
1caf560df1 | ||
|
|
98cc4a2d64 | ||
|
|
f575c18d05 | ||
|
|
fd2114b46d | ||
|
|
fe74a1b890 | ||
|
|
60f3a2bc2b | ||
|
|
2a0a05ff98 | ||
|
|
6d30ebcd42 | ||
|
|
f8671f783b | ||
|
|
ec002e8f5d | ||
|
|
f9c5f0fbda | ||
|
|
ac512fe158 | ||
|
|
867618364f | ||
|
|
97317fc319 | ||
|
|
37298c471e | ||
|
|
9fffd4c022 | ||
|
|
2e7a775dd2 | ||
|
|
eddd535bdf | ||
|
|
13d00954a6 | ||
|
|
ab67976bea | ||
|
|
fa9b74ff69 | ||
|
|
a65465d321 | ||
|
|
9d5c12e126 | ||
|
|
2c87cae76e | ||
|
|
f7333809b6 | ||
|
|
576bd64482 | ||
|
|
ed591cb2a2 | ||
|
|
d398a0278c | ||
|
|
85364c56c4 | ||
|
|
b1bb758f14 | ||
|
|
eeabded555 | ||
|
|
918592cdc6 | ||
|
|
8e935a6367 | ||
|
|
f21b0f8fab |
17
CHANGELOG.md
17
CHANGELOG.md
@@ -1,5 +1,22 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
### 2.7.0
|
||||||
|
|
||||||
|
* Support for many more filetypes
|
||||||
|
* Sort out race condition when using utility functions directly
|
||||||
|
* Fixup undo support when commenting results in cursor moves
|
||||||
|
* Refactor comment insertion code
|
||||||
|
|
||||||
|
### 2.6.0
|
||||||
|
|
||||||
|
* Refactor code to run as autoload plugin
|
||||||
|
* Add lots of community contributed file types
|
||||||
|
* Fix several languages with idiosyncrasies
|
||||||
|
* Improve interoperability with other vim settings
|
||||||
|
* Improve handling of ranges
|
||||||
|
* Improve help documentation
|
||||||
|
* Cleanup and fix vimscript issues
|
||||||
|
|
||||||
### 2.5.2
|
### 2.5.2
|
||||||
|
|
||||||
* Minor update to include new file types contributed by the community over the last few months.
|
* Minor update to include new file types contributed by the community over the last few months.
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -68,10 +68,12 @@ git clone https://github.com/preservim/nerdcommenter.git
|
|||||||
(For Neovim, change `~/.vim/` to `~/.config/nvim/`.)
|
(For Neovim, change `~/.vim/` to `~/.config/nvim/`.)
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
curl -fLo ~/.vim/plugin/NERD_Commenter.vim --create-dirs \
|
curl -fLo ~/.vim/plugin/nerdcommenter.vim --create-dirs \
|
||||||
https://raw.githubusercontent.com/preservim/nerdcommenter/master/plugin/nerdcommenter.vim
|
https://raw.githubusercontent.com/preservim/nerdcommenter/master/plugin/nerdcommenter.vim
|
||||||
curl -fLo ~/.vim/doc/NERD_Commenter.txt --create-dirs \
|
curl -fLo ~/.vim/doc/nerdcommenter.txt --create-dirs \
|
||||||
https://raw.githubusercontent.com/preservim/nerdcommenter/master/doc/nerdcommenter.txt
|
https://raw.githubusercontent.com/preservim/nerdcommenter/master/doc/nerdcommenter.txt
|
||||||
|
curl -fLo ~/.vim/autoload/nerdcommenter.vim --create-dirs \
|
||||||
|
https://raw.githubusercontent.com/preservim/nerdcommenter/master/autoload/nerdcommenter.vim
|
||||||
```
|
```
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
@@ -201,8 +203,8 @@ Most of the following mappings are for normal/visual mode only. The **|NERDComme
|
|||||||
|
|
||||||
While the plugin does not directly support motions, you can leverage its support for selections to do something very similar. For example, to add motions to toggle comments on the paragraph text object you could use:
|
While the plugin does not directly support motions, you can leverage its support for selections to do something very similar. For example, to add motions to toggle comments on the paragraph text object you could use:
|
||||||
```vim
|
```vim
|
||||||
nnoremap <silent> <leader>c} V}:call NERDComment('x', 'toggle')<CR>
|
nnoremap <silent> <leader>c} V}:call nerdcommenter#Comment('x', 'toggle')<CR>
|
||||||
nnoremap <silent> <leader>c{ V{:call NERDComment('x', 'toggle')<CR>
|
nnoremap <silent> <leader>c{ V{:call nerdcommenter#Comment('x', 'toggle')<CR>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contributions
|
## Contributions
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ let s:delimiterMap = {
|
|||||||
\ 'ada': { 'left': '--', 'leftAlt': '-- ' },
|
\ 'ada': { 'left': '--', 'leftAlt': '-- ' },
|
||||||
\ 'ahdl': { 'left': '--' },
|
\ 'ahdl': { 'left': '--' },
|
||||||
\ 'ahk': { 'left': ';', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'ahk': { 'left': ';', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
|
\ 'alloy': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
|
||||||
\ 'amiga': { 'left': ';' },
|
\ 'amiga': { 'left': ';' },
|
||||||
\ 'aml': { 'left': '/*' },
|
\ 'aml': { 'left': '/*' },
|
||||||
\ 'ampl': { 'left': '#' },
|
\ 'ampl': { 'left': '#' },
|
||||||
@@ -23,6 +24,7 @@ let s:delimiterMap = {
|
|||||||
\ 'apachestyle': { 'left': '#' },
|
\ 'apachestyle': { 'left': '#' },
|
||||||
\ 'apdl': { 'left': '!' },
|
\ 'apdl': { 'left': '!' },
|
||||||
\ 'applescript': { 'left': '--', 'leftAlt': '(*', 'rightAlt': '*)' },
|
\ 'applescript': { 'left': '--', 'leftAlt': '(*', 'rightAlt': '*)' },
|
||||||
|
\ 'aptconf': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'armasm': { 'left': ';' },
|
\ 'armasm': { 'left': ';' },
|
||||||
\ 'asciidoc': { 'left': '//' },
|
\ 'asciidoc': { 'left': '//' },
|
||||||
\ 'asm': { 'left': ';', 'leftAlt': '#' },
|
\ 'asm': { 'left': ';', 'leftAlt': '#' },
|
||||||
@@ -33,6 +35,7 @@ let s:delimiterMap = {
|
|||||||
\ 'asterisk': { 'left': ';' },
|
\ 'asterisk': { 'left': ';' },
|
||||||
\ 'asy': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'asy': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'atlas': { 'left': 'C', 'right': '$' },
|
\ 'atlas': { 'left': 'C', 'right': '$' },
|
||||||
|
\ 'ats': { 'left': '//', 'leftAlt': '(*', 'rightAlt': '*)' },
|
||||||
\ 'augeas': { 'left': '(*', 'right': '*)' },
|
\ 'augeas': { 'left': '(*', 'right': '*)' },
|
||||||
\ 'autohotkey': { 'left': ';', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'autohotkey': { 'left': ';', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'autoit': { 'left': ';' },
|
\ 'autoit': { 'left': ';' },
|
||||||
@@ -49,9 +52,11 @@ let s:delimiterMap = {
|
|||||||
\ 'btm': { 'left': '::' },
|
\ 'btm': { 'left': '::' },
|
||||||
\ 'c': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
|
\ 'c': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
|
||||||
\ 'cabal': { 'left': '--' },
|
\ 'cabal': { 'left': '--' },
|
||||||
|
\ 'cairo': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'calibre': { 'left': '//' },
|
\ 'calibre': { 'left': '//' },
|
||||||
\ 'caos': { 'left': '*' },
|
\ 'caos': { 'left': '*' },
|
||||||
\ 'catalog': { 'left': '--', 'right': '--' },
|
\ 'catalog': { 'left': '--', 'right': '--' },
|
||||||
|
\ 'cel': { 'left': '//' },
|
||||||
\ 'cf': { 'left': '<!---', 'right': '--->' },
|
\ 'cf': { 'left': '<!---', 'right': '--->' },
|
||||||
\ 'cfg': { 'left': '#' },
|
\ 'cfg': { 'left': '#' },
|
||||||
\ 'cg': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'cg': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
@@ -78,6 +83,7 @@ let s:delimiterMap = {
|
|||||||
\ 'cython': { 'left': '# ', 'leftAlt': '#' },
|
\ 'cython': { 'left': '# ', 'leftAlt': '#' },
|
||||||
\ 'd': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'd': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'dakota': { 'left': '#' },
|
\ 'dakota': { 'left': '#' },
|
||||||
|
\ 'dart': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'dcl': { 'left': '$!' },
|
\ 'dcl': { 'left': '$!' },
|
||||||
\ 'debcontrol': { 'left': '#' },
|
\ 'debcontrol': { 'left': '#' },
|
||||||
\ 'debsources': { 'left': '#' },
|
\ 'debsources': { 'left': '#' },
|
||||||
@@ -85,11 +91,12 @@ let s:delimiterMap = {
|
|||||||
\ 'desktop': { 'left': '#' },
|
\ 'desktop': { 'left': '#' },
|
||||||
\ 'dhcpd': { 'left': '#' },
|
\ 'dhcpd': { 'left': '#' },
|
||||||
\ 'diff': { 'left': '#' },
|
\ 'diff': { 'left': '#' },
|
||||||
|
\ 'dts': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
|
||||||
\ 'django': { 'left': '{% comment %}', 'right': '{% endcomment %}', 'leftAlt': '{#', 'rightAlt': '#}' },
|
\ 'django': { 'left': '{% comment %}', 'right': '{% endcomment %}', 'leftAlt': '{#', 'rightAlt': '#}' },
|
||||||
\ 'dns': { 'left': ';' },
|
\ 'dns': { 'left': ';' },
|
||||||
\ 'docbk': { 'left': '<!--', 'right': '-->' },
|
\ 'docbk': { 'left': '<!--', 'right': '-->' },
|
||||||
\ 'dockerfile': { 'left': '#' },
|
\ 'dockerfile': { 'left': '#' },
|
||||||
\ 'dosbatch': { 'left': 'REM ', 'leftAlt': '::' },
|
\ 'dosbatch': { 'left': 'REM ', 'nested': 1, 'leftAlt': 'REM ', 'nestedAlt': 1 },
|
||||||
\ 'dosini': { 'left': ';' },
|
\ 'dosini': { 'left': ';' },
|
||||||
\ 'dot': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'dot': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'dracula': { 'left': ';' },
|
\ 'dracula': { 'left': ';' },
|
||||||
@@ -114,6 +121,7 @@ let s:delimiterMap = {
|
|||||||
\ 'exports': { 'left': '#' },
|
\ 'exports': { 'left': '#' },
|
||||||
\ 'factor': { 'left': '! ', 'leftAlt': '!# ' },
|
\ 'factor': { 'left': '! ', 'leftAlt': '!# ' },
|
||||||
\ 'fancy': { 'left': '#' },
|
\ 'fancy': { 'left': '#' },
|
||||||
|
\ 'fasm': { 'left': ';' },
|
||||||
\ 'faust': { 'left': '//' },
|
\ 'faust': { 'left': '//' },
|
||||||
\ 'fgl': { 'left': '#' },
|
\ 'fgl': { 'left': '#' },
|
||||||
\ 'fluent': { 'left': '#', 'leftAlt': '##' },
|
\ 'fluent': { 'left': '#', 'leftAlt': '##' },
|
||||||
@@ -156,6 +164,7 @@ let s:delimiterMap = {
|
|||||||
\ 'haxe': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'haxe': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'hb': { 'left': '#' },
|
\ 'hb': { 'left': '#' },
|
||||||
\ 'hbs': { 'left': '{{!-- ', 'right': ' --}}' },
|
\ 'hbs': { 'left': '{{!-- ', 'right': ' --}}' },
|
||||||
|
\ 'hcl': { 'left': '#', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'hercules': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'hercules': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'hive': { 'left': '-- ' },
|
\ 'hive': { 'left': '-- ' },
|
||||||
\ 'hocon': { 'left': '//', 'leftAlt': '#' },
|
\ 'hocon': { 'left': '//', 'leftAlt': '#' },
|
||||||
@@ -187,16 +196,20 @@ let s:delimiterMap = {
|
|||||||
\ 'jgraph': { 'left': '(*', 'right': '*)' },
|
\ 'jgraph': { 'left': '(*', 'right': '*)' },
|
||||||
\ 'jinja': { 'left': '{#', 'right': '#}', 'leftAlt': '<!--', 'rightAlt': '-->' },
|
\ 'jinja': { 'left': '{#', 'right': '#}', 'leftAlt': '<!--', 'rightAlt': '-->' },
|
||||||
\ 'jproperties': { 'left': '#' },
|
\ 'jproperties': { 'left': '#' },
|
||||||
|
\ 'jq': { 'left': '#' },
|
||||||
|
\ 'json5': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'jsonc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'jsonc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'jsonnet': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'jsonnet': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'jsp': { 'left': '<%--', 'right': '--%>' },
|
\ 'jsp': { 'left': '<%--', 'right': '--%>' },
|
||||||
\ 'julia': { 'left': '# ', 'leftAlt': '#=', 'rightAlt': '=#' },
|
\ 'julia': { 'left': '# ', 'leftAlt': '#=', 'rightAlt': '=#' },
|
||||||
|
\ 'just' : { 'left': '#' },
|
||||||
\ 'kivy': { 'left': '#' },
|
\ 'kivy': { 'left': '#' },
|
||||||
\ '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': '#' },
|
||||||
|
\ 'lean': { 'left': '--', 'leftAlt': '/-', 'rightAlt': '-/' },
|
||||||
\ 'ledger': { 'left': '#', 'leftAlt': ';' },
|
\ 'ledger': { 'left': '#', 'leftAlt': ';' },
|
||||||
\ 'less': { 'left': '/*', 'right': '*/' },
|
\ 'less': { 'left': '/*', 'right': '*/' },
|
||||||
\ 'lhaskell': { 'left': '>{-', 'right': '-}', 'leftAlt': '>-- ' },
|
\ 'lhaskell': { 'left': '>{-', 'right': '-}', 'leftAlt': '>-- ' },
|
||||||
@@ -269,6 +282,7 @@ let s:delimiterMap = {
|
|||||||
\ 'ox': { 'left': '//' },
|
\ 'ox': { 'left': '//' },
|
||||||
\ 'paludis-use-conf': { 'left': '#' },
|
\ 'paludis-use-conf': { 'left': '#' },
|
||||||
\ 'pandoc': { 'left': '<!--', 'right': '-->' },
|
\ 'pandoc': { 'left': '<!--', 'right': '-->' },
|
||||||
|
\ 'pamenv': { 'left': '#' },
|
||||||
\ 'pascal': { 'left': '{', 'right': '}', 'leftAlt': '(*', 'rightAlt': '*)' },
|
\ 'pascal': { 'left': '{', 'right': '}', 'leftAlt': '(*', 'rightAlt': '*)' },
|
||||||
\ 'patran': { 'left': '$', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'patran': { 'left': '$', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'pcap': { 'left': '#' },
|
\ 'pcap': { 'left': '#' },
|
||||||
@@ -340,7 +354,7 @@ let s:delimiterMap = {
|
|||||||
\ 'sh': { 'left': '#' },
|
\ 'sh': { 'left': '#' },
|
||||||
\ 'shader_test': { 'left': '#' },
|
\ 'shader_test': { 'left': '#' },
|
||||||
\ 'sicad': { 'left': '*' },
|
\ 'sicad': { 'left': '*' },
|
||||||
\ 'sile': { 'left': '%' },
|
\ 'sile': { 'left': '%', 'leftAlt': '--' },
|
||||||
\ 'simula': { 'left': '%', 'leftAlt': '--' },
|
\ 'simula': { 'left': '%', 'leftAlt': '--' },
|
||||||
\ 'sinda': { 'left': '$' },
|
\ 'sinda': { 'left': '$' },
|
||||||
\ 'skill': { 'left': ';' },
|
\ 'skill': { 'left': ';' },
|
||||||
@@ -377,6 +391,7 @@ let s:delimiterMap = {
|
|||||||
\ 'stan': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'stan': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'stp': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
|
\ 'stp': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
|
||||||
\ 'supercollider': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'supercollider': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
|
\ 'svelte': { 'left': '<!--', 'right': '-->' },
|
||||||
\ 'swift': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
|
\ 'swift': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
|
||||||
\ 'systemverilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'systemverilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'tads': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'tads': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
@@ -391,6 +406,8 @@ let s:delimiterMap = {
|
|||||||
\ 'texmf': { 'left': '%' },
|
\ 'texmf': { 'left': '%' },
|
||||||
\ 'tf': { 'left': '#' },
|
\ 'tf': { 'left': '#' },
|
||||||
\ 'tidy': { 'left': '#' },
|
\ 'tidy': { 'left': '#' },
|
||||||
|
\ 'tjp': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
|
\ 'tla': { 'left': '\\*', 'leftAlt': '(*', 'rightAlt': '*)' },
|
||||||
\ 'tli': { 'left': '#' },
|
\ 'tli': { 'left': '#' },
|
||||||
\ 'tmux': { 'left': '#' },
|
\ 'tmux': { 'left': '#' },
|
||||||
\ 'toml': { 'left': '#' },
|
\ 'toml': { 'left': '#' },
|
||||||
@@ -405,6 +422,7 @@ let s:delimiterMap = {
|
|||||||
\ 'txt2tags': { 'left': '%' },
|
\ 'txt2tags': { 'left': '%' },
|
||||||
\ 'typescript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'typescript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'typescriptreact': { 'left': '//', 'leftAlt': '{/*', 'rightAlt': '*/}' },
|
\ 'typescriptreact': { 'left': '//', 'leftAlt': '{/*', 'rightAlt': '*/}' },
|
||||||
|
\ 'typst': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'uc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'uc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'uc4': { 'left': '!' },
|
\ 'uc4': { 'left': '!' },
|
||||||
\ 'uil': { 'left': '!' },
|
\ 'uil': { 'left': '!' },
|
||||||
@@ -412,6 +430,7 @@ let s:delimiterMap = {
|
|||||||
\ 'vala': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'vala': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'vasp': { 'left': '!' },
|
\ 'vasp': { 'left': '!' },
|
||||||
\ 'vb': { 'left': "'" },
|
\ 'vb': { 'left': "'" },
|
||||||
|
\ 'vcl': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ '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': '*/' },
|
||||||
@@ -434,7 +453,8 @@ let s:delimiterMap = {
|
|||||||
\ 'xpm2': { 'left': '!' },
|
\ 'xpm2': { 'left': '!' },
|
||||||
\ 'xquery': { 'left': '(:', 'right': ':)' },
|
\ 'xquery': { 'left': '(:', 'right': ':)' },
|
||||||
\ 'yaml': { 'left': '#' },
|
\ 'yaml': { 'left': '#' },
|
||||||
\ 'z8a': { 'left': ';' }
|
\ 'z8a': { 'left': ';' },
|
||||||
|
\ 'zig': { 'left': '//' }
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
let g:NERDDelimiterMap = s:delimiterMap
|
let g:NERDDelimiterMap = s:delimiterMap
|
||||||
@@ -451,10 +471,6 @@ endif
|
|||||||
" This function is responsible for setting up buffer scoped variables for the
|
" This function is responsible for setting up buffer scoped variables for the
|
||||||
" current buffer.
|
" current buffer.
|
||||||
function! nerdcommenter#SetUp() abort
|
function! nerdcommenter#SetUp() abort
|
||||||
if exists('b:NERDCommenterDelims')
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
let filetype = &filetype
|
let filetype = &filetype
|
||||||
|
|
||||||
"for compound filetypes, if we don't know how to handle the full filetype
|
"for compound filetypes, if we don't know how to handle the full filetype
|
||||||
@@ -472,7 +488,7 @@ function! nerdcommenter#SetUp() abort
|
|||||||
let b:NERDSexyComMarker = ''
|
let b:NERDSexyComMarker = ''
|
||||||
|
|
||||||
if has_key(s:delimiterMap, filetype)
|
if has_key(s:delimiterMap, filetype)
|
||||||
let b:NERDCommenterDelims = s:delimiterMap[filetype]
|
let b:NERDCommenterDelims = copy(s:delimiterMap[filetype])
|
||||||
for i in ['left', 'leftAlt', 'right', 'rightAlt']
|
for i in ['left', 'leftAlt', 'right', 'rightAlt']
|
||||||
if !has_key(b:NERDCommenterDelims, i)
|
if !has_key(b:NERDCommenterDelims, i)
|
||||||
let b:NERDCommenterDelims[i] = ''
|
let b:NERDCommenterDelims[i] = ''
|
||||||
@@ -484,10 +500,10 @@ function! nerdcommenter#SetUp() abort
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
" if g:NERD_<filetype>_alt_style is defined, use the alternate style
|
" if g:NERD_<filetype>_alt_style is defined, use the alternate style
|
||||||
let b:NERDCommenterFirstInit = getbufvar(1,'NERDCommenterFirstInit')
|
let b:NERDCommenterFirstInit = getbufvar(bufnr('%'),'NERDCommenterFirstInit')
|
||||||
if exists('g:NERDAltDelims_'.filetype) && eval('g:NERDAltDelims_'.filetype) && !b:NERDCommenterFirstInit
|
if exists('g:NERDAltDelims_'.filetype) && eval('g:NERDAltDelims_'.filetype) && !b:NERDCommenterFirstInit
|
||||||
call nerdcommenter#SwitchToAlternativeDelimiters(0)
|
|
||||||
let b:NERDCommenterFirstInit = 1
|
let b:NERDCommenterFirstInit = 1
|
||||||
|
call nerdcommenter#SwitchToAlternativeDelimiters(0)
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
let b:NERDCommenterDelims = s:CreateDelimMapFromCms()
|
let b:NERDCommenterDelims = s:CreateDelimMapFromCms()
|
||||||
@@ -506,8 +522,8 @@ function! s:CreateDelimMapFromCms() abort
|
|||||||
return delims
|
return delims
|
||||||
endif
|
endif
|
||||||
return {
|
return {
|
||||||
\ 'left': substitute(&commentstring, '\([^ \t]*\)\s*%s.*', '\1', ''),
|
\ 'left': matchstr(&commentstring, '^\S*\ze\s*%s'),
|
||||||
\ 'right': substitute(&commentstring, '.*%s\s*\(.*\)', '\1', 'g'),
|
\ 'right': matchstr(&commentstring, '%s\s*\zs.*$'),
|
||||||
\ 'nested': 0,
|
\ 'nested': 0,
|
||||||
\ 'leftAlt': '',
|
\ 'leftAlt': '',
|
||||||
\ 'rightAlt': '',
|
\ 'rightAlt': '',
|
||||||
@@ -525,10 +541,10 @@ endfunction
|
|||||||
" if this function changed the delimiters or not
|
" if this function changed the delimiters or not
|
||||||
" function nerdcommenter#SwitchToAlternativeDelimiters(printMsgs)
|
" function nerdcommenter#SwitchToAlternativeDelimiters(printMsgs)
|
||||||
function! nerdcommenter#SwitchToAlternativeDelimiters(printMsgs) abort
|
function! nerdcommenter#SwitchToAlternativeDelimiters(printMsgs) abort
|
||||||
call nerdcommenter#SetUp()
|
|
||||||
if exists('*NERDCommenter_before')
|
if exists('*NERDCommenter_before')
|
||||||
exe 'call NERDCommenter_before()'
|
exe 'call NERDCommenter_before()'
|
||||||
endif
|
endif
|
||||||
|
call nerdcommenter#SetUp()
|
||||||
"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'] ==# ''
|
||||||
@@ -651,7 +667,7 @@ function! s:CommentBlock(top, bottom, lSide, rSide, forceNested) abort
|
|||||||
"alternative delimiters (if THEY are) as the comment will be better and more
|
"alternative delimiters (if THEY are) as the comment will be better and more
|
||||||
"accurate with multipart delimiters
|
"accurate with multipart delimiters
|
||||||
let switchedDelims = 0
|
let switchedDelims = 0
|
||||||
if !s:Multipart() && !g:NERDAllowAnyVisualDelims && s:AltMultipart()
|
if !s:Multipart() && g:NERDAllowAnyVisualDelims && s:AltMultipart()
|
||||||
let switchedDelims = 1
|
let switchedDelims = 1
|
||||||
call nerdcommenter#SwitchToAlternativeDelimiters(0)
|
call nerdcommenter#SwitchToAlternativeDelimiters(0)
|
||||||
endif
|
endif
|
||||||
@@ -1068,7 +1084,7 @@ function! s:CommentRegion(topLine, topCol, bottomLine, bottomCol, forceNested) a
|
|||||||
|
|
||||||
"switch delimiters (if we can) if the current set isn't multipart
|
"switch delimiters (if we can) if the current set isn't multipart
|
||||||
let switchedDelims = 0
|
let switchedDelims = 0
|
||||||
if !s:Multipart() && s:AltMultipart() && !g:NERDAllowAnyVisualDelims
|
if !s:Multipart() && s:AltMultipart() && g:NERDAllowAnyVisualDelims
|
||||||
let switchedDelims = 1
|
let switchedDelims = 1
|
||||||
call nerdcommenter#SwitchToAlternativeDelimiters(0)
|
call nerdcommenter#SwitchToAlternativeDelimiters(0)
|
||||||
endif
|
endif
|
||||||
@@ -1091,7 +1107,7 @@ function! s:CommentRegion(topLine, topCol, bottomLine, bottomCol, forceNested) a
|
|||||||
|
|
||||||
"comment the bottom line
|
"comment the bottom line
|
||||||
let bottom = getline(a:bottomLine)
|
let bottom = getline(a:bottomLine)
|
||||||
let numLeadingSpacesTabs = strlen(substitute(bottom, '^\([ \t]*\).*$', '\1', ''))
|
let numLeadingSpacesTabs = strlen(matchstr(bottom, '^\s*'))
|
||||||
call s:CommentBlock(a:bottomLine, a:bottomLine, numLeadingSpacesTabs+1, a:bottomCol, a:forceNested)
|
call s:CommentBlock(a:bottomLine, a:bottomLine, numLeadingSpacesTabs+1, a:bottomCol, a:forceNested)
|
||||||
|
|
||||||
endif
|
endif
|
||||||
@@ -1151,6 +1167,7 @@ endfunction
|
|||||||
" -lineNo: the line number of the line to check
|
" -lineNo: the line number of the line to check
|
||||||
" Return: Number, 1 if the line is a comment, 0 else
|
" Return: Number, 1 if the line is a comment, 0 else
|
||||||
function! nerdcommenter#IsLineCommented(lineNo) abort
|
function! nerdcommenter#IsLineCommented(lineNo) abort
|
||||||
|
call nerdcommenter#SetUp()
|
||||||
let theLine = getline(a:lineNo)
|
let theLine = getline(a:lineNo)
|
||||||
return s:IsInSexyComment(a:lineNo) || s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine)
|
return s:IsInSexyComment(a:lineNo) || s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine)
|
||||||
endfunction
|
endfunction
|
||||||
@@ -1165,10 +1182,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! nerdcommenter#Comment(mode, type) range abort
|
function! nerdcommenter#Comment(mode, type) range abort
|
||||||
call nerdcommenter#SetUp()
|
|
||||||
if exists('*NERDCommenter_before')
|
if exists('*NERDCommenter_before')
|
||||||
exe 'call NERDCommenter_before()'
|
exe 'call NERDCommenter_before()'
|
||||||
endif
|
endif
|
||||||
|
call nerdcommenter#SetUp()
|
||||||
|
|
||||||
let isVisual = a:mode =~# '[vsx]'
|
let isVisual = a:mode =~# '[vsx]'
|
||||||
|
|
||||||
@@ -1236,7 +1253,7 @@ function! nerdcommenter#Comment(mode, type) range abort
|
|||||||
for i in range(firstLine, lastLine)
|
for i in range(firstLine, lastLine)
|
||||||
let theLine = getline(i)
|
let theLine = getline(i)
|
||||||
" if have one line no comment(not include blank/whitespace-only lines), then comment all lines
|
" if have one line no comment(not include blank/whitespace-only lines), then comment all lines
|
||||||
if theLine =~# '[^ \t]\+' && !s:IsInSexyComment(firstLine) && !s:IsCommentedFromStartOfLine(s:Left(), theLine) && !s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine)
|
if theLine =~# '\S\+' && !s:IsInSexyComment(firstLine) && !s:IsCommentedFromStartOfLine(s:Left(), theLine) && !s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine)
|
||||||
let l:commentAllLines = 1
|
let l:commentAllLines = 1
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
@@ -1259,9 +1276,9 @@ function! nerdcommenter#Comment(mode, type) range abort
|
|||||||
endtry
|
endtry
|
||||||
|
|
||||||
elseif a:type ==? 'ToEOL'
|
elseif a:type ==? 'ToEOL'
|
||||||
call s:SaveScreenState()
|
let view = winsaveview()
|
||||||
call s:CommentBlock(firstLine, firstLine, col('.'), col('$')-1, 1)
|
call s:CommentBlock(firstLine, firstLine, col('.'), col('$')-1, 1)
|
||||||
call s:RestoreScreenState()
|
call winrestview(view)
|
||||||
|
|
||||||
elseif a:type ==? 'Append'
|
elseif a:type ==? 'Append'
|
||||||
call s:AppendCommentToLine()
|
call s:AppendCommentToLine()
|
||||||
@@ -1298,18 +1315,19 @@ function! nerdcommenter#Comment(mode, type) range abort
|
|||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: NERDCommentIsCharCommented(line, col) abort
|
" Function: nerdcommenter#IsCharCommented(line, col) abort
|
||||||
" Check if the character at [line, col] is inside a comment
|
" Check if the character at [line, col] is inside a comment
|
||||||
" Note the Comment delimeter it self is considered as part of the comment
|
" Note the Comment delimeter it self is considered as part of the comment
|
||||||
"
|
"
|
||||||
" Args:
|
" Args:
|
||||||
" -line the line number of the character
|
" -line the line number of the character
|
||||||
" -col the column number of the character
|
" -col the column number of the character
|
||||||
" Return: Number, 1 if the character is inside a comment, 0 if is not
|
" Return: Number, 1 if the character is inside a comment, 0 if is not
|
||||||
function! NERDCommentIsCharCommented(line, col) abort
|
function! nerdcommenter#IsCharCommented(line, col) abort
|
||||||
|
call nerdcommenter#SetUp()
|
||||||
" Function: s:searchfor(str, line, col, direction, [maxline])
|
" Function: s:searchfor(str, line, col, direction, [maxline])
|
||||||
" search str in the buffer, including the character at [line, col]
|
" search str in the buffer, including the character at [line, col]
|
||||||
" Args:
|
" Args:
|
||||||
" -str: the string for search
|
" -str: the string for search
|
||||||
" -line: the line number where search begins
|
" -line: the line number where search begins
|
||||||
" -col: the column number where search begins
|
" -col: the column number where search begins
|
||||||
@@ -1377,14 +1395,14 @@ function! NERDCommentIsCharCommented(line, col) abort
|
|||||||
let leftpos = s:searchfor(a:left, a:line, a:col, 1)
|
let leftpos = s:searchfor(a:left, a:line, a:col, 1)
|
||||||
if leftpos == [0, 0]
|
if leftpos == [0, 0]
|
||||||
if !blockcommented | let blockcommented = 0 | endif
|
if !blockcommented | let blockcommented = 0 | endif
|
||||||
else
|
else
|
||||||
" call s:searchfor(a:right, a:line, a:col, 0)
|
" call s:searchfor(a:right, a:line, a:col, 0)
|
||||||
let rightpos = s:searchfor(a:right, leftpos[0], leftpos[1] + strlen(a:right) + 1, 0)
|
let rightpos = s:searchfor(a:right, leftpos[0], leftpos[1] + strlen(a:right) + 1, 0)
|
||||||
if rightpos != [0, 0]
|
if rightpos != [0, 0]
|
||||||
if rightpos[0] < a:line
|
if rightpos[0] < a:line
|
||||||
if !blockcommented | let blockcommented = 0 | endif
|
if !blockcommented | let blockcommented = 0 | endif
|
||||||
elseif rightpos[0] == a:line
|
elseif rightpos[0] == a:line
|
||||||
if !blockcommented
|
if !blockcommented
|
||||||
let blockcommented = (rightpos[1] + strlen(a:right) > a:col) ? 1 : 0
|
let blockcommented = (rightpos[1] + strlen(a:right) > a:col) ? 1 : 0
|
||||||
endif
|
endif
|
||||||
else " rightpos > a:line
|
else " rightpos > a:line
|
||||||
@@ -1398,14 +1416,14 @@ function! NERDCommentIsCharCommented(line, col) abort
|
|||||||
return linecommented || blockcommented
|
return linecommented || blockcommented
|
||||||
endfunction
|
endfunction
|
||||||
return s:checkwith(
|
return s:checkwith(
|
||||||
\ b:NERDCommenterDelims['left'],
|
\ b:NERDCommenterDelims['left'],
|
||||||
\ b:NERDCommenterDelims['right'],
|
\ b:NERDCommenterDelims['right'],
|
||||||
\ a:line,
|
\ a:line,
|
||||||
\ a:col) ||
|
\ a:col) ||
|
||||||
\ s:checkwith(
|
\ s:checkwith(
|
||||||
\ b:NERDCommenterDelims['leftAlt'],
|
\ b:NERDCommenterDelims['leftAlt'],
|
||||||
\ b:NERDCommenterDelims['rightAlt'],
|
\ b:NERDCommenterDelims['rightAlt'],
|
||||||
\ a:line,
|
\ a:line,
|
||||||
\ a:col)
|
\ a:col)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -1417,46 +1435,20 @@ function! s:PlaceDelimitersAndInsBetween() abort
|
|||||||
let left = s:Left({'space': 1})
|
let left = s:Left({'space': 1})
|
||||||
let right = s:Right({'space': 1})
|
let right = s:Right({'space': 1})
|
||||||
|
|
||||||
let theLine = getline('.')
|
" 0. Entered insert normal mode using <C-\><C-O> (:h i_CTRL-\_CTRL-O) to
|
||||||
let lineHasLeadTabs = s:HasLeadingTabs(theLine) || (theLine =~# '^ *$' && !&expandtab)
|
" maintain the cursor position (from <Plug>NERDCommenterInsert).
|
||||||
|
" 1. Enter insert mode without changing the cursor position.
|
||||||
"convert tabs to spaces and adjust the cursors column to take this into
|
" If the cursor is on EOL (right of the last char), use 'a'.
|
||||||
"account
|
" Otherwise, use 'i'.
|
||||||
let untabbedCol = s:UntabbedCol(theLine, col('.'))
|
let insert = col('.') > strlen(getline('.')) ? 'a' : 'i'
|
||||||
call setline(line('.'), s:ConvertLeadingTabsToSpaces(theLine))
|
" 2. Insert comment delimiters.
|
||||||
call cursor(line('.'), untabbedCol)
|
" 3. Move the cursor to the left of the closing delimiter, without
|
||||||
|
" breaking undo sequence.
|
||||||
" get the length of the right delimiter
|
" 4. Enter insert normal mode again without changing the cursor position.
|
||||||
let lenRight = strlen(right)
|
" This ensures that returning to the insert mode after finishing the
|
||||||
|
" script execution does not move the cursor.
|
||||||
let isDelimOnEOL = col('.') >= strlen(getline('.'))
|
" ( 1 ) ( 2 ) ( 3 ) ( 4 )
|
||||||
|
execute 'normal!' insert . left . right . repeat("\<C-G>U\<Left>", strchars(right)) . "\<C-\>\<C-O>"
|
||||||
" if the cursor is in the first col then we gotta insert rather than
|
|
||||||
" append the comment delimiters here
|
|
||||||
let insOrApp = (col('.')==1 ? 'i' : 'a')
|
|
||||||
|
|
||||||
" place the delimiters down. We do it differently depending on whether
|
|
||||||
" there is a left AND right delimiter
|
|
||||||
if lenRight > 0
|
|
||||||
execute ':normal! ' . insOrApp . left . right
|
|
||||||
execute ':normal! ' . lenRight . 'h'
|
|
||||||
else
|
|
||||||
execute ':normal! ' . insOrApp . left
|
|
||||||
endif
|
|
||||||
|
|
||||||
"if needed convert spaces back to tabs and adjust the cursors col
|
|
||||||
"accordingly
|
|
||||||
if lineHasLeadTabs
|
|
||||||
let tabbedCol = s:TabbedCol(getline('.'), col('.'))
|
|
||||||
call setline(line('.'), s:ConvertLeadingSpacesToTabs(getline('.')))
|
|
||||||
call cursor(line('.'), tabbedCol)
|
|
||||||
endif
|
|
||||||
|
|
||||||
if isDelimOnEOL && lenRight ==# 0
|
|
||||||
startinsert!
|
|
||||||
else
|
|
||||||
call feedkeys('a', 'ni')
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: s:RemoveDelimiters(left, right, line)
|
" Function: s:RemoveDelimiters(left, right, line)
|
||||||
@@ -1671,7 +1663,7 @@ function! s:UncommentLinesSexy(topline, bottomline) abort
|
|||||||
let theLine = getline(a:topline)
|
let theLine = getline(a:topline)
|
||||||
|
|
||||||
" if the first line contains only the left delimiter then just delete it
|
" if the first line contains only the left delimiter then just delete it
|
||||||
if theLine =~# '^[ \t]*' . left . '[ \t]*$' && !g:NERDCompactSexyComs
|
if theLine =~# '^\s*' . left . '\s*$' && !g:NERDCompactSexyComs
|
||||||
call cursor(a:topline, 1)
|
call cursor(a:topline, 1)
|
||||||
normal! dd
|
normal! dd
|
||||||
let bottomline = bottomline - 1
|
let bottomline = bottomline - 1
|
||||||
@@ -1695,7 +1687,7 @@ function! s:UncommentLinesSexy(topline, bottomline) abort
|
|||||||
let theLine = getline(bottomline)
|
let theLine = getline(bottomline)
|
||||||
|
|
||||||
" if the bottomline contains only the right delimiter then just delete it
|
" if the bottomline contains only the right delimiter then just delete it
|
||||||
if theLine =~# '^[ \t]*' . right . '[ \t]*$'
|
if theLine =~# '^\s*' . right . '\s*$'
|
||||||
call cursor(bottomline, 1)
|
call cursor(bottomline, 1)
|
||||||
normal! dd
|
normal! dd
|
||||||
|
|
||||||
@@ -1712,7 +1704,7 @@ function! s:UncommentLinesSexy(topline, bottomline) abort
|
|||||||
|
|
||||||
" if the last line also starts with a sexy comment marker then we
|
" if the last line also starts with a sexy comment marker then we
|
||||||
" remove this as well
|
" remove this as well
|
||||||
if theLine =~# '^[ \t]*' . sexyComMarker
|
if theLine =~# '^\s*' . sexyComMarker
|
||||||
|
|
||||||
" remove the sexyComMarker. If there is a space after it then
|
" remove the sexyComMarker. If there is a space after it then
|
||||||
" remove that too
|
" remove that too
|
||||||
@@ -1782,6 +1774,8 @@ function! s:UncommentLineNormal(line) abort
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
let indxLeft = s:FindDelimiterIndex(s:Left(), line)
|
||||||
|
let indxLeftAlt = s:FindDelimiterIndex(s:Left({'alt': 1}), line)
|
||||||
let indxLeftPlace = s:FindDelimiterIndex(g:NERDLPlace, line)
|
let indxLeftPlace = s:FindDelimiterIndex(g:NERDLPlace, line)
|
||||||
let indxRightPlace = s:FindDelimiterIndex(g:NERDRPlace, line)
|
let indxRightPlace = s:FindDelimiterIndex(g:NERDRPlace, line)
|
||||||
|
|
||||||
@@ -1836,7 +1830,7 @@ endfunction
|
|||||||
" Function: s:AddLeftDelim(delim, theLine)
|
" Function: s:AddLeftDelim(delim, theLine)
|
||||||
" Args:
|
" Args:
|
||||||
function! s:AddLeftDelim(delim, theLine) abort
|
function! s:AddLeftDelim(delim, theLine) abort
|
||||||
return substitute(a:theLine, '^\([ \t]*\)', '\1' . a:delim, '')
|
return substitute(a:theLine, '^\(\s*\)', '\1' . a:delim, '')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: s:AddLeftDelimAligned(delim, theLine)
|
" Function: s:AddLeftDelimAligned(delim, theLine)
|
||||||
@@ -1906,7 +1900,7 @@ function! s:CanCommentLine(forceNested, lineNum) abort
|
|||||||
|
|
||||||
" 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,
|
||||||
" unless configured otherwise
|
" unless configured otherwise
|
||||||
if g:NERDCommentEmptyLines ==# 0 && theLine =~# "^[ \t]*$"
|
if g:NERDCommentEmptyLines ==# 0 && theLine =~# '^\s*$'
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -1973,7 +1967,7 @@ function! s:CanToggleCommentLine(forceNested, lineNum) abort
|
|||||||
|
|
||||||
" 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,
|
||||||
" unless configured otherwise
|
" unless configured otherwise
|
||||||
if g:NERDCommentEmptyLines ==# 0 && theLine =~# "^[ \t]*$"
|
if g:NERDCommentEmptyLines ==# 0 && theLine =~# '^\s*$'
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -2194,16 +2188,16 @@ function! s:FindBoundingLinesOfSexyCom(lineNum) abort
|
|||||||
let theLine = getline(currentLine)
|
let theLine = getline(currentLine)
|
||||||
|
|
||||||
"check if the current line is the top of the sexy comment
|
"check if the current line is the top of the sexy comment
|
||||||
if currentLine <= a:lineNum && theLine =~# '^[ \t]*' . left && theLine !~# '.*' . right && currentLine < s:NumLinesInBuf()
|
if currentLine <= a:lineNum && theLine =~# '^\s*' . left && theLine !~# '.*' . right && currentLine < s:NumLinesInBuf()
|
||||||
let top = currentLine
|
let top = currentLine
|
||||||
let currentLine = a:lineNum
|
let currentLine = a:lineNum
|
||||||
|
|
||||||
"check if the current line is the bottom of the sexy comment
|
"check if the current line is the bottom of the sexy comment
|
||||||
elseif theLine =~# '^[ \t]*' . right && theLine !~# '.*' . left && currentLine > 1
|
elseif theLine =~# '^\s*' . right && theLine !~# '.*' . left && currentLine > 1
|
||||||
let bottom = currentLine
|
let bottom = currentLine
|
||||||
|
|
||||||
"the right delimiter is on the same line as the last sexyComMarker
|
"the right delimiter is on the same line as the last sexyComMarker
|
||||||
elseif theLine =~# '^[ \t]*' . sexyComMarker . '.*' . right
|
elseif theLine =~# '^\s*' . sexyComMarker . '.*' . right
|
||||||
let bottom = currentLine
|
let bottom = currentLine
|
||||||
|
|
||||||
"we have not found the top or bottom line so we assume currentLine is an
|
"we have not found the top or bottom line so we assume currentLine is an
|
||||||
@@ -2212,7 +2206,7 @@ function! s:FindBoundingLinesOfSexyCom(lineNum) abort
|
|||||||
|
|
||||||
"if the line doesn't start with a sexyComMarker then it is not a sexy
|
"if the line doesn't start with a sexyComMarker then it is not a sexy
|
||||||
"comment
|
"comment
|
||||||
if theLine !~# '^[ \t]*' . sexyComMarker
|
if theLine !~# '^\s*' . sexyComMarker
|
||||||
return []
|
return []
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -2450,7 +2444,7 @@ endfunction
|
|||||||
" -left: the left delimiter to check for
|
" -left: the left delimiter to check for
|
||||||
function! s:IsCommentedFromStartOfLine(left, line) abort
|
function! s:IsCommentedFromStartOfLine(left, line) abort
|
||||||
let theLine = s:ConvertLeadingTabsToSpaces(a:line)
|
let theLine = s:ConvertLeadingTabsToSpaces(a:line)
|
||||||
let numSpaces = strlen(substitute(theLine, '^\( *\).*$', '\1', ''))
|
let numSpaces = strlen(matchstr(theLine, '^ *'))
|
||||||
let delimIndx = s:FindDelimiterIndex(a:left, theLine)
|
let delimIndx = s:FindDelimiterIndex(a:left, theLine)
|
||||||
return delimIndx ==# numSpaces
|
return delimIndx ==# numSpaces
|
||||||
endfunction
|
endfunction
|
||||||
@@ -2544,15 +2538,15 @@ function! s:IsDelimValid(delimiter, delIndx, line) abort
|
|||||||
|
|
||||||
"vim comments are so fucking stupid!! Why the hell do they have comment
|
"vim comments are so fucking stupid!! Why the hell do they have comment
|
||||||
"delimiters that are used elsewhere in the syntax?!?! We need to check
|
"delimiters that are used elsewhere in the syntax?!?! We need to check
|
||||||
"some conditions especially for vim
|
"some conditions especially for vim.
|
||||||
if &filetype ==# 'vim'
|
"Also check &commentstring because it may be overwritten for embedded lua.
|
||||||
|
if &filetype ==# 'vim' && &commentstring[0] ==# '"'
|
||||||
if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, '"', "\\"))
|
if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, '"', "\\"))
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"if the delimiter is on the very first char of the line or is the
|
" if the delimiter is the first non-whitespace character, it is valid
|
||||||
"first non-tab/space char on the line then it is a valid comment delimiter
|
if a:line =~# '^\s*"'
|
||||||
if a:delIndx ==# 0 || a:line =~# "^[ \t]\\{" . a:delIndx . "\\}\".*$"
|
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -2653,7 +2647,7 @@ function! s:IsSexyComment(topline, bottomline) abort
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
"if the top line doesn't begin with a left delimiter then the comment isn't sexy
|
"if the top line doesn't begin with a left delimiter then the comment isn't sexy
|
||||||
if getline(a:topline) !~# '^[ \t]*' . left
|
if getline(a:topline) !~# '^\s*' . left
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -2681,7 +2675,7 @@ function! s:IsSexyComment(topline, bottomline) abort
|
|||||||
while currentLine < a:bottomline
|
while currentLine < a:bottomline
|
||||||
let theLine = getline(currentLine)
|
let theLine = getline(currentLine)
|
||||||
|
|
||||||
if theLine !~# '^[ \t]*' . sexyComMarker
|
if theLine !~# '^\s*' . sexyComMarker
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -2780,12 +2774,12 @@ function! s:LeftMostIndx(countCommentedLines, countEmptyLines, topline, bottomli
|
|||||||
" get the next line and if it is allowed to be commented, or is not
|
" get the next line and if it is allowed to be commented, or is not
|
||||||
" commented, check it
|
" commented, check it
|
||||||
let theLine = getline(currentLine)
|
let theLine = getline(currentLine)
|
||||||
if a:countEmptyLines || theLine !~# '^[ \t]*$'
|
if a:countEmptyLines || theLine !~# '^\s*$'
|
||||||
if a:countCommentedLines || (!s:IsCommented(s:Left(), s:Right(), theLine) && !s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), theLine))
|
if a:countCommentedLines || (!s:IsCommented(s:Left(), s:Right(), theLine) && !s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), theLine))
|
||||||
" convert spaces to tabs and get the number of leading spaces for
|
" convert spaces to tabs and get the number of leading spaces for
|
||||||
" this line and update leftMostIndx if need be
|
" this line and update leftMostIndx if need be
|
||||||
let theLine = s:ConvertLeadingTabsToSpaces(theLine)
|
let theLine = s:ConvertLeadingTabsToSpaces(theLine)
|
||||||
let leadSpaceOfLine = strlen( substitute(theLine, '\(^[ \t]*\).*$','\1','') )
|
let leadSpaceOfLine = strlen(matchstr(theLine, '^\s*'))
|
||||||
if leadSpaceOfLine < leftMostIndx
|
if leadSpaceOfLine < leftMostIndx
|
||||||
let leftMostIndx = leadSpaceOfLine
|
let leftMostIndx = leadSpaceOfLine
|
||||||
endif
|
endif
|
||||||
@@ -2833,7 +2827,7 @@ endfunction
|
|||||||
" Function: s:NumberOfLeadingTabs(s)
|
" Function: s:NumberOfLeadingTabs(s)
|
||||||
" returns the number of leading tabs in the given string
|
" returns the number of leading tabs in the given string
|
||||||
function! s:NumberOfLeadingTabs(s) abort
|
function! s:NumberOfLeadingTabs(s) abort
|
||||||
return strlen(substitute(a:s, '^\(\t*\).*$', '\1', ''))
|
return strlen(matchstr(a:s, '^\t*'))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: s:NumLinesInBuf()
|
" Function: s:NumLinesInBuf()
|
||||||
@@ -2907,21 +2901,6 @@ function! s:ReplaceRightMostDelim(toReplace, replacor, str) abort
|
|||||||
return line
|
return line
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:RestoreScreenState()
|
|
||||||
"
|
|
||||||
"Sets the screen state back to what it was when s:SaveScreenState was last
|
|
||||||
"called.
|
|
||||||
"
|
|
||||||
function! s:RestoreScreenState() abort
|
|
||||||
if !exists('t:NERDComOldTopLine') || !exists('t:NERDComOldPos')
|
|
||||||
throw 'NERDCommenter exception: cannot restore screen'
|
|
||||||
endif
|
|
||||||
|
|
||||||
call cursor(t:NERDComOldTopLine, 0)
|
|
||||||
normal! zt
|
|
||||||
call setpos('.', t:NERDComOldPos)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:Right(...)
|
" Function: s:Right(...)
|
||||||
" returns right delimiter data
|
" returns right delimiter data
|
||||||
function! s:Right(...) abort
|
function! s:Right(...) abort
|
||||||
@@ -2963,7 +2942,7 @@ function! s:RightMostIndx(countCommentedLines, countEmptyLines, topline, bottoml
|
|||||||
" get the next line and see if it is commentable, otherwise it doesn't
|
" get the next line and see if it is commentable, otherwise it doesn't
|
||||||
" count
|
" count
|
||||||
let theLine = getline(currentLine)
|
let theLine = getline(currentLine)
|
||||||
if a:countEmptyLines || theLine !~# '^[ \t]*$'
|
if a:countEmptyLines || theLine !~# '^\s*$'
|
||||||
|
|
||||||
if a:countCommentedLines || (!s:IsCommented(s:Left(), s:Right(), theLine) && !s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), theLine))
|
if a:countCommentedLines || (!s:IsCommented(s:Left(), s:Right(), theLine) && !s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), theLine))
|
||||||
|
|
||||||
@@ -2983,14 +2962,6 @@ function! s:RightMostIndx(countCommentedLines, countEmptyLines, topline, bottoml
|
|||||||
return rightMostIndx
|
return rightMostIndx
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"FUNCTION: s:SaveScreenState()
|
|
||||||
"Saves the current cursor position in the current buffer and the window
|
|
||||||
"scroll position
|
|
||||||
function! s:SaveScreenState() abort
|
|
||||||
let t:NERDComOldPos = getpos('.')
|
|
||||||
let t:NERDComOldTopLine = line('w0')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Function: s:SwapOuterMultiPartDelimsForPlaceHolders(line)
|
" Function: s:SwapOuterMultiPartDelimsForPlaceHolders(line)
|
||||||
" This function takes a line and swaps the outer most multi-part delimiters for
|
" This function takes a line and swaps the outer most multi-part delimiters for
|
||||||
" place holders
|
" place holders
|
||||||
@@ -3040,18 +3011,6 @@ function! s:SwapOuterPlaceHoldersForMultiPartDelims(line) abort
|
|||||||
return line
|
return line
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: s:TabbedCol(line, col)
|
|
||||||
" Gets the col number for given line and existing col number. The new col
|
|
||||||
" number is the col number when all leading spaces are converted to tabs
|
|
||||||
" Args:
|
|
||||||
" -line:the line to get the rel col for
|
|
||||||
" -col: the abs col
|
|
||||||
function! s:TabbedCol(line, col) abort
|
|
||||||
let lineTruncated = strpart(a:line, 0, a:col)
|
|
||||||
let lineSpacesToTabs = substitute(lineTruncated, s:TabSpace(), '\t', 'g')
|
|
||||||
return strlen(lineSpacesToTabs)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
"FUNCTION: s:TabSpace()
|
"FUNCTION: s:TabSpace()
|
||||||
"returns a string of spaces equal in length to &tabstop
|
"returns a string of spaces equal in length to &tabstop
|
||||||
function! s:TabSpace() abort
|
function! s:TabSpace() abort
|
||||||
@@ -3072,15 +3031,3 @@ endfunction
|
|||||||
function! s:UnEsc(str, escChar) abort
|
function! s:UnEsc(str, escChar) abort
|
||||||
return substitute(a:str, a:escChar, '', 'g')
|
return substitute(a:str, a:escChar, '', 'g')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: s:UntabbedCol(line, col)
|
|
||||||
" Takes a line and a col and returns the absolute column of col taking into
|
|
||||||
" account that a tab is worth 3 or 4 (or whatever) spaces.
|
|
||||||
" Args:
|
|
||||||
" -line:the line to get the abs col for
|
|
||||||
" -col: the col that doesn't take into account tabs
|
|
||||||
function! s:UntabbedCol(line, col) abort
|
|
||||||
let lineTruncated = strpart(a:line, 0, a:col)
|
|
||||||
let lineTabsToSpaces = substitute(lineTruncated, '\t', s:TabSpace(), 'g')
|
|
||||||
return strlen(lineTabsToSpaces)
|
|
||||||
endfunction
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
*nerdcommenter.txt* Plugin for commenting code
|
*nerdcommenter.txt* Plugin for commenting code
|
||||||
|
|
||||||
|
|
||||||
NERD COMMENTER REFERENCE MANUAL
|
NERD COMMENTER REFERENCE MANUAL~
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ CONTENTS *NERDCommenterContents*
|
|||||||
11.License................................|NERDCommenterLicense|
|
11.License................................|NERDCommenterLicense|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
1. Intro *NERDCommenter*
|
1. Intro *NERDCommenter*
|
||||||
|
|
||||||
The NERD commenter provides many different commenting operations and styles
|
The NERD commenter provides many different commenting operations and styles
|
||||||
which are invoked via key mappings and a menu. These operations are available
|
which are invoked via key mappings and a menu. These operations are available
|
||||||
@@ -58,7 +58,7 @@ There are also options that allow to tweak the commenting engine to your
|
|||||||
taste.
|
taste.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
1.1 Leader key *NERDCommenterLeader*
|
1.1 Leader key *NERDCommenterLeader*
|
||||||
|
|
||||||
Most NERD commenter commands are executed using the |<Leader>| key. In Vim
|
Most NERD commenter commands are executed using the |<Leader>| key. In Vim
|
||||||
this is a key dedicated for user-specific customizations. It effectively
|
this is a key dedicated for user-specific customizations. It effectively
|
||||||
@@ -66,13 +66,13 @@ creates a namespace so that custom commands don't interfere with Vim's
|
|||||||
built-in shortcuts.
|
built-in shortcuts.
|
||||||
|
|
||||||
The leader key can be mapped to whatever the user likes (see :help mapleader).
|
The leader key can be mapped to whatever the user likes (see :help mapleader).
|
||||||
In the definition of custom commands |<Leader>| is the placeholder for the
|
In the definition of custom commands |<Leader>| is the placeholder for the
|
||||||
leader key. To see the current mapping for |<Leader>| type :echo mapleader.
|
leader key. To see the current mapping for |<Leader>| type :echo mapleader.
|
||||||
If it reports an undefined variable it means the leader key is set to the
|
If it reports an undefined variable it means the leader key is set to the
|
||||||
default of '\'.
|
default of '\'.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
2. Installation *NERDCommenterInstallation*
|
2. Installation *NERDCommenterInstallation*
|
||||||
|
|
||||||
The NERD Commenter requires Vim 7 or higher.
|
The NERD Commenter requires Vim 7 or higher.
|
||||||
|
|
||||||
@@ -93,10 +93,10 @@ See |filetype-plugin-on| for details, but basically, stick this in your vimrc >
|
|||||||
<
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
3. Functionality provided *NERDCommenterFunctionality*
|
3. Functionality provided *NERDCommenterFunctionality*
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.1 Functionality summary *NERDCommenterFunctionalitySummary*
|
3.1 Functionality summary *NERDCommenterFunctionalitySummary*
|
||||||
|
|
||||||
The following key mappings are provided by default (there is also a menu
|
The following key mappings are provided by default (there is also a menu
|
||||||
with items corresponding to all the mappings below):
|
with items corresponding to all the mappings below):
|
||||||
@@ -162,10 +162,10 @@ With the optional repeat.vim plugin (vimscript #2136), the mappings can also
|
|||||||
be repeated via |.|
|
be repeated via |.|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.2 Functionality details *NERDCommenterFunctionalityDetails*
|
3.2 Functionality details *NERDCommenterFunctionalityDetails*
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.2.1 Comment map *NERDCommenterComment*
|
3.2.1 Comment map *NERDCommenterComment*
|
||||||
|
|
||||||
Default mapping: [count]|<Leader>|cc
|
Default mapping: [count]|<Leader>|cc
|
||||||
Mapped to: <plug>NERDCommenterComment
|
Mapped to: <plug>NERDCommenterComment
|
||||||
@@ -181,7 +181,7 @@ If a [count] is given in normal mode, the mapping works as though that many
|
|||||||
lines were selected in visual-line mode.
|
lines were selected in visual-line mode.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.2.2 Nested comment map *NERDCommenterNested*
|
3.2.2 Nested comment map *NERDCommenterNested*
|
||||||
|
|
||||||
Default mapping: [count]|<Leader>|cn
|
Default mapping: [count]|<Leader>|cn
|
||||||
Mapped to: <plug>NERDCommenterNested
|
Mapped to: <plug>NERDCommenterNested
|
||||||
@@ -202,7 +202,7 @@ Related options:
|
|||||||
|'NERDDefaultNesting'|
|
|'NERDDefaultNesting'|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.2.3 Toggle comment map *NERDCommenterToggle*
|
3.2.3 Toggle comment map *NERDCommenterToggle*
|
||||||
|
|
||||||
Default mapping: [count]|<Leader>|c<space>
|
Default mapping: [count]|<Leader>|c<space>
|
||||||
Mapped to: <plug>NERDCommenterToggle
|
Mapped to: <plug>NERDCommenterToggle
|
||||||
@@ -219,7 +219,7 @@ If a [count] is given in normal mode, the mapping works as though that many
|
|||||||
lines were selected in visual-line mode.
|
lines were selected in visual-line mode.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.2.4 Minimal comment map *NERDCommenterMinimal*
|
3.2.4 Minimal comment map *NERDCommenterMinimal*
|
||||||
|
|
||||||
Default mapping: [count]|<Leader>|cm
|
Default mapping: [count]|<Leader>|cm
|
||||||
Mapped to: <plug>NERDCommenterMinimal
|
Mapped to: <plug>NERDCommenterMinimal
|
||||||
@@ -241,7 +241,7 @@ If a [count] is given in normal mode, the mapping works as though that many
|
|||||||
lines were selected in visual-line mode.
|
lines were selected in visual-line mode.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.2.5 Invert comment map *NERDCommenterInvert*
|
3.2.5 Invert comment map *NERDCommenterInvert*
|
||||||
|
|
||||||
Default mapping: |<Leader>|ci
|
Default mapping: |<Leader>|ci
|
||||||
Mapped to: <plug>NERDCommenterInvert
|
Mapped to: <plug>NERDCommenterInvert
|
||||||
@@ -258,7 +258,7 @@ If a [count] is given in normal mode, the mapping works as though that many
|
|||||||
lines were selected in visual-line mode.
|
lines were selected in visual-line mode.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.2.6 Sexy comment map *NERDCommenterSexy*
|
3.2.6 Sexy comment map *NERDCommenterSexy*
|
||||||
|
|
||||||
Default mapping: [count]|<Leader>|cs
|
Default mapping: [count]|<Leader>|cs
|
||||||
Mapped to: <plug>NERDCommenterSexy
|
Mapped to: <plug>NERDCommenterSexy
|
||||||
@@ -278,7 +278,7 @@ Related options:
|
|||||||
|'NERDCompactSexyComs'|
|
|'NERDCompactSexyComs'|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.2.7 Yank comment map *NERDCommenterYank*
|
3.2.7 Yank comment map *NERDCommenterYank*
|
||||||
|
|
||||||
Default mapping: [count]|<Leader>|cy
|
Default mapping: [count]|<Leader>|cy
|
||||||
Mapped to: <plug>NERDCommenterYank
|
Mapped to: <plug>NERDCommenterYank
|
||||||
@@ -287,7 +287,7 @@ Applicable modes: normal visual visual-line visual-block.
|
|||||||
Same as |<Leader>|cc except that it yanks the line(s) that are commented first.
|
Same as |<Leader>|cc except that it yanks the line(s) that are commented first.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.2.8 Comment to EOL map *NERDCommenterToEOL*
|
3.2.8 Comment to EOL map *NERDCommenterToEOL*
|
||||||
|
|
||||||
Default mapping: |<Leader>|c$
|
Default mapping: |<Leader>|c$
|
||||||
Mapped to: <plug>NERDCommenterToEOL
|
Mapped to: <plug>NERDCommenterToEOL
|
||||||
@@ -297,7 +297,7 @@ Comments the current line from the current cursor position up to the end of
|
|||||||
the line.
|
the line.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.2.9 Append com to line map *NERDCommenterAppend*
|
3.2.9 Append com to line map *NERDCommenterAppend*
|
||||||
|
|
||||||
Default mapping: |<Leader>|cA
|
Default mapping: |<Leader>|cA
|
||||||
Mapped to: <plug>NERDCommenterAppend
|
Mapped to: <plug>NERDCommenterAppend
|
||||||
@@ -307,7 +307,7 @@ Appends comment delimiters to the end of the current line and goes
|
|||||||
to insert mode between the new delimiters.
|
to insert mode between the new delimiters.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.2.10 Insert comment map *NERDCommenterInsert*
|
3.2.10 Insert comment map *NERDCommenterInsert*
|
||||||
|
|
||||||
Default mapping: disabled by default.
|
Default mapping: disabled by default.
|
||||||
Map it to: <plug>NERDCommenterInsert
|
Map it to: <plug>NERDCommenterInsert
|
||||||
@@ -323,7 +323,7 @@ mapping add >
|
|||||||
to your vimrc.
|
to your vimrc.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.2.11 Use alternate delims map *NERDCommenterAltDelims*
|
3.2.11 Use alternate delims map *NERDCommenterAltDelims*
|
||||||
|
|
||||||
Default mapping: |<Leader>|ca
|
Default mapping: |<Leader>|ca
|
||||||
Mapped to: <plug>NERDCommenterAltDelims
|
Mapped to: <plug>NERDCommenterAltDelims
|
||||||
@@ -336,8 +336,8 @@ then they will be switched over to /**/ comments.
|
|||||||
See also |NERDCommenterDefaultDelims|
|
See also |NERDCommenterDefaultDelims|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.2.12 Comment aligned maps *NERDCommenterAlignLeft*
|
3.2.12 Comment aligned maps *NERDCommenterAlignLeft*
|
||||||
*NERDCommenterAlignBoth*
|
*NERDCommenterAlignBoth*
|
||||||
|
|
||||||
Default mappings: [count]|<Leader>|cl [count]|<Leader>|cb
|
Default mappings: [count]|<Leader>|cl [count]|<Leader>|cb
|
||||||
Mapped to: <plug>NERDCommenterAlignLeft
|
Mapped to: <plug>NERDCommenterAlignLeft
|
||||||
@@ -352,7 +352,7 @@ If a [count] is given in normal mode, the mapping works as though that many
|
|||||||
lines were selected in visual-line mode.
|
lines were selected in visual-line mode.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.2.13 Uncomment line map *NERDCommenterUncomment*
|
3.2.13 Uncomment line map *NERDCommenterUncomment*
|
||||||
|
|
||||||
Default mapping: [count]|<Leader>|cu
|
Default mapping: [count]|<Leader>|cu
|
||||||
Mapped to: <plug>NERDCommenterUncomment
|
Mapped to: <plug>NERDCommenterUncomment
|
||||||
@@ -375,7 +375,7 @@ Related options:
|
|||||||
|'NERDRemoveExtraSpaces'|
|
|'NERDRemoveExtraSpaces'|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.3 Sexy Comments *NERDCommenterSexyComments*
|
3.3 Sexy Comments *NERDCommenterSexyComments*
|
||||||
These are comments that use one set of multipart comment delimiters as well as
|
These are comments that use one set of multipart comment delimiters as well as
|
||||||
one other marker symbol. For example: >
|
one other marker symbol. For example: >
|
||||||
/*
|
/*
|
||||||
@@ -390,7 +390,7 @@ one other marker symbol. For example: >
|
|||||||
Here the multipart delimiters are /* and */ and the marker is *.
|
Here the multipart delimiters are /* and */ and the marker is *.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.4 The NERDComment function *NERDCommenterNERDComment*
|
3.4 The NERDComment function *NERDCommenterNERDComment*
|
||||||
|
|
||||||
All of the NERD commenter mappings and menu items invoke a single function
|
All of the NERD commenter mappings and menu items invoke a single function
|
||||||
which delegates the commenting work to other functions. This function is
|
which delegates the commenting work to other functions. This function is
|
||||||
@@ -411,7 +411,7 @@ 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 *NERDCommenterHooks*
|
3.5 The hooks *NERDCommenterHooks*
|
||||||
|fu! NERDCommenter_before()| Before NERDComment/SwitchToAlternativeDelimiters
|
|fu! NERDCommenter_before()| Before NERDComment/SwitchToAlternativeDelimiters
|
||||||
|fu! NERDCommenter_after()| After NERDComment/SwitchToAlternativeDelimiters
|
|fu! NERDCommenter_after()| After NERDComment/SwitchToAlternativeDelimiters
|
||||||
|
|
||||||
@@ -441,10 +441,10 @@ change the filetype back: >
|
|||||||
<
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
4. Options *NERDCommenterOptions*
|
4. Options *NERDCommenterOptions*
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
4.1 Options summary *NERDCommenterOptionsSummary*
|
4.1 Options summary *NERDCommenterOptionsSummary*
|
||||||
|
|
||||||
|'loaded_nerd_comments'| Turns off the script.
|
|'loaded_nerd_comments'| Turns off the script.
|
||||||
|
|
||||||
@@ -464,38 +464,38 @@ change the filetype back: >
|
|||||||
|
|
||||||
|'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
|
|'NERDTrimTrailingWhitespace'| Specifies if trailing whitespace
|
||||||
should be deleted when uncommenting.
|
should be deleted when uncommenting.
|
||||||
|
|
||||||
@@ -506,16 +506,16 @@ change the filetype back: >
|
|||||||
one of 'none', 'left', 'start', or
|
one of 'none', 'left', 'start', or
|
||||||
'both'.
|
'both'.
|
||||||
|
|
||||||
|'NERDToggleCheckAllLines'| Enable NERDCommenterToggle to check
|
|'NERDToggleCheckAllLines'| Enable NERDCommenterToggle to check
|
||||||
all selected lines is commented or not.
|
all selected lines is commented or not.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
4.3 Options details *NERDCommenterOptionsDetails*
|
4.2 Options details *NERDCommenterOptionsDetails*
|
||||||
|
|
||||||
To enable any of the below options you should put the given line in your
|
To enable any of the below options you should put the given line in your
|
||||||
~/.vimrc
|
~/.vimrc
|
||||||
|
|
||||||
*'loaded_nerd_comments'*
|
*'loaded_nerd_comments'*
|
||||||
If this script is driving you insane you can turn it off by setting this
|
If this script is driving you insane you can turn it off by setting this
|
||||||
option >
|
option >
|
||||||
let loaded_nerd_comments=1
|
let loaded_nerd_comments=1
|
||||||
@@ -587,7 +587,7 @@ Otherwise, the code block would become: >
|
|||||||
/*} */
|
/*} */
|
||||||
<
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'NERDCommentEmptyLines'*
|
*'NERDCommentEmptyLines'*
|
||||||
Values: 0 or 1.
|
Values: 0 or 1.
|
||||||
Default: 0.
|
Default: 0.
|
||||||
|
|
||||||
@@ -638,7 +638,7 @@ Note that this option does not affect the behaviour of commenting in
|
|||||||
|visual-block| mode.
|
|visual-block| mode.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'NERDCreateDefaultMappings'*
|
*'NERDCreateDefaultMappings'*
|
||||||
Values: 0 or 1.
|
Values: 0 or 1.
|
||||||
Default: 1.
|
Default: 1.
|
||||||
|
|
||||||
@@ -647,7 +647,7 @@ If set to 0, none of the default mappings will be created.
|
|||||||
See also |NERDCommenterMappings|.
|
See also |NERDCommenterMappings|.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'NERDCustomDelimiters'*
|
*'NERDCustomDelimiters'*
|
||||||
Values: A map (format specified below).
|
Values: A map (format specified below).
|
||||||
Default: {}
|
Default: {}
|
||||||
|
|
||||||
@@ -783,7 +783,7 @@ alignment padding. With this option enabled any trailing whitespace will be
|
|||||||
deleted when uncommenting a line.
|
deleted when uncommenting a line.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'NERDDefaultAlign'*
|
*'NERDDefaultAlign'*
|
||||||
Values: 'none', 'left', 'start', 'both'
|
Values: 'none', 'left', 'start', 'both'
|
||||||
Default 'none'.
|
Default 'none'.
|
||||||
|
|
||||||
@@ -822,7 +822,7 @@ you hit |<Leader>|cc on a line that is already commented it will be commented
|
|||||||
again.
|
again.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
.. *'NERDToggleCheckAllLines'*
|
*'NERDToggleCheckAllLines'*
|
||||||
Values: 0 or 1.
|
Values: 0 or 1.
|
||||||
Default 0.
|
Default 0.
|
||||||
|
|
||||||
@@ -830,7 +830,7 @@ When this option is set to 1, NERDCommenterToggle will check all selected line,
|
|||||||
if there have oneline not be commented, then comment all lines.
|
if there have oneline not be commented, then comment all lines.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
.. *'NERDDisableTabsInBlockComm'*
|
*'NERDDisableTabsInBlockComm'*
|
||||||
Values: 0 or 1.
|
Values: 0 or 1.
|
||||||
Default 0.
|
Default 0.
|
||||||
|
|
||||||
@@ -855,7 +855,7 @@ file by the following line >
|
|||||||
<
|
<
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.3 Default delimiter customisation *NERDCommenterDefaultDelims*
|
4.3 Default delimiter customisation *NERDCommenterDefaultDelims*
|
||||||
|
|
||||||
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: >
|
||||||
@@ -869,7 +869,7 @@ Example: java uses // style comments by default, but you want it to default to
|
|||||||
See |NERDCommenterAltDelims| for switching commenting styles at runtime.
|
See |NERDCommenterAltDelims| for switching commenting styles at runtime.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
5. Key mapping customisation *NERDCommenterMappings*
|
5. Key mapping customisation *NERDCommenterMappings*
|
||||||
|
|
||||||
To change a mapping just map another key combo to the internal <plug> mapping.
|
To change a mapping just map another key combo to the internal <plug> mapping.
|
||||||
For example, to remap the |NERDCommenterComment| mapping to ",omg" you would put
|
For example, to remap the |NERDCommenterComment| mapping to ",omg" you would put
|
||||||
@@ -884,9 +884,9 @@ map to.
|
|||||||
See also |'NERDCreateDefaultMappings'|.
|
See also |'NERDCreateDefaultMappings'|.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
6. Interfaces *NERDCommenterInterfaces*
|
6. Interfaces *NERDCommenterInterfaces*
|
||||||
|
|
||||||
NERDCommentIsLineCommented({lineNo}) *NERDCommentIsLineCommented()*
|
NERDCommentIsLineCommented({lineNo}) *NERDCommentIsLineCommented()*
|
||||||
Check if the line is a comment
|
Check if the line is a comment
|
||||||
Note this function checks if the line is **completely** a comment
|
Note this function checks if the line is **completely** a comment
|
||||||
Args:
|
Args:
|
||||||
@@ -894,22 +894,22 @@ NERDCommentIsLineCommented({lineNo}) *NERDCommentIsLineCommented()*
|
|||||||
Return: Number, 1 if the line is a comment, 0 else
|
Return: Number, 1 if the line is a comment, 0 else
|
||||||
|
|
||||||
|
|
||||||
NERDComment({mode}, {type}) *NERDComment()*
|
NERDComment({mode}, {type}) *NERDComment()*
|
||||||
This function is a Wrapper for the main commenting functions
|
This function is a Wrapper for the main commenting functions
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
{mode}: character indicating the mode in which the comment
|
{mode}: character indicating the mode in which the comment
|
||||||
is requested:
|
is requested:
|
||||||
'n' for Normal mode, 'x' for Visual mode
|
'n' for Normal mode, 'x' for Visual mode
|
||||||
{type}: the type of commenting requested. Can be 'Sexy',
|
{type}: the type of commenting requested. Can be 'Sexy',
|
||||||
'Invert', 'Minimal', 'Toggle', 'AlignLeft',
|
'Invert', 'Minimal', 'Toggle', 'AlignLeft',
|
||||||
'AlignBoth', 'Comment', 'Nested', 'ToEOL', 'Append',
|
'AlignBoth', 'Comment', 'Nested', 'ToEOL', 'Append',
|
||||||
'Insert', 'Uncomment', 'Yank'
|
'Insert', 'Uncomment', 'Yank'
|
||||||
|
|
||||||
|
|
||||||
NERDCommentIsCharCommented({line}, {col}) *NERDCommentIsCharCommented()*
|
NERDCommentIsCharCommented({line}, {col}) *NERDCommentIsCharCommented()*
|
||||||
Check if the character at [{line}, {col}] is inside a comment
|
Check if the character at [{line}, {col}] is inside a comment
|
||||||
Note the Comment delimeter it self is considered as part of the
|
Note the Comment delimeter it self is considered as part of the
|
||||||
comment
|
comment
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -919,11 +919,11 @@ NERDCommentIsCharCommented({line}, {col}) *NERDCommentIsCharCommented()*
|
|||||||
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
7. Issues with the script *NERDCommenterIssues*
|
7. Issues with the script *NERDCommenterIssues*
|
||||||
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
7.1 Delimiter detection heuristics *NERDCommenterHeuristics*
|
7.1 Delimiter detection heuristics *NERDCommenterHeuristics*
|
||||||
|
|
||||||
Heuristics are used to distinguish the real comment delimiters
|
Heuristics are used to distinguish the real comment delimiters
|
||||||
|
|
||||||
@@ -943,7 +943,7 @@ string. These heuristics, while usually pretty accurate, will not work for all
|
|||||||
cases.
|
cases.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
7.2 Nesting issues *NERDCommenterNesting*
|
7.2 Nesting issues *NERDCommenterNesting*
|
||||||
|
|
||||||
If we have some line of code like this: >
|
If we have some line of code like this: >
|
||||||
/*int foo */ = /*5 + 9;*/
|
/*int foo */ = /*5 + 9;*/
|
||||||
@@ -963,7 +963,7 @@ will become: >
|
|||||||
for simplicity)
|
for simplicity)
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
8. About *NERDCommenterAbout*
|
8. About *NERDCommenterAbout*
|
||||||
|
|
||||||
This plugin was originally written in 2007 by Martin Grenfell, aka @scrooloose
|
This plugin was originally written in 2007 by Martin Grenfell, aka @scrooloose
|
||||||
on Github: https://github.com/scrooloose
|
on Github: https://github.com/scrooloose
|
||||||
@@ -980,7 +980,7 @@ yourself please also feel free to open issues to report problems or request
|
|||||||
features: https://github.com/preservim/nerdcommenter
|
features: https://github.com/preservim/nerdcommenter
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
9. Changelog *NERDCommenterChangelog*
|
9. Changelog *NERDCommenterChangelog*
|
||||||
|
|
||||||
See the included CHANGELOG.md file or the Github Releases page for the latest
|
See the included CHANGELOG.md file or the Github Releases page for the latest
|
||||||
info on tagged releases. https://github.com/preservim/nerdcommenter/releases
|
info on tagged releases. https://github.com/preservim/nerdcommenter/releases
|
||||||
@@ -989,7 +989,7 @@ The `master` branch is considered stable and will have the latest filetype
|
|||||||
support and bugfixes.
|
support and bugfixes.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
10. Credits *NERDCommenterCredits*
|
10. Credits *NERDCommenterCredits*
|
||||||
|
|
||||||
Well over 100 people have contributed towards this plugin, it's functions, and
|
Well over 100 people have contributed towards this plugin, it's functions, and
|
||||||
specific filetype support. Please check out the up do date list of all
|
specific filetype support. Please check out the up do date list of all
|
||||||
@@ -998,7 +998,7 @@ contributors on Github:
|
|||||||
https://github.com/preservim/nerdcommenter/graphs/contributors
|
https://github.com/preservim/nerdcommenter/graphs/contributors
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
11. License *NERDCommenterLicense*
|
11. License *NERDCommenterLicense*
|
||||||
|
|
||||||
NERD Commenter is released under the Creative-Commons CCO 1.0 Universal
|
NERD Commenter is released under the Creative-Commons CCO 1.0 Universal
|
||||||
license. See the included LICENSE file for details.
|
license. See the included LICENE file for details.
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ call s:InitVariable('g:NERDDefaultAlign', 'none')
|
|||||||
call s:InitVariable('g:NERDTrimTrailingWhitespace', 0)
|
call s:InitVariable('g:NERDTrimTrailingWhitespace', 0)
|
||||||
call s:InitVariable('g:NERDToggleCheckAllLines', 0)
|
call s:InitVariable('g:NERDToggleCheckAllLines', 0)
|
||||||
call s:InitVariable('g:NERDDisableTabsInBlockComm', 0)
|
call s:InitVariable('g:NERDDisableTabsInBlockComm', 0)
|
||||||
|
call s:InitVariable('g:NERDSuppressWarnings', 0)
|
||||||
|
|
||||||
" Section: Comment mapping and menu item setup
|
" Section: Comment mapping and menu item setup
|
||||||
" ===========================================================================
|
" ===========================================================================
|
||||||
@@ -78,6 +79,7 @@ function! s:CreateMaps(modes, target, desc, combo)
|
|||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call s:CreateMaps('nx', 'Comment', 'Comment', 'cc')
|
call s:CreateMaps('nx', 'Comment', 'Comment', 'cc')
|
||||||
call s:CreateMaps('nx', 'Toggle', 'Toggle', 'c<Space>')
|
call s:CreateMaps('nx', 'Toggle', 'Toggle', 'c<Space>')
|
||||||
call s:CreateMaps('nx', 'Minimal', 'Minimal', 'cm')
|
call s:CreateMaps('nx', 'Minimal', 'Minimal', 'cm')
|
||||||
@@ -97,7 +99,33 @@ call s:CreateMaps('i', 'Insert', 'Insert Comment Here', '')
|
|||||||
call s:CreateMaps('', ':', '-Sep3-', '')
|
call s:CreateMaps('', ':', '-Sep3-', '')
|
||||||
call s:CreateMaps('', ':help NERDCommenterContents<CR>', 'Help', '')
|
call s:CreateMaps('', ':help NERDCommenterContents<CR>', 'Help', '')
|
||||||
|
|
||||||
inoremap <silent> <Plug>NERDCommenterInsert <Space><BS><Esc>:call nerdcommenter#Comment('i', "insert")<CR>
|
" Shim functions so old code gets passed through to the autoload functions
|
||||||
|
function! NERDComment(mode, type) range
|
||||||
|
if !g:NERDSuppressWarnings
|
||||||
|
echom 'Function NERDComment() has been deprecated, please use nerdcommenter#Comment() instead'
|
||||||
|
endif
|
||||||
|
if a:firstline != a:lastline
|
||||||
|
echoerr "Sorry! We can't pass a range through this deprecation shim, please update your code."
|
||||||
|
return v:false
|
||||||
|
endif
|
||||||
|
return nerdcommenter#Comment(a:mode, a:type)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! NERDCommentIsLineCommented(lineNo)
|
||||||
|
if !g:NERDSuppressWarnings
|
||||||
|
echom 'Function NERDCommentIsLineCommented() has been deprecated, please use nerdcommenter#IsLineCommented() instead'
|
||||||
|
endif
|
||||||
|
return nerdcommenter#IsLineCommented(a:lineNo)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! NERDCommentIsCharCommented(line, col)
|
||||||
|
if !g:NERDSuppressWarnings
|
||||||
|
echom 'Function NERDCommentIsCharCommented() has been deprecated, please use nerdcommenter#IsCharCommented() instead'
|
||||||
|
endif
|
||||||
|
return nerdcommenter#IsCharCommented(a:line, a:col)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
inoremap <silent> <Plug>NERDCommenterInsert <C-\><C-O>:call nerdcommenter#Comment('i', "Insert")<CR>
|
||||||
|
|
||||||
" switch to/from alternative delimiters (does not use wrapper function)
|
" switch to/from alternative delimiters (does not use wrapper function)
|
||||||
nnoremap <Plug>NERDCommenterAltDelims :call nerdcommenter#SwitchToAlternativeDelimiters(1)<CR>
|
nnoremap <Plug>NERDCommenterAltDelims :call nerdcommenter#SwitchToAlternativeDelimiters(1)<CR>
|
||||||
|
|||||||
Reference in New Issue
Block a user