Popular Posts

Aug 26, 2019

vi cheat sheet & vi basic commands

vi cheat sheet & vi basic commands


APPLIES TO :  Oracle SPARC Solaris and all unix OS

ISSUE : 

GOAL :  Easy reference to work in vi editor

SOLUTION :  


     1. To Move the cursor left  in vi editor
                 Press h
                 Press 5h - to move the cursor 5 characters left

     2. To Move the cursor right  in vi editor
                 Press l
                 Press 5l - to move the cursor 5 characters right

     3. To Move the cursor down  in vi editor
                 Press j
                 Press 5j - to move the cursor 5 lines down

     4. To Move the cursor up  in vi editor
                 Press k
                 Press 5k - to move the cursor 5 lines up

     5. To move the cursor to the right one word at a time in vi editor
                 Press w (“word”)
                 Press 5w - to move the cursor 5 words right

     6. To move the cursor to the left one word at a time  in vi editor
                 Press b (“back”)
                 Press 5b - to move the cursor 5 words left

     7. To move the cursor to the last character of the current word in vi editor
                 Press e (“end”)

     Moving to Start or End of Line
     8. To move the cursor to the start of the current line in vi editor
                 Press ^ or Press 0

     9. To move the cursor to the end of the current line in vi editor
                 Press $

     10. To move the cursor to the beginning of the next line down in vi editor
                 Press the Return key

     11. To move the cursor one character to the left in vi editor
                 Press the Back Space key

     12. To move the cursor one character to the right in vi editor
                 Press the Space Bar

     13. To move the cursor to the top of the screen in vi editor
                 Press H (“high”)

     14. Move to the first non-blank character of the line in vi editor
                 Press ^

     15. Jump forward one sentence in vi editor
                 Press )

     16. Jump backward one sentence in vi editor
                 Press (

     17. Jump forward one paragraph in vi editor
                 Press }

     18. Jump backward one paragraph in vi editor
                 Press {

     19. Jump to the middle of the screen in vi editor
                 Press M

     20. Jump to the bottom of the screen in vi editor
                 Press L

     21. Move the cursor to the end of file  in vi editor
                 Press G

     22. To create line numbers at the beginning of file  in vi editor
                 :set number

     23. Append or add a text next to the cursor in vi editor
                 Press a and type your content and press esc when finished

     24. Insert a text at the left of the cursor in vi editor
                 Press i and type your content and press esc when finished.

     25. Insert new line below the cursor  in vi editor
                 Press o

     26. Insert new line above the cursor  in vi editor
                 Press O

     27. Undoing a previous command or a change  in vi editor
                 Press u

     28. Undo all changes made to a line in vi editor
                 Press U

     29. To delete one character, position the cursor over the character to be deleted in vi editor
                 Press x

     30. To delete a word, place the cursor at the beginning of the word in vi editor
                 Press dw

     31. To delete a line, place the cursor anywhere on the line in vi editor
                 Press dd

     Copying Lines
     32. To Copy a line, place the cursor anywhere on the line  in vi editor
                 Press yy

     33. Paste the copied line, place the cursor above the line we need to paste in vi editor
                 Press p
                 Press P - paste the copied line to the above line


     Searching and Replacing
     34. Search a string in vi editor
                 :s/string
                 The first match of your string will be highlighted, Type n to see the additional occurance of nex match.

     35. Search and Replace a string in a line in vi editor
                 :s/pattern/replace/
                 This will replace the pattern with replace in the current line

     36. Search and Replace a string in a entire file in vi editor
                 :%s/pattern/replace/
                 This will replace every occurance of pattern with replace



~Judi~

Popular Posts