Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
VIM Hacks
        Why Vim
  Vim
                  c9s / Cornelius

                   AIINK.com
It doesn’t matter
It does matter
...
Microsoft
Visual Studio
Eclipse
Code Block
Notepad++
....
....
•
•
•   IDE , Editor
•
•   IDE , Editor
•     XXX Editor ..
•
•          IDE , Editor
•            XXX Editor ..
•   ....
Microsoft
Windows      ...
GEdit
Emacs
TextMate
VIM
#!/usr/bin/env perl
my $hppiness = COS::CUP();
#!/usr/bin/env perl
my $hppiness = COS::CUP();

     Oops!
         “a”
#!/usr/bin/env perl
my $hppiness = COS::CUP();
                             xN
#!/usr/bin/env perl
my $hppiness = COS::CUP();
                             xN
#!/usr/bin/env perl
my $hppiness = COS::CUP();
                         xN
#!/usr/bin/env perl
my $hppiness = COS::CUP();
                        xN
#!/usr/bin/env perl
my $hppiness = COS::CUP();
                      xN
#!/usr/bin/env perl
my $hppiness = COS::CUP();
                     xN
#!/usr/bin/env perl
my $hppiness = COS::CUP();
                    xN
#!/usr/bin/env perl
my $hppiness = COS::CUP();
                  xN
#!/usr/bin/env perl
my $hppiness = COS::CUP();
                 xN
#!/usr/bin/env perl
my $hppiness = COS::CUP();
               xN
#!/usr/bin/env perl
my $hppiness = COS::CUP();
            xN
#!/usr/bin/env perl
my $hppiness = COS::CUP();
        xN
#!/usr/bin/env perl
my $hppiness = COS::CUP();
      xN
#!/usr/bin/env perl
my $hppiness = COS::CUP();
#!/usr/bin/env perl
my $happiness = COS::CUP();
#!/usr/bin/env perl
my $happiness = COS::CUP();
                              ?
#!/usr/bin/env perl
my $happiness = COS::CUP();
                              ?
The VIM way...
VIM:
#!/usr/bin/env perl
my $hppiness = COS::CUP();
                        F    h
VIM:
#!/usr/bin/env perl
my $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
INSERT
NORMAL
 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 fun...
# comments ...

foreach my $foo ( @bar ) {

    #                         [{

   my @outs = grep /pattern/ , @list;
	 	
}
...
# comments ...

foreach my $foo ( @bar ) {

    #

   my @outs = grep /pattern/ , @list;
	 	
}                            ...
# comments ...

foreach my $foo ( @bar ) {

    #

   my @outs = grep /pattern/ , @list;
	 	
}                            ...
# comments ...

foreach my $foo ( @bar ) {

    #

   my @outs = grep /pattern/ , @list;
	 	
}      ^

sub func1 {



}
# comments ...
    H
foreach 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
                         ...
# 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 te...
Insert Mode

• i : Insert text before the cursor
• I : Insert text before the first non-blank in the
  line
• a : Append te...
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 blockwi...
Visual Mode

• v : start Visual mode per character.
• V : start Visual mode linewise.
• Ctrl-v : start Visual mode blockwi...
2.
Syntax Highlight Support
/opt/local/share/vim/vim72
$ ls -1 syntax/ | wc -l
   520
Syntax
~/.vim/syntax/[filetype].vim
~/.vim/syntax/[filetype].vim

syn match [id] [re] [options]
~/.vim/syntax/[filetype].vim

syn match [id] [re] [options]
syn region [id] start=[re] end=[re]
~/.vim/syntax/[filetype].vim

syn match [id] [re] [options]
syn region [id] start=[re] end=[re]
syn keyword [id] [keyword]...
~/.vim/syntax/[filetype].vim

syn 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)

...
:map       (all)

:nmap      (normal mode)

:vmap      (visual mode)

:imap      (insert mode)

:smap      (select mode)

...
: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   ...
nmap        <tab>   v>
         nmap        <s-tab> v<

         vmap        <tab>   >gv
         vmap        <s-tab> <gv
...
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>        ...
:h map.txt
5.
 TEXT OBJECT
Text Object

• word
• string      ⇛             action
• paragraph       (yank,delete,change ...etc)

• block
Operator Mapping

v|c|d       i|a            { | [ | ( |“ |‘

   visual                         Region
  change    Inner O...
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.vim


if exists("perl_want_scope_in_variables")
“ .....
if ...
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 mkview
autocmd   BufWinEnter *.*          silent loadview

                autoc...
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 = ...
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
:copen

QuickFix Window
:cclose

QuickFix Window
:cnext

   Result
:cprevious

     Result
QuickFix Window Toggle
com! -bang -nargs=? QFix cal QFixToggle(<bang>0)
fu! QFixToggle(forced)
   if exists("g:qfix_win") ...
QuickFix Window Toggle
com! -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:...
DBExt.vim
Oracle, Sybase, MSSQL ,
  MySQL, DBI
xml.vim
XML
FuzzyFinder.vim
 Fuzzy/Partial pattern explorer
The_NERD_TREE.vim
The NERD Commenter
taglist.vim
     ctags
macro , function , variable
cscope
C
autocomplpop.vim
MRU
most recently used
bufexplorer.vim
    Buffer Explorer
Rails.vim
git-vim
!
!
Vimana
  Vim script Manager
• Vimball
• Archive File ( zip , rar )
• .vim file
POWERED BY



Perl
CPAN   Vimana


 $ cpan Vimana
$ vimana search xml
$ vimana search xml
rrd.vim             - Edit RRD data with Vim.
qt.vim              - tiny tool for the uic used in Qt f...
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   ta...
Git Repository
http://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
You’ve finished this document.
Download and read it offline.
Upcoming SlideShare
Perl.Hacks.On.Vim
Next
Upcoming SlideShare
Perl.Hacks.On.Vim
Next
Download to read offline and view in fullscreen.

Share

Vim Hacks

Download to read offline

Vim Hacks @ COSCUP

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Vim Hacks

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

    Jul. 20, 2021
  • LeonLiu56

    Jun. 10, 2019
  • chhuang0123

    May. 29, 2019
  • kochichuang

    May. 29, 2019
  • allanbian

    May. 29, 2019
  • leo424y

    Sep. 18, 2018
  • ReioHuang

    Aug. 20, 2018
  • bingbing12

    Aug. 2, 2018
  • shiying_2012

    Sep. 29, 2017
  • linc2

    Apr. 16, 2017
  • JhihMing

    Mar. 28, 2017
  • ssusere4c7e1

    Mar. 13, 2017
  • EricYang116

    Dec. 24, 2016
  • AminadavGlickshtein

    Dec. 23, 2016
  • dtbsky

    Nov. 18, 2016
  • shihweihuang39

    Oct. 30, 2016
  • ssusere868ea

    Oct. 25, 2016
  • NikolaDimitrov6

    Oct. 15, 2016
  • itsuifeng

    Sep. 7, 2016
  • excusemejoe

    Aug. 24, 2016

Vim Hacks @ COSCUP

Views

Total views

117,408

On Slideshare

0

From embeds

0

Number of embeds

14,386

Actions

Downloads

2,309

Shares

0

Comments

0

Likes

328

×