Seven habits of effective text editing
Wed Aug 9 13:23:03 BST 2006
[Seven habits of effective text editing] has some tips for using Vim to edit text:
- To edit a file
- Move around quickly using searches and editor capabilities for jumping to matching brackets (%) , variable definitions etc (gd)
- Don't type things twice, use substitution and repetition. A period in edit mode repeats the last operation, so finding a word to replace, using cw to change the word and then repeating the find to get to the next word, followed by a period to repeat the change is a quick way of altering a file.
- Fix it when it's wrong by defining abbreviations for common typos. eg abbr Lunix Linux
- To edit multiple files
- use :grep and :cn to find all occurences of a name in a group of files. Use multiple windows to edit several files at once.
- use other programs to edit or filter text. For example select some text and use !sort to sort it.
- use macros to work with structured text eg :make to make a program
- Make it a habit, once you find a solution to something reuse it or you forget it.