Thursday, May 24, 2012

Vim script optimization tips

Is there a resource concerning the writing of optimized
Vim scripts (both memory usage and performance).

For instance:
Should variable name be short?
Should spaces not be put between tokens?
"value=" . value
a + b
let cnt = cnt + 1
versus
"value=".value
a+b
let cnt +=1
Since Vim does not have a switch/case statement (??)
are a chain of if-elseifs the best one can do.
In a function is accessing a parameter
func Foo(p)
let x = a:p "
endfunc
slower than accessing a local that has been set to the parameter
(ignoring the cost of setting the local).
func Foo(p)
let p = a:p
let x = p " faster or slower than x = a:p
endfunc
In many scripts I've seen, it is the short version key words,
options, etc are used, e.g,
func rather than function


Thanks
Richard

--
Quis custodiet ipsos custodes

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment