SlideShare une entreprise Scribd logo
1  sur  70
Télécharger pour lire hors ligne
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

Contenu connexe

Similaire à 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
 

Similaire à 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
 

Dernier

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 

Dernier (20)

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

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.