SlideShare a Scribd company logo
1 of 24
冒
2011/10/14




             顿
小调查
• Vim 用户数?



• Vim 龄?
    3 个月+

• 知识面
   10 个技巧、30 个技巧+、通读 Vim doc.
简介
• 我的故事(三遇始识君)
• 编辑模式
• 编码设置
:h tutor
大纲
•   光标移动 (motion)
•   命令 (:command)
•   搜索&替换 (find, subst)
•   量词 [count]
•   文本对象 (text-object)
•   寄存器 (register)
•   标记 (mark)
•   列模式
•   配置 (vimrc)
•   插件 (plugin)
光标移动
•   j k h l
•   w b e
•   0 ^ $
•   H M L
•   gg G 50%
•   :50
•   %
•   <C-f> <C-b> <C-e> <C-y>
•   <C-o> <Tab>
•   gj gk gf gd :h g
•   :help motion.txt
助记



a ppend        h         o          u ndo
b efore        i nsert   p aste     v isual
c hange   cc   j         q          w ord
d elete   dd   k
e nd           l         r eplace   x
f ind          m ark     s trike    y ank     yy
g oto     gg   n ext     t ill      z en      zz   ZZ



                                              [[   ]]
助记



A ppend   H igh     O          U
B efore   I nsert   P aste     V isual
C hange   J oin     Q          W ord
D elete   K ey
E nd      L ow      R eplace   X
F ind     M id      S trike    Y ank     yy
G oto     N ext     T ill      Z en      zz   ZZ



                                         (    )
                                         {    }
助记
    Mode         Motion                 Search
a ppend      b efore                f ind
i nsert      e nd                   t ill
o            g oto                  *       /
r eplace     h                      #       ?
v isual      j
                                        Buffer
Esc          k
                                    p aste
             l
      Edit                          y ank
             n ext
c hange
             w ord
d elete
                                        Others
s trike      0            ,    ;
                                    m ark
u ndo        ^            (    )
             %            [[   ]]   q
x
                          {         z en
             $                 }
                                    .
键盘映射
• == gg=G
• >> >G 2<<
• zc zo
• 自定义键盘映射
  ,cc <F3> ( <C-t> <M-1>
• :h map.txt
量词
•   5j 3w 2dd 3cw 2fa
•   10>> 8== 4Y 4yp
•   50% 100gg 100G
•   :h count
命令
•   :h :help
•   :wq
•   :qa!
•   :bro w [file.name]
•   :new :vnew :tabnew
•   自定义命令
    – :Cal :MRU :Uisvr css
• :h command
搜索&替换
• / ? n N
    – 支持正则表达式
    – :set hls :noh
•   * #
•   f F t T ; ,
•   :%s/key/word/g
•   :%s/key//n
•   :vimgrep /key/
•   :h pattern.txt
文本对象
• inner object
  – viw ci” di(
• an object
  – yaw cat dap
• :h text-object
寄存器
• “add “bY “ap “bp

•   无名寄存器 “”
•   命名寄存器 a-z
•   编号寄存器 0-9
•   黑洞寄存器 _
•   系统剪贴板 + :set clipboard+=unnamed
•   :h registers
标记
•   ma mb
•   ‘a ‘b
•   `a `b
•   :h mark
列模式
• <C-v> (for *inx)
• <C-q> (for Windows)
• :h ctrl-v
配置参考
•   https://github.com/vingel/vim
•   https://github.com/janlay/vim
•   https://github.com/cnruhua/macvimfiles
•   https://bitbucket.org/leeiio/vim
•   https://github.com/lilydjwg/dotvim
•   https://github.com/hotoo/vimrc
插件
• https://github.com/msanders/snipmate.vim
• https://github.com/scrooloose/nerdtree
• http://vim-taglist.sourceforge.net/
    – http://www.vim.org/scripts/script.php?script_id=273
• https://github.com/majutsushi/tagbar
    – http://www.vim.org/scripts/script.php?script_id=3465
• https://github.com/vim-scripts/mru.vim
    – http://www.vim.org/scripts/script.php?script_id=521
•   http://code.google.com/p/vimwiki/
•   https://github.com/hotoo/uisvr.vim
•   https://github.com/hotoo/template.vim
•   https://github.com/hotoo/more.vim
尾声
•   宏 :h q
•   持久化撤销 :h undo
•   版本比较 :diff
•   相对行号 :h rnu
•   语法高亮 :h syntax
•   外观皮肤 :h colorscheme
•   代码折叠 :h folds
•   自动缩进 :h indent
•   智能补全 :h omni-completion
•   会话恢复 :h sessions
•   文件自动备份与紧急恢复 :h backup
•   …
小众

More Related Content

Similar to Vim+神技 (1)

Command line 初級寶典
Command line 初級寶典Command line 初級寶典
Command line 初級寶典Tom Chen
 
Vim get start_1.0
Vim get start_1.0Vim get start_1.0
Vim get start_1.0longhao
 
Vim hacks
Vim hacksVim hacks
Vim hacksXuYj
 
Clojure
ClojureClojure
ClojureDi Xu
 
C++11综述/新特性描述/Overview of C++11 New Features
C++11综述/新特性描述/Overview of C++11 New FeaturesC++11综述/新特性描述/Overview of C++11 New Features
C++11综述/新特性描述/Overview of C++11 New FeaturesPeien Luo
 

Similar to Vim+神技 (1) (6)

Command line 初級寶典
Command line 初級寶典Command line 初級寶典
Command line 初級寶典
 
Vim get start_1.0
Vim get start_1.0Vim get start_1.0
Vim get start_1.0
 
Vim hacks
Vim hacksVim hacks
Vim hacks
 
Clojure
ClojureClojure
Clojure
 
C++11综述/新特性描述/Overview of C++11 New Features
C++11综述/新特性描述/Overview of C++11 New FeaturesC++11综述/新特性描述/Overview of C++11 New Features
C++11综述/新特性描述/Overview of C++11 New Features
 
HITCON GIRLS Malware Analysis
HITCON GIRLS Malware AnalysisHITCON GIRLS Malware Analysis
HITCON GIRLS Malware Analysis
 

More from Ailsa126

缴费代码
缴费代码缴费代码
缴费代码Ailsa126
 
Pm角色及前端升级包相关
Pm角色及前端升级包相关Pm角色及前端升级包相关
Pm角色及前端升级包相关Ailsa126
 
Git isthenewsexy
Git isthenewsexyGit isthenewsexy
Git isthenewsexyAilsa126
 
前后端解耦Ppt
前后端解耦Ppt前后端解耦Ppt
前后端解耦PptAilsa126
 
前端优化实践
前端优化实践前端优化实践
前端优化实践Ailsa126
 
浅析浏览器解析和渲染
浅析浏览器解析和渲染浅析浏览器解析和渲染
浅析浏览器解析和渲染Ailsa126
 
谈谈Javascript设计
谈谈Javascript设计谈谈Javascript设计
谈谈Javascript设计Ailsa126
 
Web encoding
Web encodingWeb encoding
Web encodingAilsa126
 

More from Ailsa126 (11)

缴费代码
缴费代码缴费代码
缴费代码
 
讲故事
讲故事讲故事
讲故事
 
Pm角色及前端升级包相关
Pm角色及前端升级包相关Pm角色及前端升级包相关
Pm角色及前端升级包相关
 
Ps分享
Ps分享Ps分享
Ps分享
 
Git isthenewsexy
Git isthenewsexyGit isthenewsexy
Git isthenewsexy
 
前后端解耦Ppt
前后端解耦Ppt前后端解耦Ppt
前后端解耦Ppt
 
Share
ShareShare
Share
 
前端优化实践
前端优化实践前端优化实践
前端优化实践
 
浅析浏览器解析和渲染
浅析浏览器解析和渲染浅析浏览器解析和渲染
浅析浏览器解析和渲染
 
谈谈Javascript设计
谈谈Javascript设计谈谈Javascript设计
谈谈Javascript设计
 
Web encoding
Web encodingWeb encoding
Web encoding
 

Vim+神技 (1)

  • 2. 小调查 • Vim 用户数? • Vim 龄? 3 个月+ • 知识面 10 个技巧、30 个技巧+、通读 Vim doc.
  • 4.
  • 5.
  • 6.
  • 8. 大纲 • 光标移动 (motion) • 命令 (:command) • 搜索&替换 (find, subst) • 量词 [count] • 文本对象 (text-object) • 寄存器 (register) • 标记 (mark) • 列模式 • 配置 (vimrc) • 插件 (plugin)
  • 9. 光标移动 • j k h l • w b e • 0 ^ $ • H M L • gg G 50% • :50 • % • <C-f> <C-b> <C-e> <C-y> • <C-o> <Tab> • gj gk gf gd :h g • :help motion.txt
  • 10. 助记 a ppend h o u ndo b efore i nsert p aste v isual c hange cc j q w ord d elete dd k e nd l r eplace x f ind m ark s trike y ank yy g oto gg n ext t ill z en zz ZZ [[ ]]
  • 11. 助记 A ppend H igh O U B efore I nsert P aste V isual C hange J oin Q W ord D elete K ey E nd L ow R eplace X F ind M id S trike Y ank yy G oto N ext T ill Z en zz ZZ ( ) { }
  • 12. 助记 Mode Motion Search a ppend b efore f ind i nsert e nd t ill o g oto * / r eplace h # ? v isual j Buffer Esc k p aste l Edit y ank n ext c hange w ord d elete Others s trike 0 , ; m ark u ndo ^ ( ) % [[ ]] q x { z en $ } .
  • 13. 键盘映射 • == gg=G • >> >G 2<< • zc zo • 自定义键盘映射 ,cc <F3> ( <C-t> <M-1> • :h map.txt
  • 14. 量词 • 5j 3w 2dd 3cw 2fa • 10>> 8== 4Y 4yp • 50% 100gg 100G • :h count
  • 15. 命令 • :h :help • :wq • :qa! • :bro w [file.name] • :new :vnew :tabnew • 自定义命令 – :Cal :MRU :Uisvr css • :h command
  • 16. 搜索&替换 • / ? n N – 支持正则表达式 – :set hls :noh • * # • f F t T ; , • :%s/key/word/g • :%s/key//n • :vimgrep /key/ • :h pattern.txt
  • 17. 文本对象 • inner object – viw ci” di( • an object – yaw cat dap • :h text-object
  • 18. 寄存器 • “add “bY “ap “bp • 无名寄存器 “” • 命名寄存器 a-z • 编号寄存器 0-9 • 黑洞寄存器 _ • 系统剪贴板 + :set clipboard+=unnamed • :h registers
  • 19. 标记 • ma mb • ‘a ‘b • `a `b • :h mark
  • 20. 列模式 • <C-v> (for *inx) • <C-q> (for Windows) • :h ctrl-v
  • 21. 配置参考 • https://github.com/vingel/vim • https://github.com/janlay/vim • https://github.com/cnruhua/macvimfiles • https://bitbucket.org/leeiio/vim • https://github.com/lilydjwg/dotvim • https://github.com/hotoo/vimrc
  • 22. 插件 • https://github.com/msanders/snipmate.vim • https://github.com/scrooloose/nerdtree • http://vim-taglist.sourceforge.net/ – http://www.vim.org/scripts/script.php?script_id=273 • https://github.com/majutsushi/tagbar – http://www.vim.org/scripts/script.php?script_id=3465 • https://github.com/vim-scripts/mru.vim – http://www.vim.org/scripts/script.php?script_id=521 • http://code.google.com/p/vimwiki/ • https://github.com/hotoo/uisvr.vim • https://github.com/hotoo/template.vim • https://github.com/hotoo/more.vim
  • 23. 尾声 • 宏 :h q • 持久化撤销 :h undo • 版本比较 :diff • 相对行号 :h rnu • 语法高亮 :h syntax • 外观皮肤 :h colorscheme • 代码折叠 :h folds • 自动缩进 :h indent • 智能补全 :h omni-completion • 会话恢复 :h sessions • 文件自动备份与紧急恢复 :h backup • …