This commit is contained in:
Rico Sta. Cruz 2015-04-16 23:21:37 +08:00
parent ed29edbb53
commit 38a483f278
1 changed files with 28 additions and 4 deletions

View File

@ -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
---- ----