From 0dfb0595a77758b0d704be2f6afbbce4a565309d Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Fri, 17 Apr 2015 19:12:59 +0800 Subject: [PATCH] Update vimscript --- vimscript.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/vimscript.md b/vimscript.md index a457dbe88..75aad5d1c 100644 --- a/vimscript.md +++ b/vimscript.md @@ -3,14 +3,30 @@ title: Vim script hljs_languages: [vim] --- +### Start hacking. +You can either put this in a script (`script.vim`) and run it (`:source script.vim`), or you can type the commands individually in normal mode as `:let` and `:echo`. + ```vim let name = "John" echo "Hello, " . name ``` {:.light} -### Start hacking. -You can either put this in a script (`script.vim`) and run it (`:source script.vim`), or you can type the commands individually in normal mode as `:let` and `:echo`. +### Learn by example +[Here](http://www.vimbits.com/bits/46)'s another example with [functions](#functions), [variables](#variables) and [mapping](#mapping). + +```vim +function! SuperTab() + let l:part = strpart(getline('.'),col('.')-2,1) + if (l:part=~'^\W\?$') + return "\" + else + return "\" + endif +endfunction + +imap =SuperTab() +``` Variables ---------