praveen vim commands Flashcards
How do you open another file while you are in vim
Enter command mode and type
:e filename
You can also use :e to reload the file that you have currently opened. Typically this is used to discard the edits and start over from the previous saved file
How do you save a file?
Enter command mode and pressing :w
If you like to save and quit press :wq
How do you exit vim
Enter command mode and press :q
if you edited the file and you like to dicard the edits and exit vim without saving press :q!
Save the contents in vim as a different file
Enter command mode and :w newfilename
Repeats the last change made in normal mode
Enter comamnd mode and type .
Repeat 5 times the last change made in normal mode
Enter command mode and type 5.
move the cursor to the end of the word or beginning of word
e - end
b - beginning
move the cursor to the beginning/end of the line
0 beginning of line
$ end of line
move the cursor to the end/start of the file
In command mode
G - end
gg - first line
move the cursor to the bottom of the screen
L
move cursor to line 59. Replace 59 by the desired line number.
:59
Copy commands
Enter escape mode
Press y to copy the selected text to clipboard
press yy to copy the current line
press 5yy to copy 5 lines
press y$ to copy from cursor to end of line
press y^ to copy from start of line to cursor
Paste clipboard contents
Enter command mode and press p
Delete or cut
Enter escape mode and press
dd to Cut current line
D cut from cursor to end of line
Search fred or joe
/fred|joe