OK, I feel myself empowered enough to actually write a "Hello World!" in VIM.
let hw = "Hello ".a:wrld."!"
Save that to
hw.vimand run this:
$ vim -u hw.vim -c ":q"
It should print "Hello World!" and wait for you to press
Enterbefore quiting. (
-u hw.vimtells vim to load hw.vim as substitute of ~/.vimrc and
-c ":q"tells vim after loading ~/.vimrc (which is substituted with hw.vim) to execute ":q" to terminate.)
:endfunctionare start and end of function definition.
:letcreates new variable
hwwhich contains string "Hello " concatenated with
a:wrld(function argument) and "!". (
:help :letdescribes operator '.' which is string concatenation operator.)
:echois used to print the value contained in variable
hwto screen. If we pass as parameter "World" to the function,
hwwould contain "Hello World!" string.
N.B. Colon ':' before command names, when is inside of script file - e.g. ~/.vimrc - is optional and used by me here merely to highlight that commands are all from normal mode. Also when you say to VIM
:help :let, colon before
letwould tell vim that you are interested precisely in
letcommand of normal mode - not something else. (Just like in
:help 'ts', where single quotes tells vim to look for
tsonly amongst settable options.)
P.S. Adding that function to you ~/.vimrc with
call Hello($LOGNAME)would greet you with silly "Hello <Your-Login-Name-Here>!" message every time you would launch vim.