Vim is an important text editor that could be operated in terminal directly. Thus learn to use it is of utter importance.
Configuration
Enable cursor movement with mouse
To enable movement of cursor by mouse, you need to edit or crate the ~/.vimrc file [1]. If this file do exist, you just need to add one line to it:
1 | :set mouse=a |
If you do not found this file in your ~/ directory, just create a .vimrc file and save the above line in it, then you will be able to move you curser freely with your mouse.
Enable cut/copy/paste in vim
Text operations
Edit file
open/create a file in vim with the commend:
1 | vi filename.type |
Type the above commend in the vim will enable these actions:
- insert (i) will enter the ‘insert’ mode which will enable you to edit the file
- view (ESC) will exit the insert mode and back into view mode
- write (:w) will write the changes into the file without leave the editing condition of the file, this operation is a bit like the save option when you have write some long text.
- exit (:x) will save the exit the file
- force exit (!x) will force to quite the file you are editing.
Enable Visual Selection (Ctrl+V)
Only after visual selection is turned on will you be able to copy, delete or paste the text in vim opened file. You can click ‘Ctrl+V’ to enter the visual mode, after you hit the two keys, there will be an ‘–visual–’ in the left bottom line in your vim terminal window.
Copy Text (y)
After the selection in visual mode, you can copy the text by press ‘y’ key.
Delete Text (d)
To delete the selected line of text, just press ‘d’ key.
Paste Text §
To paste the selected lines to the desired location, just mode your cursor to the desired location and then press ‘p’ key after selection.
Try to make some difference
Great? Not not at all.
Reference
[1] https://www.jacoballred.com/web-dev/enabling-mouse-support-in-vim/