SlideShare uma empresa Scribd logo
1 de 70
Baixar para ler offline
Effective Text Editing
With Vim
by Kentwang
Effective text editing


“Seven habits of effective
text editing”

  - Bram Moolenaar
Problem
Got lots of text to edit
-   source code
-   config file
-   log
-   etc.
Problem
Got lots of text to edit
-   source code
                                                e!
-   config file
                                         gh
                                            tim
                                       ou
-   log
                              have
                                     en
                           ’t
-   etc.
                  Bu
                       td
                         on
Tool


• Selecting a good editor is the first step
  towards effective text editing
• Obviously, Vim is used here
What is vim
Comments
Lots of people said like this
...
TMD
But, some in other way
Why
Different view
Different view
Different view
Vim is a tool, the use of
which must be learned
How to improve
Basic steps

1. Detect inefficiency
2. Find a quicker way
3. Make it a habit
Habit 1:
Moving around quickly
Feature
Feature


  VS
Feature


         VS


Who moved my mouse !
Detect ineffeciency
• Depend on mouse
• Use direction keys
• One line/column each time
• Hard to find match things
Find a quicker way
• Edit without mouse
• Use ‘h j k l’ instead of direction keys
• Move multi-line each time
• Use ‘%’ to find match things
Find a quicker way
• Edit without mouse
• Use ‘h j k l’ instead of direction keys
• Move multi-line each time
• Use ‘%’ to find match things
 Samples:
       20G   jump   to   line 20
       ^     jump   to   first non blank of line
       $     jump   to   end of line
       %     jump   to   match ( #if #endif etc.)
       10j   jump   to   10 lines below
       5w    jump   to   5 words after
Detect ineffeciency

• Typical you search like this
Detect ineffeciency

• Typical you search like this
  /FuncName
Detect ineffeciency

• Typical you search like this
  /FuncName
  n
  n
  n
  n
  ...
Find a quicker way

• The hlsearch option
• The * command
• Folding with ‘zf’ , ‘zo’ and ‘zc’
Make it a habit

• Put this in your vimrc file
     set hlsearch

• Use * again and again
• Use command completion (using <tab>)
• Use fold when needed
Habit 2:
Don’t type it twice
Detect ineffeciency

• Long class names
 - TiXmlAttributeSet
• Long function names
 - QueryDoubleAttribute
• Hard to type and often type it wrong
• Lots of time on indenting and code style
Find a quicker way

• Insert mode completion
• Ctrl - N & Ctrl -P
• Omni-completion
• Automatic indenting
Find a quicker way
Make it a habit

• Use Ctrl + P and Ctrl + N again and again
• Use omni-completion if needed
• Add these lines in vimrc:
  filetype plugin on
  filetype indent on
  “ auto indent
  set ai
  set smarttab
Habit 3:
Fix it when it’s wrong
Detect ineffeciency

• Often misspell English words
• Have to check text carefully
• Need a sequence of actions to correct tem
• After correct you misspell again and again
Find a quicker way

• Spell correction macros
  :iabbrev accnt account
  :syntax keyword WordError accnt
Make it a habit
• Add new words if you see them
Habit 4:
A file seldom comes
       alone
Detect ineffeciency

• When working on a new project you have a
  hard time finding your way in the files
• You have to jump between files all the time
• Edit in an editor but compile in terminal
• Hard to find declaration of symbol
A quicker way


• Find & grep
• ctags & taglist
• Quickfix
Many other ways


• use ‘gf’ to goto header file
• Use ‘[I’ to find the word under the cursor
  in include files. Or ‘[<Tab>’ to jump there
• Use a.vim to switch between .c and .h
Make it a habit

• Use quickfix as often as possible
• Drop ‘a.vim’ to your plugin directory
• Remember to use ‘ctags’ and ‘taglist’
Habit 5:
Let’s work together
Detect ineffeciency
• Often need to compare files
• Switch out of terminal and use windows
  compare tools
• Sometimes have to transfer file from IDC
  server to local first, just because can’t use
  windows compare tools there and diff
  command is not so readable
A quicker way

• vimdiff or vim -d
• Works well in both terminal and GUI
• Pretty result and convenient interactive
• Use ‘[c’ ‘]c’ to jump to changes, ‘do’ ‘dg’ to
  copy text from one to another
A quicker way
More Effective

• Integrate with SVN
• SVN_EDITOR environment variable
• Set vim as diff program for svn diff
Make it a habit
• Use vimdiff instead of windows compare
  tools
• Add this line to your bashrc:
     export SVN_EDITOR=vim

• Edit ~/.subversion/config, set vim as the
  diff-cmd
• If you are a big fan, try Vimperator / Vimium
Habit 6:
Sharpen the saw
Sharpen the saw

• Keep on tuning the set of commands you
  use for your needs
• Learn from what you did
• Type :help command when you need help
Sharpen the saw

• Replacing
• automatic indenting
• quickfix
• plugins
• key-mapping
Replacing

• Replace a word
• Use < and > to match the start/end of
  word


   Samples:
     10, 20s/Old/New/g
     %s/Old/New/g
     %s/<Old/New/g
     %s/<Old>/New/g
Replacing

• Replacing in several files
• Record / Execute register
Sample:
  vim *.cpp                    // start vim
  qq                           // start recording into the q register
  :%s/<OldFunc>/NewFunc/ge   // replacing
  :wnext                       // write and goto next file
  q                            // stop recording
  @q                           // execute
Encoding

• fileencoding
• encoding
• LC_CTYPE
Summary
•   Step 1: Detect inefficiency
    -   Find out what you waste time on
•   Step 2: Find a quicker way
    -   read the online help & quick reference
    -   ask friends & google
    -   do it yourself
•   Step 3: Make it a habit
    -   do it
    -   keep on improving
How NOT to effectively

• No time to read documents or new
  commands. keep on using primitive
  commands.
• Want to learn every feature and use the
  most efficient command all the time.
How NOT to effectively

• No time to read documents or new
  commands. keep on using primitive
  commands.
• Want to learn every feature and use the
  most efficient command all the time.
Learn it, time rewarded.
One more thing
:help user-manual
Questions?
The End

Mais conteúdo relacionado

Semelhante a Effective text editing with vim

2CPP11 - Method Overloading
2CPP11 - Method Overloading2CPP11 - Method Overloading
2CPP11 - Method OverloadingMichael Heron
 
How to become a practical Vim user
How to become a practical Vim userHow to become a practical Vim user
How to become a practical Vim userKana Natsuno
 
Habits 2007
Habits 2007Habits 2007
Habits 2007Dang Tan
 
Gearman: A Job Server made for Scale
Gearman: A Job Server made for ScaleGearman: A Job Server made for Scale
Gearman: A Job Server made for ScaleMike Willbanks
 
Austin Python Learners Meetup - Everything you need to know about programming...
Austin Python Learners Meetup - Everything you need to know about programming...Austin Python Learners Meetup - Everything you need to know about programming...
Austin Python Learners Meetup - Everything you need to know about programming...Danny Mulligan
 
Maintainability of Configuration Management Code
Maintainability of Configuration Management CodeMaintainability of Configuration Management Code
Maintainability of Configuration Management CodeClinton Wolfe
 
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...Mozaic Works
 
Pipeline 101 Lorelei Mccollum
Pipeline 101 Lorelei MccollumPipeline 101 Lorelei Mccollum
Pipeline 101 Lorelei MccollumLorelei McCollum
 
Finding Needles in Haystacks
Finding Needles in HaystacksFinding Needles in Haystacks
Finding Needles in Haystackssnyff
 
Cooking a rabbit pie
Cooking a rabbit pieCooking a rabbit pie
Cooking a rabbit pieTomas Doran
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesInductive Automation
 
Introducing Pair Programming
Introducing Pair ProgrammingIntroducing Pair Programming
Introducing Pair ProgrammingSteven Smith
 
Lotuscript for large systems
Lotuscript for large systemsLotuscript for large systems
Lotuscript for large systemsBill Buchan
 

Semelhante a Effective text editing with vim (20)

Tweakers Anonymous
Tweakers AnonymousTweakers Anonymous
Tweakers Anonymous
 
Vim survival guide
Vim survival guideVim survival guide
Vim survival guide
 
2CPP11 - Method Overloading
2CPP11 - Method Overloading2CPP11 - Method Overloading
2CPP11 - Method Overloading
 
Tweakers Anonymous
Tweakers AnonymousTweakers Anonymous
Tweakers Anonymous
 
Lecture 24
Lecture 24Lecture 24
Lecture 24
 
How to become a practical Vim user
How to become a practical Vim userHow to become a practical Vim user
How to become a practical Vim user
 
Habits 2007
Habits 2007Habits 2007
Habits 2007
 
Gearman: A Job Server made for Scale
Gearman: A Job Server made for ScaleGearman: A Job Server made for Scale
Gearman: A Job Server made for Scale
 
Go fundamentals
Go fundamentalsGo fundamentals
Go fundamentals
 
ACM Init() lesson 1
ACM Init() lesson 1ACM Init() lesson 1
ACM Init() lesson 1
 
Bug Hunting Safari
Bug Hunting SafariBug Hunting Safari
Bug Hunting Safari
 
Austin Python Learners Meetup - Everything you need to know about programming...
Austin Python Learners Meetup - Everything you need to know about programming...Austin Python Learners Meetup - Everything you need to know about programming...
Austin Python Learners Meetup - Everything you need to know about programming...
 
Maintainability of Configuration Management Code
Maintainability of Configuration Management CodeMaintainability of Configuration Management Code
Maintainability of Configuration Management Code
 
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...
 
Pipeline 101 Lorelei Mccollum
Pipeline 101 Lorelei MccollumPipeline 101 Lorelei Mccollum
Pipeline 101 Lorelei Mccollum
 
Finding Needles in Haystacks
Finding Needles in HaystacksFinding Needles in Haystacks
Finding Needles in Haystacks
 
Cooking a rabbit pie
Cooking a rabbit pieCooking a rabbit pie
Cooking a rabbit pie
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
Introducing Pair Programming
Introducing Pair ProgrammingIntroducing Pair Programming
Introducing Pair Programming
 
Lotuscript for large systems
Lotuscript for large systemsLotuscript for large systems
Lotuscript for large systems
 

Último

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 

Último (20)

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 

Effective text editing with vim

  • 1. Effective Text Editing With Vim by Kentwang
  • 2. Effective text editing “Seven habits of effective text editing” - Bram Moolenaar
  • 3. Problem Got lots of text to edit - source code - config file - log - etc.
  • 4. Problem Got lots of text to edit - source code e! - config file gh tim ou - log have en ’t - etc. Bu td on
  • 5. Tool • Selecting a good editor is the first step towards effective text editing • Obviously, Vim is used here
  • 8. Lots of people said like this
  • 9.
  • 10.
  • 11. ...
  • 12.
  • 13. TMD
  • 14. But, some in other way
  • 15.
  • 16.
  • 17.
  • 18. Why
  • 22. Vim is a tool, the use of which must be learned
  • 24. Basic steps 1. Detect inefficiency 2. Find a quicker way 3. Make it a habit
  • 28. Feature VS Who moved my mouse !
  • 29. Detect ineffeciency • Depend on mouse • Use direction keys • One line/column each time • Hard to find match things
  • 30. Find a quicker way • Edit without mouse • Use ‘h j k l’ instead of direction keys • Move multi-line each time • Use ‘%’ to find match things
  • 31. Find a quicker way • Edit without mouse • Use ‘h j k l’ instead of direction keys • Move multi-line each time • Use ‘%’ to find match things Samples: 20G jump to line 20 ^ jump to first non blank of line $ jump to end of line % jump to match ( #if #endif etc.) 10j jump to 10 lines below 5w jump to 5 words after
  • 32. Detect ineffeciency • Typical you search like this
  • 33. Detect ineffeciency • Typical you search like this /FuncName
  • 34. Detect ineffeciency • Typical you search like this /FuncName n n n n ...
  • 35. Find a quicker way • The hlsearch option • The * command • Folding with ‘zf’ , ‘zo’ and ‘zc’
  • 36. Make it a habit • Put this in your vimrc file set hlsearch • Use * again and again • Use command completion (using <tab>) • Use fold when needed
  • 38. Detect ineffeciency • Long class names - TiXmlAttributeSet • Long function names - QueryDoubleAttribute • Hard to type and often type it wrong • Lots of time on indenting and code style
  • 39. Find a quicker way • Insert mode completion • Ctrl - N & Ctrl -P • Omni-completion • Automatic indenting
  • 41. Make it a habit • Use Ctrl + P and Ctrl + N again and again • Use omni-completion if needed • Add these lines in vimrc: filetype plugin on filetype indent on “ auto indent set ai set smarttab
  • 42. Habit 3: Fix it when it’s wrong
  • 43. Detect ineffeciency • Often misspell English words • Have to check text carefully • Need a sequence of actions to correct tem • After correct you misspell again and again
  • 44. Find a quicker way • Spell correction macros :iabbrev accnt account :syntax keyword WordError accnt
  • 45. Make it a habit • Add new words if you see them
  • 46. Habit 4: A file seldom comes alone
  • 47. Detect ineffeciency • When working on a new project you have a hard time finding your way in the files • You have to jump between files all the time • Edit in an editor but compile in terminal • Hard to find declaration of symbol
  • 48. A quicker way • Find & grep • ctags & taglist • Quickfix
  • 49. Many other ways • use ‘gf’ to goto header file • Use ‘[I’ to find the word under the cursor in include files. Or ‘[<Tab>’ to jump there • Use a.vim to switch between .c and .h
  • 50. Make it a habit • Use quickfix as often as possible • Drop ‘a.vim’ to your plugin directory • Remember to use ‘ctags’ and ‘taglist’
  • 52. Detect ineffeciency • Often need to compare files • Switch out of terminal and use windows compare tools • Sometimes have to transfer file from IDC server to local first, just because can’t use windows compare tools there and diff command is not so readable
  • 53. A quicker way • vimdiff or vim -d • Works well in both terminal and GUI • Pretty result and convenient interactive • Use ‘[c’ ‘]c’ to jump to changes, ‘do’ ‘dg’ to copy text from one to another
  • 55. More Effective • Integrate with SVN • SVN_EDITOR environment variable • Set vim as diff program for svn diff
  • 56. Make it a habit • Use vimdiff instead of windows compare tools • Add this line to your bashrc: export SVN_EDITOR=vim • Edit ~/.subversion/config, set vim as the diff-cmd • If you are a big fan, try Vimperator / Vimium
  • 58. Sharpen the saw • Keep on tuning the set of commands you use for your needs • Learn from what you did • Type :help command when you need help
  • 59. Sharpen the saw • Replacing • automatic indenting • quickfix • plugins • key-mapping
  • 60. Replacing • Replace a word • Use < and > to match the start/end of word Samples: 10, 20s/Old/New/g %s/Old/New/g %s/<Old/New/g %s/<Old>/New/g
  • 61. Replacing • Replacing in several files • Record / Execute register Sample: vim *.cpp // start vim qq // start recording into the q register :%s/<OldFunc>/NewFunc/ge // replacing :wnext // write and goto next file q // stop recording @q // execute
  • 63. Summary • Step 1: Detect inefficiency - Find out what you waste time on • Step 2: Find a quicker way - read the online help & quick reference - ask friends & google - do it yourself • Step 3: Make it a habit - do it - keep on improving
  • 64. How NOT to effectively • No time to read documents or new commands. keep on using primitive commands. • Want to learn every feature and use the most efficient command all the time.
  • 65. How NOT to effectively • No time to read documents or new commands. keep on using primitive commands. • Want to learn every feature and use the most efficient command all the time.
  • 66. Learn it, time rewarded.