VIM Hacks        Why Vim  Vim                  c9s / Cornelius                   AIINK.com
It doesn’t matter
It does matter
...
MicrosoftVisual Studio
Eclipse
Code Block
Notepad++
....
....
•
••   IDE , Editor
••   IDE , Editor•     XXX Editor ..
••          IDE , Editor•            XXX Editor ..•   ....
MicrosoftWindows      ...
GEdit
Emacs
TextMate
VIM
#!/usr/bin/env perlmy $hppiness = COS::CUP();
#!/usr/bin/env perlmy $hppiness = COS::CUP();     Oops!         “a”
#!/usr/bin/env perlmy $hppiness = COS::CUP();                             xN
#!/usr/bin/env perlmy $hppiness = COS::CUP();                             xN
#!/usr/bin/env perlmy $hppiness = COS::CUP();                         xN
#!/usr/bin/env perlmy $hppiness = COS::CUP();                        xN
#!/usr/bin/env perlmy $hppiness = COS::CUP();                      xN
#!/usr/bin/env perlmy $hppiness = COS::CUP();                     xN
#!/usr/bin/env perlmy $hppiness = COS::CUP();                    xN
#!/usr/bin/env perlmy $hppiness = COS::CUP();                  xN
#!/usr/bin/env perlmy $hppiness = COS::CUP();                 xN
#!/usr/bin/env perlmy $hppiness = COS::CUP();               xN
#!/usr/bin/env perlmy $hppiness = COS::CUP();            xN
#!/usr/bin/env perlmy $hppiness = COS::CUP();        xN
#!/usr/bin/env perlmy $hppiness = COS::CUP();      xN
#!/usr/bin/env perlmy $hppiness = COS::CUP();
#!/usr/bin/env perlmy $happiness = COS::CUP();
#!/usr/bin/env perlmy $happiness = COS::CUP();                              ?
#!/usr/bin/env perlmy $happiness = COS::CUP();                              ?
The VIM way...
VIM:#!/usr/bin/env perlmy $hppiness = COS::CUP();                        F    h
VIM:#!/usr/bin/env perlmy $happiness = COS::CUP();       a ppend a
VIM
VIM
IDE
...
...
!!!
!!!      !!!
VIM
VI Improved
Learning Curve
Vim
Vim• Vim
Vim• Vim• gVim
Vim• Vim• gVim• gVim Easy
Vim• Vim• gVim• gVim Easy• MacVim
Vim• Vim• gVim• gVim Easy• MacVim• Vi in Emacs
Vim• Vim• gVim• gVim Easy• MacVim• Vi in Emacs• Vi in Bash
Vim• Vim• gVim• gVim Easy• MacVim• Vi in Emacs• Vi in Bash• etc ...
Features
1.     Mode
INSERTNORMAL VISUAL SELECT  ... et cetera
ESC      [Ii]NSERT      NORMAL      [Vv]ISUAL
1.1 Normal Mode
Motion
HJKL←↓↑→
# comments ...foreach my $foo ( @bar ) {    #   my @outs = grep /pattern/ , @list;	 	}sub func1 {}
# comments ...foreach my $foo ( @bar ) {    #   my @outs = grep /pattern/ , @list;	 	             Cursor}sub func1 {}
# comments ...foreach my $foo ( @bar ) {    #                         [{   my @outs = grep /pattern/ , @list;	 	}sub func1...
# comments ...foreach my $foo ( @bar ) {    #   my @outs = grep /pattern/ , @list;	 	}                                  f@...
# comments ...foreach my $foo ( @bar ) {    #   my @outs = grep /pattern/ , @list;	 	}                                    ...
# comments ...foreach my $foo ( @bar ) {    #   my @outs = grep /pattern/ , @list;	 	}      ^sub func1 {}
# comments ...    Hforeach my $foo ( @bar ) {    #   my @outs = grep /pattern/ , @list;	 	}sub func1 {}
# comments ...foreach my $foo ( @bar ) {    #   my @outs = grep /pattern/ , @list;	 	 M}sub func1 {}
# comments ...foreach my $foo ( @bar ) {    #   my @outs = grep /pattern/ , @list;	 	}sub func1 {}        L
# comments ...foreach my $foo ( @bar ) {    #   my @outs = grep /pattern/ , @list;	 	}sub func1 {}
# comments ...foreach my $foo ( @bar ) {    #   my @outs = grep	 	}                    C                             Inser...
# comments ...foreach my $foo ( @bar ) {    #   my @outs = grep /pattern/ , @list;	 	}sub func1 {}
# comments ...foreach my $foo ( @bar ) {    #   my @outs = grep /pattern/ , @list;	 	}     %sub func1 {}
:h motion.txt
1.2 Insert Mode
Editing text
Insert Mode• i : Insert text before the cursor
Insert Mode• i : Insert text before the cursor• I : Insert text before the first non-blank in the  line
Insert Mode• i : Insert text before the cursor• I : Insert text before the first non-blank in the  line• a : Append text af...
Insert Mode• i : Insert text before the cursor• I : Insert text before the first non-blank in the  line• a : Append text af...
1.3 Visual Mode
Select region
Visual Mode• v : start Visual mode per character.
Visual Mode• v : start Visual mode per character.• V : start Visual mode linewise.
Visual Mode• v : start Visual mode per character.• V : start Visual mode linewise.• Ctrl-v : start Visual mode blockwise.
Visual Mode• v : start Visual mode per character.• V : start Visual mode linewise.• Ctrl-v : start Visual mode blockwise. ...
2.Syntax Highlight Support
/opt/local/share/vim/vim72$ ls -1 syntax/ | wc -l   520
Syntax
~/.vim/syntax/[filetype].vim
~/.vim/syntax/[filetype].vimsyn match [id] [re] [options]
~/.vim/syntax/[filetype].vimsyn match [id] [re] [options]syn region [id] start=[re] end=[re]
~/.vim/syntax/[filetype].vimsyn match [id] [re] [options]syn region [id] start=[re] end=[re]syn keyword [id] [keyword] ...
~/.vim/syntax/[filetype].vimsyn match [id] [re] [options]syn region [id] start=[re] end=[re]syn keyword [id] [keyword] ......
:help syntax.txt
3.     ENCODING
:set fencs=utf-8,gbk,big5,euc-jp,utf-16le:set fenc=utf-8 enc=utf-8 tenc=utf-8
:set fencs=utf-8,gbk,big5,euc-jp,utf-16le:set fenc=utf-8 enc=utf-8 tenc=utf-8
Vim:set fencs=utf-8,gbk,big5,euc-jp,utf-16le:set fenc=utf-8 enc=utf-8 tenc=utf-8
:set fencs=utf-8,gbk,big5,euc-jp,utf-16le:set fenc=utf-8 enc=utf-8 tenc=utf-8
:set fencs=utf-8,gbk,big5,euc-jp,utf-16le:set fenc=utf-8 enc=utf-8 tenc=utf-8
:set fencs=utf-8,gbk,big5,euc-jp,utf-16le:set fenc=utf-8 enc=utf-8 tenc=utf-8                               Terminal
:help encoding
4. Key Mapping
:map:nmap:vmap:imap:smap:xmap... more
:map       (all):nmap      (normal mode):vmap      (visual mode):imap      (insert mode):smap      (select mode):xmap     ...
:map       (all):nmap      (normal mode):vmap      (visual mode):imap      (insert mode):smap      (select mode):xmap     ...
:nmap <C-c><C-c> :!gcc -Wall % -o %:r.out<CR>     Ctrl C    Ctrl C                GCC                                     ...
Normal Mode      Tab   Shift-Tab   nmap       <tab>   v>   nmap       <s-tab> v<   vmap       <tab>   >gv   vmap       <s-...
nmap        <tab>   v>         nmap        <s-tab> v<         vmap        <tab>   >gv         vmap        <s-tab> <gvVisua...
nmap        <tab>   v>         nmap        <s-tab> v<                        When mappings and menus are defined with      ...
imap <F2> <C-R>=strftime("%c")<CR>   Insert Mode       F2
cmap   <c-a>   <home>cmap   <c-e>   <end>cnoremap <c-b>        <left>cnoremap <c-d>        <del>cnoremap <c-f>        <rig...
:h map.txt
5. TEXT OBJECT
Text Object• word• string      ⇛             action• paragraph       (yank,delete,change ...etc)• block
Operator Mappingv|c|d       i|a            { | [ | ( |“ |‘   visual                         Region  change    Inner Object...
va{
function ( blah , blah )              ci(     function ( )   function ( new_args )
“Hello World”          di”     “”“Hello New World”
6.     TAB PAPGES
:tabnew
:tabnew:tabedit path/to/file
:tabnew:tabedit path/to/file:tabfind path/to/file
:help tabpage.txt
7.     FOLDS
FOLD IS
Fold Methods
Fold Methods Syntax Fold
Fold Methods Syntax Fold         :set foldmethod=syntax           $VIMRUNTIME/syntax/*.vim
Perl                  :/opt/local/share/vim/vim72/syntax/perl.vimif exists("perl_want_scope_in_variables")“ .....if exists...
Fold Methods Syntax Fold Marker Fold
Fold Methods Syntax Fold Marker Fold          :set foldmethod=marker                  “{{{“   “}}}”
# fold this {{{function do_something {    echo “COSCUP”;}#   }}}
Fold Methods Syntax Fold Marker Fold Indent Fold
Fold Methods Syntax Fold Marker Fold Indent Fold          :set foldmethod=indent
Fold Methods Syntax Fold Marker Fold Indent Fold Manual Fold
:set foldmethod=manual              zf
autocmd   BufWinLeave *.*          silent mkviewautocmd   BufWinEnter *.*          silent loadview                autocmd ...
Fold Methods Syntax Fold Marker Fold Indent Fold Manual Fold Expr Fold (Custom Fold Function)
:set foldexpr=MyFoldLevel(v:lnum)
Fold Methods Syntax Fold Marker Fold Indent Fold Manual Fold Expr Fold (Custom Fold Function) Diff Fold
8.Modeline & FileType
ModeLine
" vim:fdm=marker:sw=2:ts=2:et:fdl=0:"============================" Author:   Cornelius <cornelius.howl{at}gmail{dot}com >
" vim:fdm=marker:sw=2:ts=2:et:fdl=0:"============================" Author:   Cornelius <cornelius.howl{at}gmail{dot}com > ...
FileType
~/.vim/ftplugin/ruby.vim                           vimrc
~/.vim/filetype.vim                      filetype.vim
9.FORMATTING
:set equalprg=perltidy
:set equalprg=perltidy                             “=”                  perltidy
autocmd Filetype perl :set equalprg=perltidy                 autocmd                   equalprg
autocmd Filetype c :set equalprg=indent               C         GNU Ident
SQL $ cat bin/sql-beautify.pl #!/usr/bin/env perl use warnings; use strict; use SQL::Beautify; local $/; my $sql = SQL::Be...
10. QuickFix
:grep & :make
:grep [pattern] [filepath]
:grep [pattern] [filepath]     grepprg (   vimgrep)      grep             QuickFix
QuickFix Window
:set grepprg=/path/to/grep      grepprg (   VIM   grep)
:make
:make     makeprg (    make)Makefile.            compiler  output parser
:set makeprg=gmake    makeprg (   make)
Result ⇛ QuickFix Window
:copenQuickFix Window
:ccloseQuickFix Window
:cnext   Result
:cprevious     Result
QuickFix Window Togglecom! -bang -nargs=? QFix cal QFixToggle(<bang>0)fu! QFixToggle(forced)   if exists("g:qfix_win") && ...
QuickFix Window Togglecom! -bang -nargs=? QFix cal QFixToggle(<bang>0)fu! QFixToggle(forced)   if exists("g:qfix_win") && ...
11.  Plugin
SnipMate  TextMate
snippet cla class .. initialize .. end    class ${1:`substitute(Filename(), ^., u&, )`}        def initialize(${2:args})  ...
DBExt.vimOracle, Sybase, MSSQL ,  MySQL, DBI
xml.vimXML
FuzzyFinder.vim Fuzzy/Partial pattern explorer
The_NERD_TREE.vim
The NERD Commenter
taglist.vim     ctagsmacro , function , variable
cscopeC
autocomplpop.vim
MRUmost recently used
bufexplorer.vim    Buffer Explorer
Rails.vim
git-vim
!
!
Vimana  Vim script Manager
• Vimball• Archive File ( zip , rar )• .vim file
POWERED BYPerl
CPAN   Vimana $ cpan Vimana
$ vimana search xml
$ vimana search xmlrrd.vim             - Edit RRD data with Vim.qt.vim              - tiny tool for the uic used in Qt fro...
script$ vimana info xml.vim
xml.vim$ vimana install xml.vim
$ vimana   install   xml.vim$ vimana   install   rails.vim$ vimana   install   the-nerd-tree.vim$ vimana   install   tagli...
Git Repositoryhttp://github.com/c9s/Vimana/tree/master
ENJOY
Thank You
Demo  ....
Q &A
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Vim Hacks
Upcoming SlideShare
Loading in...5
×

Vim Hacks

1,182

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,182
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
22
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Vim Hacks

  1. 1. VIM Hacks Why Vim Vim c9s / Cornelius AIINK.com
  2. 2. It doesn’t matter
  3. 3. It does matter
  4. 4. ...
  5. 5. MicrosoftVisual Studio
  6. 6. Eclipse
  7. 7. Code Block
  8. 8. Notepad++
  9. 9. ....
  10. 10. ....
  11. 11.
  12. 12. •• IDE , Editor
  13. 13. •• IDE , Editor• XXX Editor ..
  14. 14. •• IDE , Editor• XXX Editor ..• ....
  15. 15. MicrosoftWindows ...
  16. 16. GEdit
  17. 17. Emacs
  18. 18. TextMate
  19. 19. VIM
  20. 20. #!/usr/bin/env perlmy $hppiness = COS::CUP();
  21. 21. #!/usr/bin/env perlmy $hppiness = COS::CUP(); Oops! “a”
  22. 22. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  23. 23. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  24. 24. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  25. 25. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  26. 26. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  27. 27. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  28. 28. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  29. 29. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  30. 30. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  31. 31. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  32. 32. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  33. 33. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  34. 34. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  35. 35. #!/usr/bin/env perlmy $hppiness = COS::CUP();
  36. 36. #!/usr/bin/env perlmy $happiness = COS::CUP();
  37. 37. #!/usr/bin/env perlmy $happiness = COS::CUP(); ?
  38. 38. #!/usr/bin/env perlmy $happiness = COS::CUP(); ?
  39. 39. The VIM way...
  40. 40. VIM:#!/usr/bin/env perlmy $hppiness = COS::CUP(); F h
  41. 41. VIM:#!/usr/bin/env perlmy $happiness = COS::CUP(); a ppend a
  42. 42. VIM
  43. 43. VIM
  44. 44. IDE
  45. 45. ...
  46. 46. ...
  47. 47. !!!
  48. 48. !!! !!!
  49. 49. VIM
  50. 50. VI Improved
  51. 51. Learning Curve
  52. 52. Vim
  53. 53. Vim• Vim
  54. 54. Vim• Vim• gVim
  55. 55. Vim• Vim• gVim• gVim Easy
  56. 56. Vim• Vim• gVim• gVim Easy• MacVim
  57. 57. Vim• Vim• gVim• gVim Easy• MacVim• Vi in Emacs
  58. 58. Vim• Vim• gVim• gVim Easy• MacVim• Vi in Emacs• Vi in Bash
  59. 59. Vim• Vim• gVim• gVim Easy• MacVim• Vi in Emacs• Vi in Bash• etc ...
  60. 60. Features
  61. 61. 1. Mode
  62. 62. INSERTNORMAL VISUAL SELECT ... et cetera
  63. 63. ESC [Ii]NSERT NORMAL [Vv]ISUAL
  64. 64. 1.1 Normal Mode
  65. 65. Motion
  66. 66. HJKL←↓↑→
  67. 67. # comments ...foreach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; }sub func1 {}
  68. 68. # comments ...foreach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; Cursor}sub func1 {}
  69. 69. # comments ...foreach my $foo ( @bar ) { # [{ my @outs = grep /pattern/ , @list; }sub func1 {}
  70. 70. # comments ...foreach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; } f@sub func1 {}
  71. 71. # comments ...foreach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; } $sub func1 {}
  72. 72. # comments ...foreach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; } ^sub func1 {}
  73. 73. # comments ... Hforeach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; }sub func1 {}
  74. 74. # comments ...foreach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; M}sub func1 {}
  75. 75. # comments ...foreach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; }sub func1 {} L
  76. 76. # comments ...foreach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; }sub func1 {}
  77. 77. # comments ...foreach my $foo ( @bar ) { # my @outs = grep } C Insert modesub func1 {}
  78. 78. # comments ...foreach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; }sub func1 {}
  79. 79. # comments ...foreach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; } %sub func1 {}
  80. 80. :h motion.txt
  81. 81. 1.2 Insert Mode
  82. 82. Editing text
  83. 83. Insert Mode• i : Insert text before the cursor
  84. 84. Insert Mode• i : Insert text before the cursor• I : Insert text before the first non-blank in the line
  85. 85. Insert Mode• i : Insert text before the cursor• I : Insert text before the first non-blank in the line• a : Append text after the cursor
  86. 86. Insert Mode• i : Insert text before the cursor• I : Insert text before the first non-blank in the line• a : Append text after the cursor• A : Append text at the end of the line
  87. 87. 1.3 Visual Mode
  88. 88. Select region
  89. 89. Visual Mode• v : start Visual mode per character.
  90. 90. Visual Mode• v : start Visual mode per character.• V : start Visual mode linewise.
  91. 91. Visual Mode• v : start Visual mode per character.• V : start Visual mode linewise.• Ctrl-v : start Visual mode blockwise.
  92. 92. Visual Mode• v : start Visual mode per character.• V : start Visual mode linewise.• Ctrl-v : start Visual mode blockwise. operator y (yank) , d (delete) , c (change) ... etc
  93. 93. 2.Syntax Highlight Support
  94. 94. /opt/local/share/vim/vim72$ ls -1 syntax/ | wc -l 520
  95. 95. Syntax
  96. 96. ~/.vim/syntax/[filetype].vim
  97. 97. ~/.vim/syntax/[filetype].vimsyn match [id] [re] [options]
  98. 98. ~/.vim/syntax/[filetype].vimsyn match [id] [re] [options]syn region [id] start=[re] end=[re]
  99. 99. ~/.vim/syntax/[filetype].vimsyn match [id] [re] [options]syn region [id] start=[re] end=[re]syn keyword [id] [keyword] ...
  100. 100. ~/.vim/syntax/[filetype].vimsyn match [id] [re] [options]syn region [id] start=[re] end=[re]syn keyword [id] [keyword] ...hi [id] guibg=[color] ctermfg=[color]
  101. 101. :help syntax.txt
  102. 102. 3. ENCODING
  103. 103. :set fencs=utf-8,gbk,big5,euc-jp,utf-16le:set fenc=utf-8 enc=utf-8 tenc=utf-8
  104. 104. :set fencs=utf-8,gbk,big5,euc-jp,utf-16le:set fenc=utf-8 enc=utf-8 tenc=utf-8
  105. 105. Vim:set fencs=utf-8,gbk,big5,euc-jp,utf-16le:set fenc=utf-8 enc=utf-8 tenc=utf-8
  106. 106. :set fencs=utf-8,gbk,big5,euc-jp,utf-16le:set fenc=utf-8 enc=utf-8 tenc=utf-8
  107. 107. :set fencs=utf-8,gbk,big5,euc-jp,utf-16le:set fenc=utf-8 enc=utf-8 tenc=utf-8
  108. 108. :set fencs=utf-8,gbk,big5,euc-jp,utf-16le:set fenc=utf-8 enc=utf-8 tenc=utf-8 Terminal
  109. 109. :help encoding
  110. 110. 4. Key Mapping
  111. 111. :map:nmap:vmap:imap:smap:xmap... more
  112. 112. :map (all):nmap (normal mode):vmap (visual mode):imap (insert mode):smap (select mode):xmap (visual , select mode)... more
  113. 113. :map (all):nmap (normal mode):vmap (visual mode):imap (insert mode):smap (select mode):xmap (visual , select mode)... more
  114. 114. :nmap <C-c><C-c> :!gcc -Wall % -o %:r.out<CR> Ctrl C Ctrl C GCC .out
  115. 115. Normal Mode Tab Shift-Tab nmap <tab> v> nmap <s-tab> v< vmap <tab> >gv vmap <s-tab> <gv
  116. 116. nmap <tab> v> nmap <s-tab> v< vmap <tab> >gv vmap <s-tab> <gvVisual/Select Mode Tab Shift-Tab
  117. 117. nmap <tab> v> nmap <s-tab> v< When mappings and menus are defined with the |:vmap| or |:vmenu| command they work vmap <tab> >gv both in Visual mode and in Select mode. When these are used in Select mode Vim vmap <s-tab> <gv automatically switches to Visual mode, so that the same behavior as in Visual mode is effective.Visual/Select Mode Tab Shift-Tab
  118. 118. imap <F2> <C-R>=strftime("%c")<CR> Insert Mode F2
  119. 119. cmap <c-a> <home>cmap <c-e> <end>cnoremap <c-b> <left>cnoremap <c-d> <del>cnoremap <c-f> <right>cnoremap <c-n> <down>cnoremap <c-p> <up>cnoremap <esc><c-b> <s-left>cnoremap <esc><c-f> <s-right> Command Mode Bash Key Binding
  120. 120. :h map.txt
  121. 121. 5. TEXT OBJECT
  122. 122. Text Object• word• string ⇛ action• paragraph (yank,delete,change ...etc)• block
  123. 123. Operator Mappingv|c|d i|a { | [ | ( |“ |‘ visual Region change Inner Object {} delete An Object [] () ““Operator ‘‘
  124. 124. va{
  125. 125. function ( blah , blah ) ci( function ( ) function ( new_args )
  126. 126. “Hello World” di” “”“Hello New World”
  127. 127. 6. TAB PAPGES
  128. 128. :tabnew
  129. 129. :tabnew:tabedit path/to/file
  130. 130. :tabnew:tabedit path/to/file:tabfind path/to/file
  131. 131. :help tabpage.txt
  132. 132. 7. FOLDS
  133. 133. FOLD IS
  134. 134. Fold Methods
  135. 135. Fold Methods Syntax Fold
  136. 136. Fold Methods Syntax Fold :set foldmethod=syntax $VIMRUNTIME/syntax/*.vim
  137. 137. Perl :/opt/local/share/vim/vim72/syntax/perl.vimif exists("perl_want_scope_in_variables")“ .....if exists("perl_extended_vars")“ ..... if exists("perl_fold")“ ..... .vimrc (Fold) let perl_fold = 1 let perl_extended_vars = 1 “ .... etc
  138. 138. Fold Methods Syntax Fold Marker Fold
  139. 139. Fold Methods Syntax Fold Marker Fold :set foldmethod=marker “{{{“ “}}}”
  140. 140. # fold this {{{function do_something { echo “COSCUP”;}# }}}
  141. 141. Fold Methods Syntax Fold Marker Fold Indent Fold
  142. 142. Fold Methods Syntax Fold Marker Fold Indent Fold :set foldmethod=indent
  143. 143. Fold Methods Syntax Fold Marker Fold Indent Fold Manual Fold
  144. 144. :set foldmethod=manual zf
  145. 145. autocmd BufWinLeave *.* silent mkviewautocmd BufWinEnter *.* silent loadview autocmd mkview , loadview ~/.vim/view/
  146. 146. Fold Methods Syntax Fold Marker Fold Indent Fold Manual Fold Expr Fold (Custom Fold Function)
  147. 147. :set foldexpr=MyFoldLevel(v:lnum)
  148. 148. Fold Methods Syntax Fold Marker Fold Indent Fold Manual Fold Expr Fold (Custom Fold Function) Diff Fold
  149. 149. 8.Modeline & FileType
  150. 150. ModeLine
  151. 151. " vim:fdm=marker:sw=2:ts=2:et:fdl=0:"============================" Author: Cornelius <cornelius.howl{at}gmail{dot}com >
  152. 152. " vim:fdm=marker:sw=2:ts=2:et:fdl=0:"============================" Author: Cornelius <cornelius.howl{at}gmail{dot}com > Marker Tab Fold (Level 0 )
  153. 153. FileType
  154. 154. ~/.vim/ftplugin/ruby.vim vimrc
  155. 155. ~/.vim/filetype.vim filetype.vim
  156. 156. 9.FORMATTING
  157. 157. :set equalprg=perltidy
  158. 158. :set equalprg=perltidy “=” perltidy
  159. 159. autocmd Filetype perl :set equalprg=perltidy autocmd equalprg
  160. 160. autocmd Filetype c :set equalprg=indent C GNU Ident
  161. 161. SQL $ cat bin/sql-beautify.pl #!/usr/bin/env perl use warnings; use strict; use SQL::Beautify; local $/; my $sql = SQL::Beautify->new( query => <STDIN> , spaces => 4 , break => "n" ); print $sql->beautify;autocmd Filetype sql :set equalprg=sql-beautify.pl SQL Filter
  162. 162. 10. QuickFix
  163. 163. :grep & :make
  164. 164. :grep [pattern] [filepath]
  165. 165. :grep [pattern] [filepath] grepprg ( vimgrep) grep QuickFix
  166. 166. QuickFix Window
  167. 167. :set grepprg=/path/to/grep grepprg ( VIM grep)
  168. 168. :make
  169. 169. :make makeprg ( make)Makefile. compiler output parser
  170. 170. :set makeprg=gmake makeprg ( make)
  171. 171. Result ⇛ QuickFix Window
  172. 172. :copenQuickFix Window
  173. 173. :ccloseQuickFix Window
  174. 174. :cnext Result
  175. 175. :cprevious Result
  176. 176. QuickFix Window Togglecom! -bang -nargs=? QFix cal QFixToggle(<bang>0)fu! QFixToggle(forced) if exists("g:qfix_win") && a:forced == 0 cclose unlet g:qfix_win else copen 10 let g:qfix_win = bufnr("$") enendfnn <leader>q :QFix<cr>
  177. 177. QuickFix Window Togglecom! -bang -nargs=? QFix cal QFixToggle(<bang>0)fu! QFixToggle(forced) if exists("g:qfix_win") && a:forced == 0 cclose unlet g:qfix_win else copen 10 let g:qfix_win = bufnr("$") enendfnn <leader>q :QFix<cr> nmap “q” , <leader> “”
  178. 178. 11. Plugin
  179. 179. SnipMate TextMate
  180. 180. snippet cla class .. initialize .. end class ${1:`substitute(Filename(), ^., u&, )`} def initialize(${2:args}) ${3} end end
  181. 181. DBExt.vimOracle, Sybase, MSSQL , MySQL, DBI
  182. 182. xml.vimXML
  183. 183. FuzzyFinder.vim Fuzzy/Partial pattern explorer
  184. 184. The_NERD_TREE.vim
  185. 185. The NERD Commenter
  186. 186. taglist.vim ctagsmacro , function , variable
  187. 187. cscopeC
  188. 188. autocomplpop.vim
  189. 189. MRUmost recently used
  190. 190. bufexplorer.vim Buffer Explorer
  191. 191. Rails.vim
  192. 192. git-vim
  193. 193. !
  194. 194. !
  195. 195. Vimana Vim script Manager
  196. 196. • Vimball• Archive File ( zip , rar )• .vim file
  197. 197. POWERED BYPerl
  198. 198. CPAN Vimana $ cpan Vimana
  199. 199. $ vimana search xml
  200. 200. $ vimana search xmlrrd.vim - Edit RRD data with Vim.qt.vim - tiny tool for the uic used in Qt fromTrolltechsyntax-for-xul - Highlighting for XML User interface Language.maven2.vim - Compiler plugin for maven2 .... skip
  201. 201. script$ vimana info xml.vim
  202. 202. xml.vim$ vimana install xml.vim
  203. 203. $ vimana install xml.vim$ vimana install rails.vim$ vimana install the-nerd-tree.vim$ vimana install taglist.vim$ vimana install snipmate$ vimana install fuzzyfinder.vimetc ... ALL Works
  204. 204. Git Repositoryhttp://github.com/c9s/Vimana/tree/master
  205. 205. ENJOY
  206. 206. Thank You
  207. 207. Demo ....
  208. 208. Q &A
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×