Update
This commit is contained in:
parent
a32ec3387b
commit
a9c8ccf6cd
44
vimscript.md
44
vimscript.md
|
@ -40,7 +40,12 @@ echo &g:option
|
||||||
echo &l:option
|
echo &l:option
|
||||||
```
|
```
|
||||||
|
|
||||||
### Operation assignment
|
### Operators
|
||||||
|
|
||||||
|
```vim
|
||||||
|
a + b " numbers only!
|
||||||
|
'hello ' . name " concat
|
||||||
|
```
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
let var -= 2
|
let var -= 2
|
||||||
|
@ -48,20 +53,34 @@ let var += 5
|
||||||
let var .= 'string' " concat
|
let var .= 'string' " concat
|
||||||
```
|
```
|
||||||
|
|
||||||
### Strings
|
### [Strings](http://learnvimscriptthehardway.stevelosh.com/chapters/26.html)
|
||||||
|
Also see `:help literal-string` and `:help expr-quote`.
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
let str = "String"
|
let str = "String"
|
||||||
let str = "String with \n newline"
|
let str = "String with \n newline"
|
||||||
|
|
||||||
let literal = 'literal, no \ escaping'
|
let literal = 'literal, no \ escaping'
|
||||||
|
let literal = 'that''s enough' # double '' => '
|
||||||
|
|
||||||
echo "result = " . re " concatenation
|
echo "result = " . re " concatenation
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### [String functions](learnvimscriptthehardway.stevelosh.com/chapters/27.html)
|
||||||
|
Also see `:help functions`.
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
strlen(str) " length
|
strlen(str) " length
|
||||||
|
len(str) " same
|
||||||
strchars(str) " character length
|
strchars(str) " character length
|
||||||
|
|
||||||
|
split("one two three") "=> ['one', 'two', 'three']
|
||||||
|
split("one.two.three", '.') "=> ['one', 'two', 'three']
|
||||||
|
|
||||||
|
join(['a', 'b'], ',') "=> 'a,b'
|
||||||
|
|
||||||
|
tolower('Hello')
|
||||||
|
toupper('Hello')
|
||||||
```
|
```
|
||||||
|
|
||||||
Functions
|
Functions
|
||||||
|
@ -288,14 +307,31 @@ asin() acos() atan()
|
||||||
Vim-isms
|
Vim-isms
|
||||||
--------
|
--------
|
||||||
|
|
||||||
### Execute a command
|
### [Execute a command](http://learnvimscriptthehardway.stevelosh.com/chapters/28.html)
|
||||||
Runs an ex command you typically run with `:`
|
Runs an ex command you typically run with `:`. Also see `:help execute`.
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
execute "vsplit"
|
execute "vsplit"
|
||||||
execute "e " . fnameescape(filename)
|
execute "e " . fnameescape(filename)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### [Running keystrokes](http://learnvimscriptthehardway.stevelosh.com/chapters/29.html)
|
||||||
|
Use `:normal` to execute keystrokes as if you're typing them in normal mode. Combine with `:execute` for special keystrokes.
|
||||||
|
|
||||||
|
```vim
|
||||||
|
normal G
|
||||||
|
normal! G " skips key mappings
|
||||||
|
|
||||||
|
execute "normal! gg/foo\<cr>dd"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Silencing
|
||||||
|
See `:help silent`
|
||||||
|
|
||||||
|
```vim
|
||||||
|
silent g/Aap/p
|
||||||
|
```
|
||||||
|
|
||||||
### Echo
|
### Echo
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
|
|
Loading…
Reference in New Issue