Reputation: 195
In section 4 of the Vim reference manual, it lists a number of builtin functions:
4. Builtin Functions *functions*
See |function-list| for a list grouped by what the function is used for.
(Use CTRL-] on the function name to jump to the full explanation.)
USAGE RESULT DESCRIPTION ~
abs({expr}) Float or Number absolute value of {expr}
acos({expr}) Float arc cosine of {expr}
add({object}, {item}) List/Blob append {item} to {object}
and({expr}, {expr}) Number bitwise AND
append({lnum}, {text}) Number append {text} below line {lnum}
How do I call these functions? How do I for example get the absolute value of a number?
Upvotes: 2
Views: 1495
Reputation: 196476
The reference manual is borderline useless without the foundations provided by the user manual.
Functions are introduced in chapter 41 of the user manual:
:help usr_41.txt
Upvotes: 1
Reputation: 32926
First, note there is no visible difference between user functions and built-in functions from a usage point of view.
Functions that return nothing are meant to be called with :call
-- note, that they will still always return 0.
The other functions return expressions. These expressions can be
getline('.')[col('.')-1]
:echo
an expression:let
:execute
another vim ex-command, .e.g :exe line('$')/2
Upvotes: 0
Reputation: 76409
You can call a built-in function like so, with the call command, or in an expression:
let x = abs(-2)
" or, for functions where you're not interested in the return value:
:call clearmatches()
Upvotes: 3