mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
parent
c8f34a9a3e
commit
aa680f6acb
@ -886,9 +886,9 @@ When the result is a |List| then the items are joined with separating line
|
|||||||
breaks. Thus each item becomes a line, except that they can contain line
|
breaks. Thus each item becomes a line, except that they can contain line
|
||||||
breaks themselves.
|
breaks themselves.
|
||||||
|
|
||||||
The whole matched text can be accessed with "submatch(0)". The text matched
|
The |submatch()| function can be used to obtain matched text. The whole
|
||||||
with the first pair of () with "submatch(1)". Likewise for further
|
matched text can be accessed with "submatch(0)". The text matched with the
|
||||||
sub-matches in ().
|
first pair of () with "submatch(1)". Likewise for further sub-matches in ().
|
||||||
|
|
||||||
Be careful: The separation character must not appear in the expression!
|
Be careful: The separation character must not appear in the expression!
|
||||||
Consider using a character like "@" or ":". There is no problem if the result
|
Consider using a character like "@" or ":". There is no problem if the result
|
||||||
|
@ -106,7 +106,6 @@ Basic editing ~
|
|||||||
|scroll.txt| scrolling the text in the window
|
|scroll.txt| scrolling the text in the window
|
||||||
|insert.txt| Insert and Replace mode
|
|insert.txt| Insert and Replace mode
|
||||||
|change.txt| deleting and replacing text
|
|change.txt| deleting and replacing text
|
||||||
|indent.txt| automatic indenting for C and other languages
|
|
||||||
|undo.txt| Undo and Redo
|
|undo.txt| Undo and Redo
|
||||||
|repeat.txt| repeating commands, Vim scripts and debugging
|
|repeat.txt| repeating commands, Vim scripts and debugging
|
||||||
|visual.txt| using the Visual mode (selecting a text area)
|
|visual.txt| using the Visual mode (selecting a text area)
|
||||||
@ -119,30 +118,36 @@ Advanced editing ~
|
|||||||
|pattern.txt| regexp patterns and search commands
|
|pattern.txt| regexp patterns and search commands
|
||||||
|map.txt| key mapping and abbreviations
|
|map.txt| key mapping and abbreviations
|
||||||
|tagsrch.txt| tags and special searches
|
|tagsrch.txt| tags and special searches
|
||||||
|quickfix.txt| commands for a quick edit-compile-fix cycle
|
|
||||||
|windows.txt| commands for using multiple windows and buffers
|
|windows.txt| commands for using multiple windows and buffers
|
||||||
|tabpage.txt| commands for using multiple tab pages
|
|tabpage.txt| commands for using multiple tab pages
|
||||||
|syntax.txt| syntax highlighting
|
|
||||||
|spell.txt| spell checking
|
|spell.txt| spell checking
|
||||||
|diff.txt| working with two to four versions of the same file
|
|diff.txt| working with two to four versions of the same file
|
||||||
|autocmd.txt| automatically executing commands on an event
|
|autocmd.txt| automatically executing commands on an event
|
||||||
|filetype.txt| settings done specifically for a type of file
|
|
||||||
|eval.txt| expression evaluation, conditional commands
|
|eval.txt| expression evaluation, conditional commands
|
||||||
|fold.txt| hide (fold) ranges of lines
|
|fold.txt| hide (fold) ranges of lines
|
||||||
|
|
||||||
Special issues ~
|
Special issues ~
|
||||||
|print.txt| printing
|
|print.txt| printing
|
||||||
|remote.txt| using Vim as a server or client
|
|remote.txt| using Vim as a server or client
|
||||||
|digraph.txt| list of available digraphs
|
|
||||||
|mbyte.txt| multi-byte text support
|
Programming language support ~
|
||||||
|mlang.txt| non-English language support
|
|indent.txt| automatic indenting for C and other languages
|
||||||
|arabic.txt| Arabic language support and editing
|
|syntax.txt| syntax highlighting
|
||||||
|hebrew.txt| Hebrew language support and editing
|
|textprop.txt| Attaching properties to text for highlighting or other
|
||||||
|russian.txt| Russian language support and editing
|
|filetype.txt| settings done specifically for a type of file
|
||||||
|
|quickfix.txt| commands for a quick edit-compile-fix cycle
|
||||||
|ft_ada.txt| Ada (the programming language) support
|
|ft_ada.txt| Ada (the programming language) support
|
||||||
|ft_rust.txt| Filetype plugin for Rust
|
|ft_rust.txt| Filetype plugin for Rust
|
||||||
|ft_sql.txt| about the SQL filetype plugin
|
|ft_sql.txt| about the SQL filetype plugin
|
||||||
|
|
||||||
|
Language support ~
|
||||||
|
|digraph.txt| list of available digraphs
|
||||||
|
|mbyte.txt| multi-byte text support
|
||||||
|
|mlang.txt| non-English language support
|
||||||
|rileft.txt| right-to-left editing mode
|
|rileft.txt| right-to-left editing mode
|
||||||
|
|arabic.txt| Arabic language support and editing
|
||||||
|
|hebrew.txt| Hebrew language support and editing
|
||||||
|
|russian.txt| Russian language support and editing
|
||||||
|
|
||||||
GUI ~
|
GUI ~
|
||||||
|gui.txt| Graphical User Interface (GUI)
|
|gui.txt| Graphical User Interface (GUI)
|
||||||
|
@ -1213,8 +1213,9 @@ defined, not where it is invoked! Example:
|
|||||||
Executing script2.vim will result in "None" being echoed. Not what you
|
Executing script2.vim will result in "None" being echoed. Not what you
|
||||||
intended! Calling a function may be an alternative.
|
intended! Calling a function may be an alternative.
|
||||||
|
|
||||||
Completion behavior *:command-completion* *E179*
|
Completion behavior ~
|
||||||
*E180* *E181* *:command-complete*
|
*:command-completion* *E179* *E180* *E181*
|
||||||
|
*:command-complete*
|
||||||
By default, the arguments of user defined commands do not undergo completion.
|
By default, the arguments of user defined commands do not undergo completion.
|
||||||
However, by specifying one or the other of the following attributes, argument
|
However, by specifying one or the other of the following attributes, argument
|
||||||
completion can be enabled:
|
completion can be enabled:
|
||||||
@ -1341,6 +1342,7 @@ Possible values are:
|
|||||||
-addr=loaded_buffers Range for loaded buffers
|
-addr=loaded_buffers Range for loaded buffers
|
||||||
-addr=windows Range for windows
|
-addr=windows Range for windows
|
||||||
-addr=tabs Range for tab pages
|
-addr=tabs Range for tab pages
|
||||||
|
-addr=other other kind of range
|
||||||
|
|
||||||
|
|
||||||
Special cases *:command-bang* *:command-bar*
|
Special cases *:command-bang* *:command-bar*
|
||||||
|
@ -306,7 +306,10 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|.
|
|||||||
|<SID>|.
|
|<SID>|.
|
||||||
|
|
||||||
:scr[iptnames][!] {scriptId} *:script*
|
:scr[iptnames][!] {scriptId} *:script*
|
||||||
Edit script {scriptId}. Suggested name is ":script".
|
Edit script {scriptId}. Although ":scriptnames name"
|
||||||
|
works, using ":script name" is recommended.
|
||||||
|
When the current buffer can't be |abandon|ed and the !
|
||||||
|
is not present, the command fails.
|
||||||
|
|
||||||
*:fini* *:finish* *E168*
|
*:fini* *:finish* *E168*
|
||||||
:fini[sh] Stop sourcing a script. Can only be used in a Vim
|
:fini[sh] Stop sourcing a script. Can only be used in a Vim
|
||||||
|
@ -346,20 +346,9 @@ Upon loading a file, Vim finds the relevant syntax file as follows:
|
|||||||
syntax.
|
syntax.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
4. Syntax file remarks *:syn-file-remarks*
|
4. Conversion to HTML *2html.vim* *convert-to-HTML*
|
||||||
|
|
||||||
*b:current_syntax-variable*
|
2html is not a syntax file itself, but a script that converts the current
|
||||||
Vim stores the name of the syntax that has been loaded in the
|
|
||||||
"b:current_syntax" variable. You can use this if you want to load other
|
|
||||||
settings, depending on which syntax is active. Example: >
|
|
||||||
:au BufReadPost * if b:current_syntax == "csh"
|
|
||||||
:au BufReadPost * do-some-things
|
|
||||||
:au BufReadPost * endif
|
|
||||||
|
|
||||||
|
|
||||||
2HTML *2html.vim* *convert-to-HTML*
|
|
||||||
|
|
||||||
This is not a syntax file itself, but a script that converts the current
|
|
||||||
window into HTML. Vim opens a new window in which it builds the HTML file.
|
window into HTML. Vim opens a new window in which it builds the HTML file.
|
||||||
|
|
||||||
After you save the resulting file, you can view it with any browser. The
|
After you save the resulting file, you can view it with any browser. The
|
||||||
@ -751,6 +740,18 @@ When 1, generate XHTML 1.0 instead (XML compliant HTML).
|
|||||||
>
|
>
|
||||||
:let g:html_use_xhtml = 1
|
:let g:html_use_xhtml = 1
|
||||||
<
|
<
|
||||||
|
==============================================================================
|
||||||
|
5. Syntax file remarks *:syn-file-remarks*
|
||||||
|
|
||||||
|
*b:current_syntax-variable*
|
||||||
|
Vim stores the name of the syntax that has been loaded in the
|
||||||
|
"b:current_syntax" variable. You can use this if you want to load other
|
||||||
|
settings, depending on which syntax is active. Example: >
|
||||||
|
:au BufReadPost * if b:current_syntax == "csh"
|
||||||
|
:au BufReadPost * do-some-things
|
||||||
|
:au BufReadPost * endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ABEL *abel.vim* *ft-abel-syntax*
|
ABEL *abel.vim* *ft-abel-syntax*
|
||||||
|
|
||||||
@ -3440,7 +3441,7 @@ The syntax script for zsh allows for syntax-based folding: >
|
|||||||
:let g:zsh_fold_enable = 1
|
:let g:zsh_fold_enable = 1
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
5. Defining a syntax *:syn-define* *E410*
|
6. Defining a syntax *:syn-define* *E410*
|
||||||
|
|
||||||
Vim understands three types of syntax items:
|
Vim understands three types of syntax items:
|
||||||
|
|
||||||
@ -3799,7 +3800,7 @@ DEFINING REGIONS *:syn-region* *:syn-start* *:syn-skip* *:syn-end*
|
|||||||
The maximum number of syntax groups is 19999.
|
The maximum number of syntax groups is 19999.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
6. :syntax arguments *:syn-arguments*
|
7. :syntax arguments *:syn-arguments*
|
||||||
|
|
||||||
The :syntax commands that define syntax items take a number of arguments.
|
The :syntax commands that define syntax items take a number of arguments.
|
||||||
The common ones are explained here. The arguments may be given in any order
|
The common ones are explained here. The arguments may be given in any order
|
||||||
@ -4120,7 +4121,7 @@ IMPLICIT CONCEAL *:syn-conceal-implicit*
|
|||||||
Show either "syntax conceal on" or "syntax conceal off" (translated).
|
Show either "syntax conceal on" or "syntax conceal off" (translated).
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
7. Syntax patterns *:syn-pattern* *E401* *E402*
|
8. Syntax patterns *:syn-pattern* *E401* *E402*
|
||||||
|
|
||||||
In the syntax commands, a pattern must be surrounded by two identical
|
In the syntax commands, a pattern must be surrounded by two identical
|
||||||
characters. This is like it works for the ":s" command. The most common to
|
characters. This is like it works for the ":s" command. The most common to
|
||||||
@ -4298,7 +4299,7 @@ Note that only matches within a single line can be used. Multi-line matches
|
|||||||
cannot be referred to.
|
cannot be referred to.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
8. Syntax clusters *:syn-cluster* *E400*
|
9. Syntax clusters *:syn-cluster* *E400*
|
||||||
|
|
||||||
:sy[ntax] cluster {cluster-name} [contains={group-name}..]
|
:sy[ntax] cluster {cluster-name} [contains={group-name}..]
|
||||||
[add={group-name}..]
|
[add={group-name}..]
|
||||||
@ -4344,7 +4345,7 @@ This also has implications for nested clusters: >
|
|||||||
The maximum number of clusters is 9767.
|
The maximum number of clusters is 9767.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
9. Including syntax files *:syn-include* *E397*
|
10. Including syntax files *:syn-include* *E397*
|
||||||
|
|
||||||
It is often useful for one language's syntax file to include a syntax file for
|
It is often useful for one language's syntax file to include a syntax file for
|
||||||
a related language. Depending on the exact relationship, this can be done in
|
a related language. Depending on the exact relationship, this can be done in
|
||||||
@ -4385,7 +4386,7 @@ two different ways:
|
|||||||
The maximum number of includes is 999.
|
The maximum number of includes is 999.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
10. Synchronizing *:syn-sync* *E403* *E404*
|
11. Synchronizing *:syn-sync* *E403* *E404*
|
||||||
|
|
||||||
Vim wants to be able to start redrawing in any position in the document. To
|
Vim wants to be able to start redrawing in any position in the document. To
|
||||||
make this possible it needs to know the syntax state at the position where
|
make this possible it needs to know the syntax state at the position where
|
||||||
@ -4577,7 +4578,7 @@ You can clear specific sync patterns with: >
|
|||||||
:syntax sync clear {sync-group-name} ..
|
:syntax sync clear {sync-group-name} ..
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
11. Listing syntax items *:syntax* *:sy* *:syn* *:syn-list*
|
12. Listing syntax items *:syntax* *:sy* *:syn* *:syn-list*
|
||||||
|
|
||||||
This command lists all the syntax items: >
|
This command lists all the syntax items: >
|
||||||
|
|
||||||
@ -5090,7 +5091,7 @@ Without the "default" in the C syntax file, the highlighting would be
|
|||||||
overruled when the syntax file is loaded.
|
overruled when the syntax file is loaded.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
14. Cleaning up *:syn-clear* *E391*
|
15. Cleaning up *:syn-clear* *E391*
|
||||||
|
|
||||||
If you want to clear the syntax stuff for the current buffer, you can use this
|
If you want to clear the syntax stuff for the current buffer, you can use this
|
||||||
command: >
|
command: >
|
||||||
@ -5180,7 +5181,7 @@ syntax/syncolor.vim files are loaded:
|
|||||||
them.
|
them.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
15. Highlighting tags *tag-highlight*
|
16. Highlighting tags *tag-highlight*
|
||||||
|
|
||||||
If you want to highlight all the tags in your file, you can use the following
|
If you want to highlight all the tags in your file, you can use the following
|
||||||
mappings.
|
mappings.
|
||||||
@ -5215,7 +5216,7 @@ And put these lines in your vimrc: >
|
|||||||
autocmd BufRead,BufNewFile *.[ch] endif
|
autocmd BufRead,BufNewFile *.[ch] endif
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
16. Window-local syntax *:ownsyntax*
|
17. Window-local syntax *:ownsyntax*
|
||||||
|
|
||||||
Normally all windows on a buffer share the same syntax settings. It is
|
Normally all windows on a buffer share the same syntax settings. It is
|
||||||
possible, however, to set a particular window on a file to have its own
|
possible, however, to set a particular window on a file to have its own
|
||||||
|
@ -368,7 +368,7 @@ function FalconGetIndent(...)
|
|||||||
return indent('.')
|
return indent('.')
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
call cursor(clnum, vcol)
|
call cursor(clnum, 0) " FIXME: column was vcol
|
||||||
end
|
end
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -1,74 +1,121 @@
|
|||||||
" Matlab indent file
|
" Vim indent file
|
||||||
" Language: Matlab
|
" Language: MATLAB
|
||||||
" Maintainer: Christophe Poucet <christophe.poucet@pandora.be>
|
" Maintainer: Axel Forsman <axelsfor@gmail.com>
|
||||||
" Last Change: 6 January, 2001
|
" Previous maintainer: Christophe Poucet <christophe.poucet@pandora.be>
|
||||||
|
|
||||||
" Only load this indent file when no other was loaded.
|
" Only load if no other indent file is loaded
|
||||||
if exists("b:did_indent")
|
if exists('b:did_indent') | finish | endif
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let b:did_indent = 1
|
let b:did_indent = 1
|
||||||
|
|
||||||
" Some preliminary setting
|
setlocal indentexpr=GetMatlabIndent()
|
||||||
setlocal indentkeys=!,o,O=end,=case,=else,=elseif,=otherwise,=catch
|
setlocal indentkeys=!,o,O,e,0=end,0=elseif,0=case,0=otherwise,0=catch,0=function,0=elsei
|
||||||
|
|
||||||
|
" The value of the Function indenting format in
|
||||||
|
" MATLAB Editor/Debugger Language Preferences.
|
||||||
|
" The possible values are 0 for Classic, 1 for Indent nested functions
|
||||||
|
" and 2 for Indent all functions (default).
|
||||||
|
let b:MATLAB_function_indent = get(g:, 'MATLAB_function_indent', 2)
|
||||||
|
" The previous value of b:changedtick
|
||||||
|
let b:MATLAB_lasttick = -1
|
||||||
|
" The previously indented line
|
||||||
|
let b:MATLAB_lastline = -1
|
||||||
|
" Whether the line above was a line continuation
|
||||||
|
let b:MATLAB_waslc = 0
|
||||||
|
let b:MATLAB_bracketlevel = 0
|
||||||
|
|
||||||
setlocal indentexpr=GetMatlabIndent(v:lnum)
|
" Only define the function once
|
||||||
|
if exists("*GetMatlabIndent") | finish | endif
|
||||||
|
|
||||||
" Only define the function once.
|
let s:keepcpo = &cpo
|
||||||
if exists("*GetMatlabIndent")
|
set cpo&vim
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
function GetMatlabIndent(lnum)
|
let s:end = '\<end\>\%([^(]*)\)\@!' " Array indexing heuristic
|
||||||
" Give up if this line is explicitly joined.
|
let s:open_pat = 'for\|if\|parfor\|spmd\|switch\|try\|while\|classdef\|properties\|methods\|events\|enumeration'
|
||||||
if getline(a:lnum - 1) =~ '\\$'
|
let s:dedent_pat = '\C^\s*\zs\<\%(end\|else\|elseif\|catch\|\(case\|otherwise\|function\)\)\>'
|
||||||
return -1
|
let s:start_pat = '\C\<\%(function\|' . s:open_pat . '\)\>'
|
||||||
endif
|
let s:bracket_pair_pat = '\(\[\|{\)\|\(\]\|}\)'
|
||||||
|
let s:zflag = has('patch-7.4.984') ? 'z' : ''
|
||||||
|
|
||||||
" Search backwards for the first non-empty line.
|
" Returns whether a comment or string envelops the specified column.
|
||||||
let plnum = a:lnum - 1
|
function! s:IsCommentOrString(lnum, col)
|
||||||
while plnum > 0 && getline(plnum) =~ '^\s*$'
|
return synIDattr(synID(a:lnum, a:col, 1), "name") =~# 'matlabComment\|matlabMultilineComment\|matlabString'
|
||||||
let plnum = plnum - 1
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
if plnum == 0
|
|
||||||
" This is the first non-empty line, use zero indent.
|
|
||||||
return 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
let curind = indent(plnum)
|
|
||||||
|
|
||||||
" If the current line is a stop-block statement...
|
|
||||||
if getline(v:lnum) =~ '^\s*\(end\|else\|elseif\|case\|otherwise\|catch\)\>'
|
|
||||||
" See if this line does not follow the line right after an openblock
|
|
||||||
if getline(plnum) =~ '^\s*\(for\|if\|else\|elseif\|case\|while\|switch\|try\|otherwise\|catch\)\>'
|
|
||||||
" See if the user has already dedented
|
|
||||||
elseif indent(v:lnum) > curind - shiftwidth()
|
|
||||||
" If not, recommend one dedent
|
|
||||||
let curind = curind - shiftwidth()
|
|
||||||
else
|
|
||||||
" Otherwise, trust the user
|
|
||||||
return -1
|
|
||||||
endif
|
|
||||||
" endif
|
|
||||||
|
|
||||||
" If the previous line opened a block
|
|
||||||
elseif getline(plnum) =~ '^\s*\(for\|if\|else\|elseif\|case\|while\|switch\|try\|otherwise\|catch\)\>'
|
|
||||||
" See if the user has already indented
|
|
||||||
if indent(v:lnum) < curind + shiftwidth()
|
|
||||||
"If not, recommend indent
|
|
||||||
let curind = curind + shiftwidth()
|
|
||||||
else
|
|
||||||
" Otherwise, trust the user
|
|
||||||
return -1
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
" If we got to here, it means that the user takes the standardversion, so we return it
|
|
||||||
return curind
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" vim:sw=2
|
" Returns whether the specified line continues on the next line.
|
||||||
|
function! s:IsLineContinuation(lnum)
|
||||||
|
let l = getline(a:lnum) | let c = -3
|
||||||
|
while 1
|
||||||
|
let c = match(l, '\.\{3}', c + 3)
|
||||||
|
if c == -1 | return 0
|
||||||
|
elseif !s:IsCommentOrString(a:lnum, c) | return 1 | endif
|
||||||
|
endwhile
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:SubmatchCount(lnum, pattern, ...)
|
||||||
|
let endcol = a:0 >= 1 ? a:1 : 1 / 0 | let x = [0, 0, 0, 0]
|
||||||
|
call cursor(a:lnum, 1)
|
||||||
|
while 1
|
||||||
|
let [lnum, c, submatch] = searchpos(a:pattern, 'cpe' . s:zflag, a:lnum)
|
||||||
|
if !submatch || c >= endcol | break | endif
|
||||||
|
if !s:IsCommentOrString(lnum, c) | let x[submatch - 2] += 1 | endif
|
||||||
|
if cursor(0, c + 1) == -1 || col('.') == c | break | endif
|
||||||
|
endwhile
|
||||||
|
return x
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:GetOpenCloseCount(lnum, pattern, ...)
|
||||||
|
let counts = call('s:SubmatchCount', [a:lnum, a:pattern] + a:000)
|
||||||
|
return counts[0] - counts[1]
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! GetMatlabIndent()
|
||||||
|
let prevlnum = prevnonblank(v:lnum - 1)
|
||||||
|
|
||||||
|
if b:MATLAB_lasttick != b:changedtick || b:MATLAB_lastline != prevlnum
|
||||||
|
" Recalculate bracket count (only have to check same block and line above)
|
||||||
|
let b:MATLAB_bracketlevel = 0
|
||||||
|
let previndent = indent(prevlnum) | let l = prevlnum
|
||||||
|
while 1
|
||||||
|
let l = prevnonblank(l - 1) | let indent = indent(l)
|
||||||
|
if l <= 0 || previndent < indent | break | endif
|
||||||
|
let b:MATLAB_bracketlevel += s:GetOpenCloseCount(l, s:bracket_pair_pat)
|
||||||
|
if previndent != indent | break | endif
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
let b:MATLAB_waslc = s:IsLineContinuation(prevlnum - 1)
|
||||||
|
endif
|
||||||
|
" If line above was blank it can impossibly have been a LC
|
||||||
|
let above_lc = b:MATLAB_lasttick == b:changedtick && prevlnum != v:lnum - 1 && b:MATLAB_lastline == prevlnum ? 0 : s:IsLineContinuation(v:lnum - 1)
|
||||||
|
|
||||||
|
let pair_pat = '\C\<\(' . s:open_pat . '\|'
|
||||||
|
\ . (b:MATLAB_function_indent == 1 ? '^\@<!' : '')
|
||||||
|
\ . (b:MATLAB_function_indent >= 1 ? 'function\|' : '')
|
||||||
|
\ . '\|\%(^\s*\)\@<=\%(else\|elseif\|case\|otherwise\|catch\)\)\>'
|
||||||
|
\ . '\|\S\s*\zs\(' . s:end . '\)'
|
||||||
|
let [open, close, b_open, b_close] = prevlnum ? s:SubmatchCount(prevlnum,
|
||||||
|
\ pair_pat . '\|' . s:bracket_pair_pat) : [0, 0, 0, 0]
|
||||||
|
let curbracketlevel = b:MATLAB_bracketlevel + b_open - b_close
|
||||||
|
|
||||||
|
call cursor(v:lnum, 1)
|
||||||
|
let submatch = search(s:dedent_pat, 'cp' . s:zflag, v:lnum)
|
||||||
|
if submatch && !s:IsCommentOrString(v:lnum, col('.'))
|
||||||
|
" Align end, et cetera with start of block
|
||||||
|
let [lnum, col] = searchpairpos(s:start_pat, '', '\C' . s:end, 'bW', 's:IsCommentOrString(line("."), col("."))')
|
||||||
|
let result = lnum ? indent(lnum) + shiftwidth() * (s:GetOpenCloseCount(lnum, pair_pat, col) + submatch == 2) : 0
|
||||||
|
else
|
||||||
|
" Count how many blocks the previous line opens/closes
|
||||||
|
" Line continuations/brackets indent once per statement
|
||||||
|
let result = indent(prevlnum) + shiftwidth() * (open - close
|
||||||
|
\ + (b:MATLAB_bracketlevel ? -!curbracketlevel : !!curbracketlevel)
|
||||||
|
\ + (curbracketlevel <= 0) * (above_lc - b:MATLAB_waslc))
|
||||||
|
endif
|
||||||
|
|
||||||
|
let b:MATLAB_waslc = above_lc
|
||||||
|
let b:MATLAB_bracketlevel = curbracketlevel
|
||||||
|
let b:MATLAB_lasttick = b:changedtick
|
||||||
|
let b:MATLAB_lastline = v:lnum
|
||||||
|
return result
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
let &cpo = s:keepcpo
|
||||||
|
unlet s:keepcpo
|
||||||
|
@ -15,3 +15,66 @@ catch exception
|
|||||||
statements
|
statements
|
||||||
end
|
end
|
||||||
% END_INDENT
|
% END_INDENT
|
||||||
|
|
||||||
|
% START_INDENT
|
||||||
|
if true, ...
|
||||||
|
if true
|
||||||
|
disp hello
|
||||||
|
end
|
||||||
|
end
|
||||||
|
% END_INDENT
|
||||||
|
|
||||||
|
% START_INDENT
|
||||||
|
switch a
|
||||||
|
case expr
|
||||||
|
if true, foo; end
|
||||||
|
disp hello
|
||||||
|
otherwise
|
||||||
|
disp bar
|
||||||
|
end
|
||||||
|
% END_INDENT
|
||||||
|
|
||||||
|
% START_INDENT
|
||||||
|
if true
|
||||||
|
A(1:end - 1)
|
||||||
|
disp foo
|
||||||
|
end
|
||||||
|
% END_INDENT
|
||||||
|
|
||||||
|
% START_INDENT
|
||||||
|
A = [{
|
||||||
|
}
|
||||||
|
] ...
|
||||||
|
disp foo
|
||||||
|
disp bar
|
||||||
|
% END_INDENT
|
||||||
|
|
||||||
|
% START_INDENT
|
||||||
|
% INDENT_EXE let b:MATLAB_function_indent = 0
|
||||||
|
function foo
|
||||||
|
disp foo
|
||||||
|
function nested
|
||||||
|
disp bar
|
||||||
|
end
|
||||||
|
end
|
||||||
|
% END_INDENT
|
||||||
|
|
||||||
|
% START_INDENT
|
||||||
|
% INDENT_EXE let b:MATLAB_function_indent = 1
|
||||||
|
function foo
|
||||||
|
disp foo
|
||||||
|
function nested
|
||||||
|
disp bar
|
||||||
|
end
|
||||||
|
end
|
||||||
|
% END_INDENT
|
||||||
|
|
||||||
|
% START_INDENT
|
||||||
|
% INDENT_EXE let b:MATLAB_function_indent = 2
|
||||||
|
function foo
|
||||||
|
disp foo
|
||||||
|
function nested
|
||||||
|
disp bar
|
||||||
|
end
|
||||||
|
end
|
||||||
|
% END_INDENT
|
||||||
|
@ -15,3 +15,66 @@ catch exception
|
|||||||
statements
|
statements
|
||||||
end
|
end
|
||||||
% END_INDENT
|
% END_INDENT
|
||||||
|
|
||||||
|
% START_INDENT
|
||||||
|
if true, ...
|
||||||
|
if true
|
||||||
|
disp hello
|
||||||
|
end
|
||||||
|
end
|
||||||
|
% END_INDENT
|
||||||
|
|
||||||
|
% START_INDENT
|
||||||
|
switch a
|
||||||
|
case expr
|
||||||
|
if true, foo; end
|
||||||
|
disp hello
|
||||||
|
otherwise
|
||||||
|
disp bar
|
||||||
|
end
|
||||||
|
% END_INDENT
|
||||||
|
|
||||||
|
% START_INDENT
|
||||||
|
if true
|
||||||
|
A(1:end - 1)
|
||||||
|
disp foo
|
||||||
|
end
|
||||||
|
% END_INDENT
|
||||||
|
|
||||||
|
% START_INDENT
|
||||||
|
A = [{
|
||||||
|
}
|
||||||
|
] ...
|
||||||
|
disp foo
|
||||||
|
disp bar
|
||||||
|
% END_INDENT
|
||||||
|
|
||||||
|
% START_INDENT
|
||||||
|
% INDENT_EXE let b:MATLAB_function_indent = 0
|
||||||
|
function foo
|
||||||
|
disp foo
|
||||||
|
function nested
|
||||||
|
disp bar
|
||||||
|
end
|
||||||
|
end
|
||||||
|
% END_INDENT
|
||||||
|
|
||||||
|
% START_INDENT
|
||||||
|
% INDENT_EXE let b:MATLAB_function_indent = 1
|
||||||
|
function foo
|
||||||
|
disp foo
|
||||||
|
function nested
|
||||||
|
disp bar
|
||||||
|
end
|
||||||
|
end
|
||||||
|
% END_INDENT
|
||||||
|
|
||||||
|
% START_INDENT
|
||||||
|
% INDENT_EXE let b:MATLAB_function_indent = 2
|
||||||
|
function foo
|
||||||
|
disp foo
|
||||||
|
function nested
|
||||||
|
disp bar
|
||||||
|
end
|
||||||
|
end
|
||||||
|
% END_INDENT
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# vim: set filetype=tcl shiftwidth=4 tabstop=4:
|
# vim: set filetype=tcl shiftwidth=4 tabstop=8 expandtab :
|
||||||
|
|
||||||
# START_INDENT
|
# START_INDENT
|
||||||
proc abc {} {
|
proc abc {} {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# vim: set filetype=tcl shiftwidth=4 tabstop=4:
|
# vim: set filetype=tcl shiftwidth=4 tabstop=8 expandtab :
|
||||||
|
|
||||||
# START_INDENT
|
# START_INDENT
|
||||||
proc abc {} {
|
proc abc {} {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- vim: set ft=xml ts=2 sw=0 sts=-1 et : -->
|
<!-- vim: set ft=xml ts=8 sw=0 sts=-1 et : -->
|
||||||
<!-- START_INDENT -->
|
<!-- START_INDENT -->
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<tag0>
|
<tag0>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- vim: set ft=xml ts=2 sw=0 sts=-1 et : -->
|
<!-- vim: set ft=xml ts=8 sw=0 sts=-1 et : -->
|
||||||
<!-- START_INDENT -->
|
<!-- START_INDENT -->
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<tag0>
|
<tag0>
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
" Language: xml
|
" Language: xml
|
||||||
" Repository: https://github.com/chrisbra/vim-xml-ftplugin
|
" Repository: https://github.com/chrisbra/vim-xml-ftplugin
|
||||||
|
" Last Changed: Dec 07th, 2018
|
||||||
" Maintainer: Christian Brabandt <cb@256bit.org>
|
" Maintainer: Christian Brabandt <cb@256bit.org>
|
||||||
" Previous Maintainer: Johannes Zellner <johannes@zellner.org>
|
" Previous Maintainer: Johannes Zellner <johannes@zellner.org>
|
||||||
" Last Change: 20181022 - Do not overwrite indentkeys setting
|
" Last Change:
|
||||||
|
" 20181116 - Fix indentation when tags start with a colon or an underscore
|
||||||
|
" https://github.com/vim/vim/pull/926
|
||||||
|
" 20181022 - Do not overwrite indentkeys setting
|
||||||
" https://github.com/chrisbra/vim-xml-ftplugin/issues/1
|
" https://github.com/chrisbra/vim-xml-ftplugin/issues/1
|
||||||
" 20180724 - Correctly indent xml comments https://github.com/vim/vim/issues/3200
|
" 20180724 - Correctly indent xml comments https://github.com/vim/vim/issues/3200
|
||||||
" Notes: 1) does not indent pure non-xml code (e.g. embedded scripts)
|
"
|
||||||
|
" Notes:
|
||||||
|
" 1) does not indent pure non-xml code (e.g. embedded scripts)
|
||||||
" 2) will be confused by unbalanced tags in comments
|
" 2) will be confused by unbalanced tags in comments
|
||||||
" or CDATA sections.
|
" or CDATA sections.
|
||||||
" 2009-05-26 patch by Nikolai Weibull
|
" 2009-05-26 patch by Nikolai Weibull
|
||||||
@ -20,11 +26,12 @@ let s:keepcpo= &cpo
|
|||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
" [-- local settings (must come before aborting the script) --]
|
" [-- local settings (must come before aborting the script) --]
|
||||||
|
" Attention: Parameter use_syntax_check is used by the docbk.vim indent script
|
||||||
setlocal indentexpr=XmlIndentGet(v:lnum,1)
|
setlocal indentexpr=XmlIndentGet(v:lnum,1)
|
||||||
setlocal indentkeys=o,O,*<Return>,<>>,<<>,/,{,},!^F
|
setlocal indentkeys=o,O,*<Return>,<>>,<<>,/,{,},!^F
|
||||||
|
|
||||||
if !exists('b:xml_indent_open')
|
if !exists('b:xml_indent_open')
|
||||||
let b:xml_indent_open = '.\{-}<\a'
|
let b:xml_indent_open = '.\{-}<[:A-Z_a-z]'
|
||||||
" pre tag, e.g. <address>
|
" pre tag, e.g. <address>
|
||||||
" let b:xml_indent_open = '.\{-}<[/]\@!\(address\)\@!'
|
" let b:xml_indent_open = '.\{-}<[/]\@!\(address\)\@!'
|
||||||
endif
|
endif
|
||||||
@ -53,10 +60,10 @@ endfun
|
|||||||
|
|
||||||
" [-- check if it's xml --]
|
" [-- check if it's xml --]
|
||||||
fun! <SID>XmlIndentSynCheck(lnum)
|
fun! <SID>XmlIndentSynCheck(lnum)
|
||||||
if '' != &syntax
|
if &syntax != ''
|
||||||
let syn1 = synIDattr(synID(a:lnum, 1, 1), 'name')
|
let syn1 = synIDattr(synID(a:lnum, 1, 1), 'name')
|
||||||
let syn2 = synIDattr(synID(a:lnum, strlen(getline(a:lnum)) - 1, 1), 'name')
|
let syn2 = synIDattr(synID(a:lnum, strlen(getline(a:lnum)) - 1, 1), 'name')
|
||||||
if '' != syn1 && syn1 !~ 'xml' && '' != syn2 && syn2 !~ 'xml'
|
if syn1 != '' && syn1 !~ 'xml' && syn2 != '' && syn2 !~ 'xml'
|
||||||
" don't indent pure non-xml code
|
" don't indent pure non-xml code
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
@ -77,32 +84,63 @@ fun! <SID>XmlIndentSum(lnum, style, add)
|
|||||||
endif
|
endif
|
||||||
endfun
|
endfun
|
||||||
|
|
||||||
|
" Main indent function
|
||||||
fun! XmlIndentGet(lnum, use_syntax_check)
|
fun! XmlIndentGet(lnum, use_syntax_check)
|
||||||
" Find a non-empty line above the current line.
|
" Find a non-empty line above the current line.
|
||||||
let lnum = prevnonblank(a:lnum - 1)
|
let plnum = prevnonblank(a:lnum - 1)
|
||||||
|
" Find previous line with a tag (regardless whether open or closed)
|
||||||
|
let ptag = search('.\{-}<[/:A-Z_a-z]', 'bnw')
|
||||||
|
|
||||||
" Hit the start of the file, use zero indent.
|
" Hit the start of the file, use zero indent.
|
||||||
if lnum == 0
|
if plnum == 0
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
let syn_name = ''
|
||||||
|
|
||||||
if a:use_syntax_check
|
if a:use_syntax_check
|
||||||
let check_lnum = <SID>XmlIndentSynCheck(lnum)
|
let check_lnum = <SID>XmlIndentSynCheck(plnum)
|
||||||
let check_alnum = <SID>XmlIndentSynCheck(a:lnum)
|
let check_alnum = <SID>XmlIndentSynCheck(a:lnum)
|
||||||
if 0 == check_lnum || 0 == check_alnum
|
if check_lnum == 0 || check_alnum == 0
|
||||||
return indent(a:lnum)
|
return indent(a:lnum)
|
||||||
elseif -1 == check_lnum || -1 == check_alnum
|
|
||||||
return -1
|
|
||||||
endif
|
endif
|
||||||
|
let syn_name = synIDattr(synID(a:lnum, strlen(getline(a:lnum)) - 1, 1), 'name')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let ind = <SID>XmlIndentSum(lnum, -1, indent(lnum))
|
if syn_name =~ 'Comment'
|
||||||
|
return <SID>XmlIndentComment(a:lnum)
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Get indent from previous tag line
|
||||||
|
let ind = <SID>XmlIndentSum(ptag, -1, indent(ptag))
|
||||||
|
" Determine indent from current line
|
||||||
let ind = <SID>XmlIndentSum(a:lnum, 0, ind)
|
let ind = <SID>XmlIndentSum(a:lnum, 0, ind)
|
||||||
|
|
||||||
return ind
|
return ind
|
||||||
endfun
|
endfun
|
||||||
|
|
||||||
|
" return indent for a commented line,
|
||||||
|
" the middle part might be indented on additional level
|
||||||
|
func! <SID>XmlIndentComment(lnum)
|
||||||
|
let ptagopen = search(b:xml_indent_open, 'bnw')
|
||||||
|
let ptagclose = search(b:xml_indent_close, 'bnw')
|
||||||
|
if getline(a:lnum) =~ '<!--'
|
||||||
|
" if previous tag was a closing tag, do not add
|
||||||
|
" one additional level of indent
|
||||||
|
if ptagclose > ptagopen && a:lnum > ptagclose
|
||||||
|
return indent(ptagclose)
|
||||||
|
else
|
||||||
|
" start of comment, add one indentation level
|
||||||
|
return indent(ptagopen) + shiftwidth()
|
||||||
|
endif
|
||||||
|
elseif getline(a:lnum) =~ '-->'
|
||||||
|
" end of comment, same as start of comment
|
||||||
|
return indent(search('<!--', 'bnw'))
|
||||||
|
else
|
||||||
|
" middle part of comment, add one additional level
|
||||||
|
return indent(search('<!--', 'bnw')) + shiftwidth()
|
||||||
|
endif
|
||||||
|
endfunc
|
||||||
|
|
||||||
let &cpo = s:keepcpo
|
let &cpo = s:keepcpo
|
||||||
unlet s:keepcpo
|
unlet s:keepcpo
|
||||||
|
|
||||||
" vim:ts=8
|
" vim:ts=4 et sts=-1 sw=0
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
" Vim ABAP syntax file
|
" Vim ABAP syntax file
|
||||||
" Language: SAP - ABAP/R4
|
" Language: SAP - ABAP/R4
|
||||||
" Revision: 2.1
|
|
||||||
" Maintainer: Marius Piedallu van Wyk <lailoken@gmail.com>
|
" Maintainer: Marius Piedallu van Wyk <lailoken@gmail.com>
|
||||||
" Last Change: 2013 Jun 13
|
" Last Change: 2018 Dec 12
|
||||||
" Comment: Thanks to EPI-USE Labs for all your assistance. :)
|
" Comment: Thanks to EPI-USE Labs for all your assistance. :)
|
||||||
|
|
||||||
" quit when a syntax file was already loaded
|
" Quit when a syntax file was already loaded
|
||||||
if exists("b:current_syntax")
|
if exists("b:current_syntax")
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
@ -55,6 +54,7 @@ syn match abapComplexStatement "\<RESPECTING\W\+BLANKS\>"
|
|||||||
syn match abapComplexStatement "\<SEPARATED\W\+BY\>"
|
syn match abapComplexStatement "\<SEPARATED\W\+BY\>"
|
||||||
syn match abapComplexStatement "\<USING\(\W\+EDIT\W\+MASK\)\?\>"
|
syn match abapComplexStatement "\<USING\(\W\+EDIT\W\+MASK\)\?\>"
|
||||||
syn match abapComplexStatement "\<WHERE\(\W\+LINE\)\?\>"
|
syn match abapComplexStatement "\<WHERE\(\W\+LINE\)\?\>"
|
||||||
|
syn match abapComplexStatement "\<GET\W\+\(TIME\(\W\+STAMP\)\?\(\W\+FIELD\)\?\|PF-STATUS\|BADI\|BIT\|CONNECTION\|CURSOR\|REFERENCE\W\+OF\)\>"
|
||||||
syn match abapComplexStatement "\<RADIOBUTTON\W\+GROUP\>"
|
syn match abapComplexStatement "\<RADIOBUTTON\W\+GROUP\>"
|
||||||
syn match abapComplexStatement "\<REF\W\+TO\>"
|
syn match abapComplexStatement "\<REF\W\+TO\>"
|
||||||
syn match abapComplexStatement "\<\(PUBLIC\|PRIVATE\|PROTECTED\)\(\W\+SECTION\)\?\>"
|
syn match abapComplexStatement "\<\(PUBLIC\|PRIVATE\|PROTECTED\)\(\W\+SECTION\)\?\>"
|
||||||
@ -109,7 +109,7 @@ syn keyword abapStatement CALL CASE CATCH CHECK CLASS CLEAR CLOSE CNT COLLECT CO
|
|||||||
syn keyword abapStatement DATA DEFINE DEFINITION DEFERRED DELETE DESCRIBE DETAIL DIVIDE DO
|
syn keyword abapStatement DATA DEFINE DEFINITION DEFERRED DELETE DESCRIBE DETAIL DIVIDE DO
|
||||||
syn keyword abapStatement ELSE ELSEIF ENDAT ENDCASE ENDCLASS ENDDO ENDEXEC ENDFORM ENDFUNCTION ENDIF ENDIFEND ENDINTERFACE ENDLOOP ENDMETHOD ENDMODULE ENDON ENDPROVIDE ENDSELECT ENDTRY ENDWHILE EVENT EVENTS EXEC EXIT EXPORT EXPORTING EXTRACT
|
syn keyword abapStatement ELSE ELSEIF ENDAT ENDCASE ENDCLASS ENDDO ENDEXEC ENDFORM ENDFUNCTION ENDIF ENDIFEND ENDINTERFACE ENDLOOP ENDMETHOD ENDMODULE ENDON ENDPROVIDE ENDSELECT ENDTRY ENDWHILE EVENT EVENTS EXEC EXIT EXPORT EXPORTING EXTRACT
|
||||||
syn keyword abapStatement FETCH FIELDS FORM FORMAT FREE FROM FUNCTION
|
syn keyword abapStatement FETCH FIELDS FORM FORMAT FREE FROM FUNCTION
|
||||||
syn keyword abapStatement GENERATE GET
|
syn keyword abapStatement GENERATE
|
||||||
syn keyword abapStatement HIDE
|
syn keyword abapStatement HIDE
|
||||||
syn keyword abapStatement IF IMPORT IMPORTING INDEX INFOTYPES INITIALIZATION INTERFACE INTERFACES INPUT INSERT IMPLEMENTATION
|
syn keyword abapStatement IF IMPORT IMPORTING INDEX INFOTYPES INITIALIZATION INTERFACE INTERFACES INPUT INSERT IMPLEMENTATION
|
||||||
syn keyword abapStatement LEAVE LIKE LINE LOAD LOCAL LOOP
|
syn keyword abapStatement LEAVE LIKE LINE LOAD LOCAL LOOP
|
||||||
@ -147,7 +147,7 @@ syn keyword abapSpecial TRUE FALSE NULL SPACE
|
|||||||
syn region abapInclude start="include" end="." contains=abapComment
|
syn region abapInclude start="include" end="." contains=abapComment
|
||||||
|
|
||||||
" Types
|
" Types
|
||||||
syn keyword abapTypes c n i p f d t x string xstring decfloat16 decfloat34
|
syn keyword abapTypes c n i int8 p f d t x string xstring decfloat16 decfloat34
|
||||||
|
|
||||||
" Atritmitic operators
|
" Atritmitic operators
|
||||||
syn keyword abapOperator abs sign ceil floor trunc frac acos asin atan cos sin tan
|
syn keyword abapOperator abs sign ceil floor trunc frac acos asin atan cos sin tan
|
||||||
@ -194,4 +194,3 @@ hi def link abapHex Number
|
|||||||
let b:current_syntax = "abap"
|
let b:current_syntax = "abap"
|
||||||
|
|
||||||
" vim: ts=8 sw=2
|
" vim: ts=8 sw=2
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user