Update
This commit is contained in:
parent
ed29edbb53
commit
38a483f278
32
vimscript.md
32
vimscript.md
|
@ -110,14 +110,38 @@ function! infect(...)
|
||||||
endfunction
|
endfunction
|
||||||
```
|
```
|
||||||
|
|
||||||
Commands
|
Custom commands
|
||||||
--------
|
---------------
|
||||||
|
|
||||||
|
Custom commands start with uppercase letters. The `!` redefines a command if it already exists.
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
command! Save set fo=want tw=80 nowrap
|
command! Save :set fo=want tw=80 nowrap
|
||||||
command! Save call s:Foo()
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Commands calling functions
|
||||||
|
|
||||||
|
```vim
|
||||||
|
command! Save call script#foo()
|
||||||
|
function! script#foo()
|
||||||
|
...
|
||||||
|
endfunction
|
||||||
|
```
|
||||||
|
|
||||||
|
### Commands with arguments
|
||||||
|
|
||||||
|
```vim
|
||||||
|
command! -nargs=? Save call script#foo(<args>
|
||||||
|
```
|
||||||
|
|
||||||
|
| What | What |
|
||||||
|
| ---- | ---- |
|
||||||
|
| `-nargs=0` | 0 arguments, default |
|
||||||
|
| `-nargs=1` | 1 argument, includes spaces |
|
||||||
|
| `-nargs=?` | 0 or 1 argument |
|
||||||
|
| `-nargs=*` | 0+ arguments, space separated |
|
||||||
|
| `-nargs=+` | 1+ arguments, space reparated |
|
||||||
|
|
||||||
Flow
|
Flow
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue