Home

Seven habits of effective text editing 2.0

image

Contents

1. Seven habits of effective text editing 2 0 Presentation given by Bram Moolenaar at Google 2007 February 13 There will be time to ask questions at the end of the presentation The problem You edit lots of text Program source code documentation Editing text takes a lot of our time Looking at myself I spend more than half my day reading and changing various kinds of text Rest of the time is spent in meetings Perhaps someone can do a seven habits of effective meetings This presentation is about how to get more work done in less time Don t listen when you are paid by the hour The tool Obviously Vim is used here Some people use Notepad and never get past it Those people can learn a lot today You can spend lots of time on evaluating different editors I use two rules e Ifyou are already using an editor and it works very well for you don t waste time by learning to use another one However after this presentation you might wonder if your editor is really good enough e Otherwise use Vim You won t be disappointed I m not going into the discussion which editor is best for you That would take too much time Question Who of you have never used Vim Who is using Vim every day Three basic steps 1 Detect inefficiency 2 Find a quicker way Keep an eye out for actions that you repeat and or spend a lot of time on Lean back and evaluate what
2. WEEK SO WE CAN DOESN T EXIST YET CALL OUR TECK SUPPORT WE LL BLAME MICRO SOFT SHIP IT WHEN THE SOFT WARE TS DONE YOU LL HAVE TO MAKE LOGLCAL S Adams E malli SCOTTADAMS AOL COM The Dilbert book helps you to enjoy life Read it when you take a break These two books make a great combination See http www iccf nl click2 html for more information and help orphans in Uganda at the same time Habit 1 Moving around quickly Step 1 Detect inefficiency You wonder where a variable is used You use While editing a program you often have to check where a variable is set and where it s used Currently you use the search command to find each location And if you type it wrong you can t find it Habit 1 Moving around quickly Step 2 Find a quicker way In the help on searching you find sethlsearch and include lt stdio h gt int main int arge char argv char progname outname inname it irge lt 2 arge gt 3 4 fprintf stderr d arguments is not right n argc exit 1 outname argv arge e progname argv 0 if arge gt 1 inname argv 1 lt arge gt You look in the help for searching commands You find references to two items that appear to be useful The hlsearch option shows all matches with a pattern You don t have to find each match you can see them right away The command searches f
3. quickly move to it and open the fold That s a clever way to move around quickly 10 Habit 2 Don t type it twice step 1 Detect inefficiency You have a hard time typing Function names can be very difficult to type It takes a lot of key strokes and it s easy to make a mistake I see people use copy paste for these names but that still is not very effective 11 Habit 2 Don t type it twice step 2 Find a quicker way You ask a colleague how he does this This time you ask someone else if he knows a quicker way He has run into the same problem before and found a good solution Insert mode completion It s always a good idea to ask someone else you don t have to invent the solution yourself 12 Habit 2 Don t type it twice step 3 Make it a habit f include lt X11 xpm h gt get_bitmap status Xpmcr INSERT 5 18 All type CTRL N include lt X11 xpm h gt get _bitmap status XpmCreatePixmapFromData Keyword completion N P match 1 of 16 5 36 You start using it and find out what you need to type to complete it quickly If you don t type enough you get too many matches Type CTRL P to go back to the original word type an extra letter and hit CTRL N again If you don t get a match you forgot the include line After doing this for a while you hardly type any long words It s also useful when typing unusua
4. you have been doing the past hour If you have more than a bit of work to do try to find a pattern in it that repeats itself Example You have a program with several files and have to rename a function that s used in many places If you have to type the name many times you are inefficient Any powerful editor provides you with commands to do your work fast You just have to find them If the editor doesn t offer an appropriate command you can use its script language Or perhaps you can use an external program You have to learn new commands until you use them automatically Summary 1 See the problem 2 find a solution 3 use it That sounds easy doesn t it And so it is you just have to do it Seven habits The 7 habits of highly effective people Stephen R Covey eee OVER 10 MILLION SOLD I will give seven examples Why seven To match the title The title is inspired by the book from Stephen Covey The Seven habits book is a very good one I can recommend it to anyone who wants to improve his life And who doesn t Although the presentation might as well be based on Dilbert Seven habits Seven years of highly defective people Scott Adams DILBERT by Scott Adams HOW CAN I WRITE TINA YOU LL HAVE TO TF YOU PRESS ANY HAVE ALL THE DOCUMEN INSTRUCTIONS FOR KEY YOUR COMPUTER TATION WRITTEN BY SOMETHING THAT WILL LOCK UP LF YOU NEXT
5. any programs that work with formatted text but have a bad editor Vim is a good editor but does not do layout Connecting the two will use the best of both 24 Habit 5 Let s work together Step 2 Find a quicker way Check the MS Word OpenOffice org Outlook docs Can you select another editor No You ask the Vim maillist if someone knows a solution Response Unfortunately you can t find an existing solution for this Second best is to copy paste the text and edit itin Vim You need to avoid inserting hard line breaks Another solution would be to remove the line breaks when copying to the clipboard You can make a mapping for this 25 Habit 5 Let s work together Step 3 Make it a habit 26 Habit 6 Text is structured Step 1 Detect inefficiency You are wading through a list of lint warnings to find real errors usr local include glib12 glib h 1328 warning static function usr local include glib12 glib h 1562 warning static function usr local include glib12 glib h 1580 warning static function usr local include glibl2 glib h 1599 warning static function edit c Yusr local include glibl2 glibconfig h 43 warning ANSI C does n usr local include glib12 glibconfig h 44 warning ANSI C does n usr local include glib12 glib h 725 warning dubious operation usr local include glibl12 glib h 759 warning dubious operation usr local include glib12 glib h 760 warning dubious ope
6. e quickfix window define K KINS TERMCAP2KEY KS EXTRA KE_KINS define K DEL TERMCAP2KEY k D define K KDEL TERMCAP2KEY KS_EXTRA KE_ KDEL define K HOME TERMCAP2KEY k h define K KHOME TERMCAP2KEY K 1 keypad home u Ipper left define K XHOME TERMCAP2KEY KS EXTRA KE XHOME ledit c 653 case ledit c 924 case lex _getln c 915 case keymap h 342 define misc2 c 1707 4 5 Inermal c 376 4 3 y Nnermal c 2866 case K S HOME cap gt cmdchar break TERMCAP2KEY k h char_u Home nv_home NV_sss NV_sTs 0 Error List lt K HOME gt The quickfix window lists all items from a make or grep command This gives you an overview and allows quickly jumping to the location you want to see Hitting lt Enter gt on a line displays the line with that error in the other window Habit 4 A file seldom comes alone Many other ways use gf Goto File on header file names also works for http some org some file These are useful commands when browsing source code They don t require a tags file or anything only that the path option is set to find include files Like the list of directories that the compiler uses 23 Habit 5 Let s work together Step 1 Detect inefficiency You have to use MS Word OpenOffice org Calc Real power comes from programs working together There are m
7. ed Compare to learning to drive a car The first few lessons you have to think about how to get it in the next gear Only after practicing a while you can do it automatically and have time to think about where you are going Learning to use an editor is similar with one important difference It has many more commands Too many to learn them all You need to learn one at a time when you need it On a meta level you should think about what you did with the editor How much time did you waste on not using the best commands How much time did you waste on finding a better way How much time did you win by writing that macro Use this to know what you need to do in the future 30 Habit 7 Sharpen the saw Vim will help you sharpen your saw folding automatic indenting Vim has many more features All of them have been asked for by users Thus it should make editing more effective for you too Automatic indenting is very flexible You can define indenting for your specific needs This avoids manually adjusting the indent This uses plugins thus can be changed easily Plugins make it easy to add functionality and exchange scripts between users It s a matter of dropping the plugin in the right directory They exist for generic use and specific to a certain filetype Editing files over a network saves you the manual commands to make a copy of a file and write it back later This is actually done by a plugin Since Vim 7 0 i
8. l make the same again and again Your fingers just don t do what you intended This can be with abbreviations A few examples iabbr Linux iabbr across iabbr the fne words will be automatically corrected just after you typed them syntax keyword WordError mistake found GRENSE so vim wordlist vim Tire Now you spot typing mistakes while editing text And they are automatically corrected when you type them Actually it was a bit difficult to create this example since the mistakes were automatically corrected when I typed them 18 Habit 3 Fix it when it s wrong Step 3 make it a habit Whenever you spot a wrong word that isn t detected yet you add it to the dictionary If you do this often you can make a mapping for it 19 Habit 4 A file seldom comes alone Step 1 Detect inefficiency I have this problem every day Especially now that I work for Google 20 Habit 4 A file seldom comes alone Step 2 Find a quicker way You read the quick reference guide and find out about tags and quickfix A tag file can be used to jump to where an item is_defined_ Exuberant ctags is recommended http ctags sourceforge net Question who of you hear about using tags for the first time When searching for all places where a variable or function is _used_ the grep command finds them You can jump to each next item with cn 21 Habit 4 A file seldom comes alon
9. l names in e mail You can create a dictionary for specific words you use and set the complete option to use it 13 Habit 2 Don t type it twice New in Vim 7 0 omni completion cmd char_u _ mi_cend char after what was use Scratch Preview 1 1 Top Skip over the previously found word s wlen mip gt mi_compoff flen mip gt mi_cend mi_buf gt m buf_T bu mi_capflags m int WF mi_cend m char_u J iel mi_compextra m int He alle if Cbyts NU mi_compflags m char_u MAXWLEN return mi_complen m int ano mi_compoff m int ffi heel e mi_cprefixlen m int byte mi_end m char_u en Omni completion CAOANAP match 3 of 20 In Vim 7 0 a more advanced context sensitive completion has been added This needs to understand the language you are editing That makes it slower but more precise In the example you can also see the preview window where the context of the currently selected match is displayed The menu is nice to see the overview of matches and quickly jump though them It also works in a terminal that s why it looks quite ugly 14 Habit 3 Fix it when it s wrong Step 1 Detect inefficiency You often misspell English words When typing English text you often make mistakes You have to proofread your text carefully or use the spell checker 15 Habit 3 Fix it when it s wrong S
10. or the word under the cursor You don t have to type the word Habit 1 Moving around quickly Step 3 Make it a habit Put this in your vimrc file set hlsearch 66399 You now start using the command Every editor offers many ways to move around It s not a bad idea to read the documentation to find useful commands Note nohlseach can be abbreviated to noh Don t forget to use command line completion using lt Tab gt Habit 1 Moving around quickly folding in Vim 6 0 and later Exported folding functions 1 14 lines copyFoldingState 2 copyFoldingState 13 lines hasAnyFolding 2 hasAnyFolding jroo IM inesi a hasEoldi ng fie Gay Aieevstoloillis WiiKe Se aa 1 121 lines hasFoldingWin 2 hasFoldingWin 15 lines lineFolded 2 lineFolded ee 20 Lines coldedGountt 442 toldedCount i aa oaseananmea a foldmethodIsManual 4442 Return TRUE if foldmethod is manual int foldmethodIsManual wp win t wpy return wp gt w_p fdm 3 u 11 lines foldmethodIsIndent 2 foldmethodIsIndent 11 lines foldmethodIsExpr 2 foldmethodIsExpr 234 0 1 2 The folds contain a block of lines In this example each fold contains a function Closing all the folds makes it easy to locate a function
11. ration usr X11R6 include gtk12 gdk gdktypes h 657 warning dubious ope 63 1 0S Even though files contain plain text it is often structured You can use this to make your editing more productive If you have warnings in include files you can t avoid them It makes it difficult to find the serious warnings that you need to take care of Logs files have a similar issue 27 Habit 6 Text is structured Step 2 Find a quicker way Write cleanup commands in a function map _cl call CleanLint lt CR gt func CleanLint g gtk_x11 c enum d This time you decide to use the features the editor offers to extend its functionality Most editors offer some script language Vim has Vim script which uses the same Ex commands that you type interactively Put these commands in your vimre file 28 Habit 6 Text is structured Step 3 Make it a habit After running lint you type _ cl The trick here is to use the right patterns to only match the lines of harmless warnings You need to tune this to avoid that serious warnings get deleted or that harmless warnings clobber the list 29 Habit 7 Sharpen the saw You have to keep on tuning the set of commands you use for your needs The third step seems to come down to do it You might think that s obvious and not important The contrary is true Only when you have made the task a habit will you be able to work at high spe
12. t also browses remote directories Vim 7 is currently available with all of this Current work is mainly maintenance Vim 7 1 will be a bugfix release 31 Summary Step 1 Detect inefficiency Find out what you waste time on Step 2 Find a quicker way read the on line help 32 How not to edit effectively You have to get the text ready right now No time to read documentation or learn a new command You will keep on using primitive commands The first remark is obvious If you don t learn you will remain primitive I must warn for a pitfall when overdoing it Learning every feature of Vim might make you the great wizard of Vim but it will not be very effective And it will be impossible to make everything a habit 33 How to edit effectively with Vim Read the Vim user manual from start to end help user manual The user manual is written in a way that it should be read from start to end It started out as the first 20 chapters of Steve Oualline s Vim book Images were removed corrections made and new commands added I like to thank all the people that answer questions on the Vim maillist They make many Vim users happy 34 The end Questions I will be around for more information I have some extra info about Charityware and helping orphans in Uganda 35
13. tep 1 Detect inefficiency Using the spell feature of Vim 7 Awaiting updated patches 9 Mac unichde patch Da Woon Jung Eckehard Berns 8 Add ika Taro Mar 16 to support i change unicode to gt Unicode n put met hod add unicode to word list uni code New ignore unicode encode l j uncoded select Undo unicorn reaks display UTF 8 1 Paste unicoed blems Font replaceme a g ses th una code C ses Select Word uni coda Select Sentence uni cote i Commant Select paragraph mica Ork CALan Schmitt With Select Line jewsewrong with paste Comma Select Block nd V doesn t select all Alan SCHATTEE y remove macatsui option when this has been fixed 34 13 0 Now you spot typing mistakes when proofreading text But you still need to perform a sequence of actions to correct them That is OK for infrequent errors but clumsy for mistakes you make all the time 16 Habit 3 Fix it when it s wrong Step 2 Find a quicker way You search the Vim maillist archives This time you look for a solution on the internet The Vim maillist contains questions answers and announcements for scripts that people made You can find info about it on the Vim website http www vim org maillist php This is a very useful resource many questions have been asked and answered already 17 Habit 3 Fix it when it s wrong Step 3 make it a habit Very often you wil

Download Pdf Manuals

image

Related Search

Related Contents

Yamaha MG206C Track Sheet  Advertencia  Panasonic KX-MB2515 multifunctional  MMP 401 User Manual  BG-PM 40 P BG  Emerson Grommets Brochures and Data Sheets  2007 Riptide Owners Manual - NOT Trident Pro.pub    Q5K-YSG-004-000  Touch Panels TP27, TP37 - IBS Technology International H.K Ltd.  

Copyright © All rights reserved.
Failed to retrieve file