Your SlideShare is downloading. ×
0
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
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
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
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
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
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
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
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Vim Hacks

1,166

Published on

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

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

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. VIM Hacks Why Vim Vim c9s / Cornelius AIINK.com
  • 2. It doesn’t matter
  • 3. It does matter
  • 4. ...
  • 5. MicrosoftVisual Studio
  • 6. Eclipse
  • 7. Code Block
  • 8. Notepad++
  • 9. ....
  • 10. ....
  • 11. •
  • 12. •• IDE , Editor
  • 13. •• IDE , Editor• XXX Editor ..
  • 14. •• IDE , Editor• XXX Editor ..• ....
  • 15. MicrosoftWindows ...
  • 16. GEdit
  • 17. Emacs
  • 18. TextMate
  • 19. VIM
  • 20. #!/usr/bin/env perlmy $hppiness = COS::CUP();
  • 21. #!/usr/bin/env perlmy $hppiness = COS::CUP(); Oops! “a”
  • 22. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  • 23. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  • 24. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  • 25. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  • 26. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  • 27. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  • 28. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  • 29. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  • 30. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  • 31. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  • 32. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  • 33. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  • 34. #!/usr/bin/env perlmy $hppiness = COS::CUP(); xN
  • 35. #!/usr/bin/env perlmy $hppiness = COS::CUP();
  • 36. #!/usr/bin/env perlmy $happiness = COS::CUP();
  • 37. #!/usr/bin/env perlmy $happiness = COS::CUP(); ?
  • 38. #!/usr/bin/env perlmy $happiness = COS::CUP(); ?
  • 39. The VIM way...
  • 40. VIM:#!/usr/bin/env perlmy $hppiness = COS::CUP(); F h
  • 41. VIM:#!/usr/bin/env perlmy $happiness = COS::CUP(); a ppend a
  • 42. VIM
  • 43. VIM
  • 44. IDE
  • 45. ...
  • 46. ...
  • 47. !!!
  • 48. !!! !!!
  • 49. VIM
  • 50. VI Improved
  • 51. Learning Curve
  • 52. Vim
  • 53. Vim• Vim
  • 54. Vim• Vim• gVim
  • 55. Vim• Vim• gVim• gVim Easy
  • 56. Vim• Vim• gVim• gVim Easy• MacVim
  • 57. Vim• Vim• gVim• gVim Easy• MacVim• Vi in Emacs
  • 58. Vim• Vim• gVim• gVim Easy• MacVim• Vi in Emacs• Vi in Bash
  • 59. Vim• Vim• gVim• gVim Easy• MacVim• Vi in Emacs• Vi in Bash• etc ...
  • 60. Features
  • 61. 1. Mode
  • 62. INSERTNORMAL VISUAL SELECT ... et cetera
  • 63. ESC [Ii]NSERT NORMAL [Vv]ISUAL
  • 64. 1.1 Normal Mode
  • 65. Motion
  • 66. HJKL←↓↑→
  • 67. # comments ...foreach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; }sub func1 {}
  • 68. # comments ...foreach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; Cursor}sub func1 {}
  • 69. # comments ...foreach my $foo ( @bar ) { # [{ my @outs = grep /pattern/ , @list; }sub func1 {}
  • 70. # comments ...foreach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; } f@sub func1 {}
  • 71. # comments ...foreach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; } $sub func1 {}
  • 72. # comments ...foreach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; } ^sub func1 {}
  • 73. # comments ... Hforeach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; }sub func1 {}
  • 74. # comments ...foreach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; M}sub func1 {}
  • 75. # comments ...foreach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; }sub func1 {} L
  • 76. # comments ...foreach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; }sub func1 {}
  • 77. # comments ...foreach my $foo ( @bar ) { # my @outs = grep } C Insert modesub func1 {}
  • 78. # comments ...foreach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; }sub func1 {}
  • 79. # comments ...foreach my $foo ( @bar ) { # my @outs = grep /pattern/ , @list; } %sub func1 {}
  • 80. :h motion.txt
  • 81. 1.2 Insert Mode
  • 82. Editing text
  • 83. Insert Mode• i : Insert text before the cursor
  • 84. Insert Mode• i : Insert text before the cursor• I : Insert text before the first non-blank in the line
  • 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. 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. 1.3 Visual Mode
  • 88. Select region
  • 89. Visual Mode• v : start Visual mode per character.
  • 90. Visual Mode• v : start Visual mode per character.• V : start Visual mode linewise.
  • 91. Visual Mode• v : start Visual mode per character.• V : start Visual mode linewise.• Ctrl-v : start Visual mode blockwise.
  • 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. 2.Syntax Highlight Support
  • 94. /opt/local/share/vim/vim72$ ls -1 syntax/ | wc -l 520
  • 95. Syntax
  • 96. ~/.vim/syntax/[filetype].vim
  • 97. ~/.vim/syntax/[filetype].vimsyn match [id] [re] [options]
  • 98. ~/.vim/syntax/[filetype].vimsyn match [id] [re] [options]syn region [id] start=[re] end=[re]
  • 99. ~/.vim/syntax/[filetype].vimsyn match [id] [re] [options]syn region [id] start=[re] end=[re]syn keyword [id] [keyword] ...
  • 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. :help syntax.txt
  • 102. 3. ENCODING
  • 103. :set fencs=utf-8,gbk,big5,euc-jp,utf-16le:set fenc=utf-8 enc=utf-8 tenc=utf-8
  • 104. :set fencs=utf-8,gbk,big5,euc-jp,utf-16le:set fenc=utf-8 enc=utf-8 tenc=utf-8
  • 105. Vim:set fencs=utf-8,gbk,big5,euc-jp,utf-16le:set fenc=utf-8 enc=utf-8 tenc=utf-8
  • 106. :set fencs=utf-8,gbk,big5,euc-jp,utf-16le:set fenc=utf-8 enc=utf-8 tenc=utf-8
  • 107. :set fencs=utf-8,gbk,big5,euc-jp,utf-16le:set fenc=utf-8 enc=utf-8 tenc=utf-8
  • 108. :set fencs=utf-8,gbk,big5,euc-jp,utf-16le:set fenc=utf-8 enc=utf-8 tenc=utf-8 Terminal
  • 109. :help encoding
  • 110. 4. Key Mapping
  • 111. :map:nmap:vmap:imap:smap:xmap... more
  • 112. :map (all):nmap (normal mode):vmap (visual mode):imap (insert mode):smap (select mode):xmap (visual , select mode)... more
  • 113. :map (all):nmap (normal mode):vmap (visual mode):imap (insert mode):smap (select mode):xmap (visual , select mode)... more
  • 114. :nmap <C-c><C-c> :!gcc -Wall % -o %:r.out<CR> Ctrl C Ctrl C GCC .out
  • 115. Normal Mode Tab Shift-Tab nmap <tab> v> nmap <s-tab> v< vmap <tab> >gv vmap <s-tab> <gv
  • 116. nmap <tab> v> nmap <s-tab> v< vmap <tab> >gv vmap <s-tab> <gvVisual/Select Mode Tab Shift-Tab
  • 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. imap <F2> <C-R>=strftime("%c")<CR> Insert Mode F2
  • 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. :h map.txt
  • 121. 5. TEXT OBJECT
  • 122. Text Object• word• string ⇛ action• paragraph (yank,delete,change ...etc)• block
  • 123. Operator Mappingv|c|d i|a { | [ | ( |“ |‘ visual Region change Inner Object {} delete An Object [] () ““Operator ‘‘
  • 124. va{
  • 125. function ( blah , blah ) ci( function ( ) function ( new_args )
  • 126. “Hello World” di” “”“Hello New World”
  • 127. 6. TAB PAPGES
  • 128. :tabnew
  • 129. :tabnew:tabedit path/to/file
  • 130. :tabnew:tabedit path/to/file:tabfind path/to/file
  • 131. :help tabpage.txt
  • 132. 7. FOLDS
  • 133. FOLD IS
  • 134. Fold Methods
  • 135. Fold Methods Syntax Fold
  • 136. Fold Methods Syntax Fold :set foldmethod=syntax $VIMRUNTIME/syntax/*.vim
  • 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. Fold Methods Syntax Fold Marker Fold
  • 139. Fold Methods Syntax Fold Marker Fold :set foldmethod=marker “{{{“ “}}}”
  • 140. # fold this {{{function do_something { echo “COSCUP”;}# }}}
  • 141. Fold Methods Syntax Fold Marker Fold Indent Fold
  • 142. Fold Methods Syntax Fold Marker Fold Indent Fold :set foldmethod=indent
  • 143. Fold Methods Syntax Fold Marker Fold Indent Fold Manual Fold
  • 144. :set foldmethod=manual zf
  • 145. autocmd BufWinLeave *.* silent mkviewautocmd BufWinEnter *.* silent loadview autocmd mkview , loadview ~/.vim/view/
  • 146. Fold Methods Syntax Fold Marker Fold Indent Fold Manual Fold Expr Fold (Custom Fold Function)
  • 147. :set foldexpr=MyFoldLevel(v:lnum)
  • 148. Fold Methods Syntax Fold Marker Fold Indent Fold Manual Fold Expr Fold (Custom Fold Function) Diff Fold
  • 149. 8.Modeline & FileType
  • 150. ModeLine
  • 151. " vim:fdm=marker:sw=2:ts=2:et:fdl=0:"============================" Author: Cornelius <cornelius.howl{at}gmail{dot}com >
  • 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. FileType
  • 154. ~/.vim/ftplugin/ruby.vim vimrc
  • 155. ~/.vim/filetype.vim filetype.vim
  • 156. 9.FORMATTING
  • 157. :set equalprg=perltidy
  • 158. :set equalprg=perltidy “=” perltidy
  • 159. autocmd Filetype perl :set equalprg=perltidy autocmd equalprg
  • 160. autocmd Filetype c :set equalprg=indent C GNU Ident
  • 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. 10. QuickFix
  • 163. :grep & :make
  • 164. :grep [pattern] [filepath]
  • 165. :grep [pattern] [filepath] grepprg ( vimgrep) grep QuickFix
  • 166. QuickFix Window
  • 167. :set grepprg=/path/to/grep grepprg ( VIM grep)
  • 168. :make
  • 169. :make makeprg ( make)Makefile. compiler output parser
  • 170. :set makeprg=gmake makeprg ( make)
  • 171. Result ⇛ QuickFix Window
  • 172. :copenQuickFix Window
  • 173. :ccloseQuickFix Window
  • 174. :cnext Result
  • 175. :cprevious Result
  • 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. 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. 11. Plugin
  • 179. SnipMate TextMate
  • 180. snippet cla class .. initialize .. end class ${1:`substitute(Filename(), ^., u&, )`} def initialize(${2:args}) ${3} end end
  • 181. DBExt.vimOracle, Sybase, MSSQL , MySQL, DBI
  • 182. xml.vimXML
  • 183. FuzzyFinder.vim Fuzzy/Partial pattern explorer
  • 184. The_NERD_TREE.vim
  • 185. The NERD Commenter
  • 186. taglist.vim ctagsmacro , function , variable
  • 187. cscopeC
  • 188. autocomplpop.vim
  • 189. MRUmost recently used
  • 190. bufexplorer.vim Buffer Explorer
  • 191. Rails.vim
  • 192. git-vim
  • 193. !
  • 194. !
  • 195. Vimana Vim script Manager
  • 196. • Vimball• Archive File ( zip , rar )• .vim file
  • 197. POWERED BYPerl
  • 198. CPAN Vimana $ cpan Vimana
  • 199. $ vimana search xml
  • 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. script$ vimana info xml.vim
  • 202. xml.vim$ vimana install xml.vim
  • 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. Git Repositoryhttp://github.com/c9s/Vimana/tree/master
  • 205. ENJOY
  • 206. Thank You
  • 207. Demo ....
  • 208. Q &A

×