SlideShare a Scribd company logo
1 of 25
冒
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                  n ext
r eplace     h                      *       /
v isual      j                      #       ?
Esc          k
                                        Buffer
             l
      Edit                          p aste
             w ord
c hange                             y ank
             0            ,    ;
d elete                                 Others
             ^            (    )
s trike
             %            [[   ]]   m ark
u ndo
             $            {    }    q
x
                                    z en          .
Ctrl-                                 助记



a dd/all    h   o ld caret            u pward
b ackward   i   p             block   v iew
c ancel     j   q                     w indow
d ownward   k
e xtra      l   r edo                 x
f orward    m   s plit/save           y
g           n   t ags back            z
键盘映射
•   .
•   == 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
•   :wqa!
•   :cd
•   :setf html
•   :set fenc=utf8|gbk
•   :set [no]wrap
•   :bro[wser] w [file.name]
•   :new :vnew :tabnew
•   自定义命令
    – :Cal :MRU :Uisvr css
• :h command
搜索&替换
• / ? n N
    – 支持正则表达式 :h magic
    – :set hls :noh
•   * #
•   f F t T ; ,
•   :%s/key/word/g
•   :%s/key//n
•   :vimgrep/key/**/*.c
•   :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

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Vim 神技

  • 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 n ext r eplace h * / v isual j # ? Esc k Buffer l Edit p aste w ord c hange y ank 0 , ; d elete Others ^ ( ) s trike % [[ ]] m ark u ndo $ { } q x z en .
  • 13. Ctrl- 助记 a dd/all h o ld caret u pward b ackward i p block v iew c ancel j q w indow d ownward k e xtra l r edo x f orward m s plit/save y g n t ags back z
  • 14. 键盘映射 • . • == gg=G • >> >G 2<< • zc zo • 自定义键盘映射 ,cc <F3> ( <C-t> <M-1> • :h map.txt
  • 15. 量词 • 5j 3w 2dd 3cw 2fa • 10>> 8== 4Y 4yp • 50% 100gg 100G • :h count
  • 16. 命令 • :h :help • :wqa! • :cd • :setf html • :set fenc=utf8|gbk • :set [no]wrap • :bro[wser] w [file.name] • :new :vnew :tabnew • 自定义命令 – :Cal :MRU :Uisvr css • :h command
  • 17. 搜索&替换 • / ? n N – 支持正则表达式 :h magic – :set hls :noh • * # • f F t T ; , • :%s/key/word/g • :%s/key//n • :vimgrep/key/**/*.c • :h pattern.txt
  • 18. 文本对象 • inner object – viw ci” di( • an object – yaw cat dap • :h text-object
  • 19. 寄存器 • “add “bY “ap “bp • 无名寄存器 “” • 命名寄存器 a-z • 编号寄存器 0-9 • 黑洞寄存器 _ • 共享系统剪贴板 :set clipboard+=unnamed • :h registers
  • 20. 标记 • ma mb • ‘a ‘b • `a `b • :h mark
  • 21. 列模式 • <C-v> (for *inx) • <C-q> (for Windows) • :h ctrl-v
  • 22. 配置参考 • 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
  • 23. 插件 • 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
  • 24. 尾声 • 宏 :h q • 持久化撤销 :h undo • 文件/版本比较 :diff • 相对行号 :h rnu • 语法高亮 :h syntax • 外观皮肤 :h colorscheme • 代码折叠 :h folds • 自动缩进 :h indent • 智能补全 :h omni-completion • 会话恢复 :h sessions • 文件自动备份与紧急恢复 :h backup • …