René Nyffenegger's collection of things on the web | |
René Nyffenegger on Oracle - Most wanted - Feedback
- Follow @renenyffenegger
|
Functions in vim | ||
TODO: merge with /vim/scripting/functions.html
Yet to be finished....
function Funcname() ... endfunction Replacing functions
Existing functions can be replaced with a ! following the
function keyword:
function! Funcname() ... endfunction Function names
Functions must either start with a capital letter. If the function is local to a script, it needs not necessarly start with a capital letter,
yet, it must start with a
s:
Arguments
Arguments need a a: prefix within the function body, but not within the function declaration.
function Sum (arg_1, arg_2) echo a:arg_1 + a:arg_2 endfunction Functions operating on a range
If a function is declared with range it will only be executed once when invoked like :'a,'b FirstLastLine()
a:firstline and a:lastline will be set accordingly
function! FirstLastLine() range echo a:firstline . " " . a:lastline endfunction |