My work goal for the week ending 21/04/2007 in Hitwise is to learn at least 10 NEW Vi commands which I can apply to my day to day work, the following is the compiled list of my research, happying learning. 1. Double spacing
:%s/$/{ctrl-V}{CR}/g
2. Strip blanks at end of line:
:%s/{TAB}*$//
3. Strip DOS ctrl-M’s:
:1,$ s/{ctrl-V}{ctrl-M}//
4. Append current file to a file
:w>>file
5. Write lines 5 through 10 to file
:5,10w file
6. Append Lines 5 through 10 to file
:5,10w>>file
7. Create a shortcut for docBlock for a comment, “ab” stands for “Abbreviations”
:ab _comment /***   *  ***/
This is what you will see in vi editor:
:ab _comment /*** ^M * ^M***/
Now if you type ab and then space in the insert mode, you will see the following:
/***
 *
 ***/
8. Copy lines 5-10 to the line after 105
:5,10 co 105
9. Move lines 5-20 to end of file
:5,20 m $
10. Start a file with the cursor positioned at line 24
vi +24 myfile.txt
11. Start a file with the cursor positioned to the first occurrence of the string foo in the first file being edited
vi +/foo myfile.txt
12. Shows number of lines in file
:=

Leave a Reply

Your email address will not be published. Required fields are marked *