Vim Editor Usage rules
- The Vi Editor has 3 usage modes: General mode, edit mode, and command mode.
- $SHELL: View the current default SHELL type
$BASH _version: View the current Shell version
3. General Mode:
Cursor Movement shortcut keys |
Operation |
Shortcut keys |
Move Cursor Down |
Down ARROW key,J, space bar |
Move Cursor up |
Up ARROW key,K,backspace key |
Move the cursor to the left |
Left ARROW key,h |
Move the cursor to the right |
Right ARROW key,L (l lowercase ) |
Move to the beginning of the next line |
Enter |
Move to the beginning of the previous line |
- Key |
Move to the last line of the file |
G Key |
Text Manipulation shortcut keys |
Operation |
Shortcut keys |
Right insert |
A |
Left insert |
I |
End of line Append |
A |
Beginning of insertion |
I |
Insert Row |
O ( insert one line ) or o ( bottom line ) |
Overwrite text |
R |
Merge rows |
J |
Text copy and paste shortcut keys |
Operation |
Shortcut keys |
Copy rows |
Yy |
Copy Multiple lines |
Nyy |
Copy a Word |
yw |
Copy multiple words |
Nyw |
Copy cursor to beginning of line |
y^ |
Copy cursor to end of line |
y$ |
Where to paste after the cursor |
P |
Where to paste before the cursor |
P |
Delete text shortcut keys |
Operation |
Shortcut keys |
Delete current character |
X |
Delete multiple characters |
Nx |
Delete When moving forward |
Dd |
Delete multiple rows |
Ndd |
Undo previous Action |
U |
Undo Multiple actions |
U |
"/": Search mode :/string-N ( search down )/n ( search up )
4. Edit mode:
It's not much different from other editor modes.
5. Command mode:
Common vi commands |
Operation |
Command |
Open File |
: E file name |
Save File |
: W |
Exit editor |
: Q |
Exit editor directly |
: q! |
Exit and save the file |
: Wq |
Jumps to the specified line |
: N : n+ ( next hop n row ) : N-( top jump n rows ) |
Show or hide line numbers |
: Set Nu : Set Nonu |
Replace string |
: S/old/new replaces the first occurrence of the old in the current row with the string new : s/old/new/g replaces all strings in the current line with string new old : n,m s/old/new/g replaces all strings from n to m with string new old :%s/old/new/g replaces all characters in the current file with string new old |
Set file format |
: Set Fileformat=unix |
6. Building the system environment
Shell configuration file:
There are 5 main profiles for Bash , 4 of which are in the user home directory.
. Bash_profile: is located in each user's home directory, where it is used to save the shell information that the user uses . Environment variables are often set.
. BASHRC: Contains bash-related information specifically belonging to a user . Used primarily to define aliases and functions.
. bash_logout: Executed every time the current user exits the Shell .
. bash_history
There is also a BASHRC in the/ etc directory . files that are used jointly by all users of bash.
Vim Editor Usage rules