mirror of
https://github.com/preservim/nerdcommenter.git
synced 2025-11-08 18:03:46 -05:00
Compare commits
29 Commits
| 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 |
@@ -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>
|
||||||
|
|
||||||
|
|||||||
@@ -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': '#' },
|
||||||
@@ -50,10 +52,11 @@ let s:delimiterMap = {
|
|||||||
\ 'btm': { 'left': '::' },
|
\ 'btm': { 'left': '::' },
|
||||||
\ 'c': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
|
\ 'c': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
|
||||||
\ 'cabal': { 'left': '--' },
|
\ 'cabal': { 'left': '--' },
|
||||||
\ 'cairo': { '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': '*/' },
|
||||||
@@ -80,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': '#' },
|
||||||
@@ -87,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': ';' },
|
||||||
@@ -159,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': '#' },
|
||||||
@@ -190,6 +196,7 @@ 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': '*/' },
|
\ 'json5': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'jsonc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'jsonc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'jsonnet': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
\ 'jsonnet': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
@@ -275,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': '#' },
|
||||||
@@ -398,6 +406,7 @@ let s:delimiterMap = {
|
|||||||
\ 'texmf': { 'left': '%' },
|
\ 'texmf': { 'left': '%' },
|
||||||
\ 'tf': { 'left': '#' },
|
\ 'tf': { 'left': '#' },
|
||||||
\ 'tidy': { 'left': '#' },
|
\ 'tidy': { 'left': '#' },
|
||||||
|
\ 'tjp': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||||
\ 'tla': { 'left': '\\*', 'leftAlt': '(*', 'rightAlt': '*)' },
|
\ 'tla': { 'left': '\\*', 'leftAlt': '(*', 'rightAlt': '*)' },
|
||||||
\ 'tli': { 'left': '#' },
|
\ 'tli': { 'left': '#' },
|
||||||
\ 'tmux': { 'left': '#' },
|
\ 'tmux': { 'left': '#' },
|
||||||
@@ -413,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': '!' },
|
||||||
@@ -420,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': '*/' },
|
||||||
@@ -460,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
|
||||||
@@ -481,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] = ''
|
||||||
@@ -493,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()
|
||||||
@@ -534,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'] ==# ''
|
||||||
@@ -1175,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]'
|
||||||
|
|
||||||
@@ -1311,15 +1318,16 @@ endfunction
|
|||||||
" Function: nerdcommenter#IsCharCommented(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! nerdcommenter#IsCharCommented(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
|
||||||
@@ -1387,14 +1395,14 @@ function! nerdcommenter#IsCharCommented(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
|
||||||
@@ -1408,14 +1416,14 @@ function! nerdcommenter#IsCharCommented(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
|
||||||
|
|
||||||
@@ -1766,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)
|
||||||
|
|
||||||
@@ -2528,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 =~# "^\s\\{" . a:delIndx . "\\}\".*$"
|
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ 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 '\'.
|
||||||
@@ -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,11 +506,11 @@ 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
|
||||||
@@ -826,7 +826,7 @@ again.
|
|||||||
Values: 0 or 1.
|
Values: 0 or 1.
|
||||||
Default 0.
|
Default 0.
|
||||||
|
|
||||||
When this option is set to 1, NERDCommenterToggle will check all selected line,
|
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.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
@@ -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: >
|
||||||
@@ -901,15 +901,15 @@ NERDComment({mode}, {type}) *NERDComment()*
|
|||||||
{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:
|
||||||
|
|||||||
Reference in New Issue
Block a user