• Like
  • Save
Vim Script Programming
Upcoming SlideShare
Loading in...5
×
 

Vim Script Programming

on

  • 13,330 views

 

Statistics

Views

Total Views
13,330
Views on SlideShare
10,109
Embed Views
3,221

Actions

Likes
20
Downloads
181
Comments
0

23 Embeds 3,221

http://c9s.blogspot.com 1720
http://c9s.blogspot.tw 1407
http://c9s.blogspot.hk 39
http://twitter.com 11
http://c9s.blogspot.jp 8
https://twitter.com 4
http://c9s.blogspot.fr 4
http://c9s.blogspot.com.au 3
http://c9s.blogspot.ca 3
http://static.slidesharecdn.com 3
http://tweetedtimes.com 3
http://c9s.blogspot.ch 3
http://c9s.blogspot.kr 2
http://webcache.googleusercontent.com 2
http://c9s.blogspot.in 1
http://c9s.blogspot.ru 1
http://translate.googleusercontent.com 1
http://www.slideshare.net 1
http://c9s.me 1
http://us-w1.rockmelt.com 1
http://a0.twimg.com 1
http://passing.tk 1
http://c9s.blogspot.ae 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Vim Script Programming Vim Script Programming Presentation Transcript

    • Vim Script Programming Vim Script (c9s) Fork Me on Github http://github.com/c9s
    • • Programmable interface • vim script • Perl / Python / Ruby / Mzscheme ...
    • Outline - Vim Script • Comment • Looping • Variable • Command • Variable scope • Mapping • Special variable • Completion • Function • Autocommand • function scope • Autogroup • built-in function • Utility • Condition • vim-makefile
    • Prepare
    • Region Eval http://gist.github.com/444528 * Press ‘V’ then select region * Press ‘e’ to evaluate region
    • To run script :source [filename] :source % # current file
    • Debugging :messages :set verbose=10 “ verbose mode :verbose *command*
    • Help section :help *section* option :help ‘option_name’ mode :help [icv]_..... command :help :command_name
    • Alias • source => so :so • function => func :func Foo(bar) • endfunction => endf :endf
    • Variable let variable = 123 let string = “string” let list = [1,2,3] let strlist = [ “bar” , “foo” ] let dict = { ‘phone’: ‘01234567’ } let dict.name = “Chopin” echo dict
    • Variable Scope • non-prefix = global • g: global • s: script • b: buffer • v: vim built-in • a: function arguments
    • Variable Scope • let var = “string” • let g:var_global = “global” • let s:var_script = “script” • let b:var_buffer = “buffer”
    • Condition if boo > 2 elseif str == “string” elseif str =~ ‘[a-z]+’ endif
    • Looping while running == 1 echo “Run...” endwhile for i in [1,2,3,4] endfor
    • Looping for i in range(1,10) “ i = 1 ~ 10 endfor
    • Override Function Uppercase fun! Test() .. blah endf
    • Override Function Uppercase fun! Test() .. blah endf call Test() “ no return value
    • Override Function Uppercase fun! Test() .. blah return 3 endf let ret = Test() Return 3
    • Function arguments fun! Foo(bar) echo a:bar endf fun! Foo(...) echo a:000 echo a:001 endf
    • Function arguments fun! Foo(bar) echo a:bar endf non-modifiable fun! Foo(...) echo a:000 echo a:001 endf
    • Function arguments fun! Foo(bar) echo a:bar endf non-modifiable fun! Foo(...) echo a:000 count of args echo a:001 endf
    • Function arguments fun! Foo(bar) echo a:bar endf non-modifiable fun! Foo(...) echo a:000 count of args echo a:001 endf arg1
    • Function Scope fun! s:Foo() endf Script Scope fun! g:Foo() endf Global Scope fun! b:Foo() endf Buffer Scope
    • Built-in Functions • List related: add() , remove() , filter() , map (), len() , sort(), empty(), join(), range() ... • Dictionary related: keys() , values() , has_key() , has_value(), extend() ... • String related: stridx(), strridx(), strlen(), substitute() , submatch(), strpart(), expand () ...
    • Built-in Functions • List related: add() , remove() , filter() , map (), len() , sort(), empty(), join(), range() ... • Dictionary related: keys() , values() , has_key() , has_value(), extend() ... • String related: stridx(), strridx(), strlen(), substitute() , submatch(), strpart(), expand () ... *function-list*
    • Built-in Function • Buffer related: bufnr() , bufexists() , buflisted () , bufname() ... etc • Window related: winbufnr(), bufwinnr(), winnr() • Misc: getreg(), setreg(), system(), eventhandler () , getpid() ...
    • Autoload function Define your library function: ~/.vim/autoload/foo.vim fun! foo#blah() endf In your script: call foo#blah()
    • Command com! -range DoWrite :write flags command name execute
    • Command Define line range for command: -range -range=% -range=N -count=N
    • Command Other options: -bang -bar -register -buffer -complete=[type]
    • Command Template arguments: <line1>,<line2> <count> <bang> <reg> <args> <f-args> <q-args> <lt>
    • Syntax • syn list • syn keyword [ID] .... • syn match [ID] .... • syn region [ID] ... • hi [ID] [Attributes]
    • Runtime Directory /Users/c9s/.vim/ |-- after |-- autoload |-- colors |-- doc |-- ftdetect |-- ftplugin | |-- c | |-- cabal | |-- cg .... |-- indent |-- plugin |-- syntax | |-- c | |-- javascript | `-- perl
    • Utilities • vim-makefile • vim-uploader • Vimana
    • Vim Makefile • make install • make uninstall • make link • make dist
    • Thanks http://github.com/c9s