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
Upcoming SlideShare
Loading in...5
×

Vim Hacks

51,942

Published on

Vim Hacks @ COSCUP

Published in: Technology
22 Comments
289 Likes
Statistics
Notes
No Downloads
Views
Total Views
51,942
On Slideshare
0
From Embeds
0
Number of Embeds
57
Actions
Shares
0
Downloads
2,125
Comments
22
Likes
289
Embeds 0
No embeds

No notes for slide

Transcript of "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. Microsoft Visual 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. Microsoft Windows ...
  16. 16. GEdit
  17. 17. Emacs
  18. 18. TextMate
  19. 19. VIM
  20. 20. #!/usr/bin/env perl my $hppiness = COS::CUP();
  21. 21. #!/usr/bin/env perl my $hppiness = COS::CUP(); Oops! “a”
  22. 22. #!/usr/bin/env perl my $hppiness = COS::CUP(); xN
  23. 23. #!/usr/bin/env perl my $hppiness = COS::CUP(); xN
  24. 24. #!/usr/bin/env perl my $hppiness = COS::CUP(); xN
  25. 25. #!/usr/bin/env perl my $hppiness = COS::CUP(); xN
  26. 26. #!/usr/bin/env perl my $hppiness = COS::CUP(); xN
  27. 27. #!/usr/bin/env perl my $hppiness = COS::CUP(); xN
  28. 28. #!/usr/bin/env perl my $hppiness = COS::CUP(); xN
  29. 29. #!/usr/bin/env perl my $hppiness = COS::CUP(); xN
  30. 30. #!/usr/bin/env perl my $hppiness = COS::CUP(); xN
  31. 31. #!/usr/bin/env perl my $hppiness = COS::CUP(); xN
  32. 32. #!/usr/bin/env perl my $hppiness = COS::CUP(); xN
  33. 33. #!/usr/bin/env perl my $hppiness = COS::CUP(); xN
  34. 34. #!/usr/bin/env perl my $hppiness = COS::CUP(); xN
  35. 35. #!/usr/bin/env perl my $hppiness = COS::CUP();
  36. 36. #!/usr/bin/env perl my $happiness = COS::CUP();
  37. 37. #!/usr/bin/env perl my $happiness = COS::CUP(); ?
  38. 38. #!/usr/bin/env perl my $happiness = COS::CUP(); ?
  39. 39. The VIM way...
  40. 40. VIM: #!/usr/bin/env perl my $hppiness = COS::CUP(); F h
  41. 41. VIM: #!/usr/bin/env perl my $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. INSERT NORMAL 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 ... H foreach 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 mode sub 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].vim syn match [id] [re] [options]
  98. 98. ~/.vim/syntax/[filetype].vim syn match [id] [re] [options] syn region [id] start=[re] end=[re]
  99. 99. ~/.vim/syntax/[filetype].vim syn match [id] [re] [options] syn region [id] start=[re] end=[re] syn keyword [id] [keyword] ...
  100. 100. ~/.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]
  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> <gv Visual/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 Mapping v|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.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
  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 mkview autocmd 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. :copen QuickFix Window
  173. 173. :cclose QuickFix Window
  174. 174. :cnext Result
  175. 175. :cprevious Result
  176. 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>
  177. 177. 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> “”
  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.vim Oracle, Sybase, MSSQL , MySQL, DBI
  182. 182. xml.vim XML
  183. 183. FuzzyFinder.vim Fuzzy/Partial pattern explorer
  184. 184. The_NERD_TREE.vim
  185. 185. The NERD Commenter
  186. 186. taglist.vim ctags macro , function , variable
  187. 187. cscope C
  188. 188. autocomplpop.vim
  189. 189. MRU most 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 BY Perl
  198. 198. CPAN Vimana $ cpan Vimana
  199. 199. $ vimana search xml
  200. 200. $ 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
  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.vim etc ... ALL Works
  204. 204. Git Repository http://github.com/c9s/Vimana/tree/master
  205. 205. ENJOY
  206. 206. Thank You
  207. 207. Demo ....
  208. 208. Q &A
  1. ¿Le ha llamado la atención una diapositiva en particular?

    Recortar diapositivas es una manera útil de recopilar información importante para consultarla más tarde.

×