[LINUX] vim command

I'm planning to take LPIC101 this weekend, but I can't remember the basic commands of the Vi editor because I don't use it normally, so I'll try to deepen my memory as a notepad.

Esc Command mode <=> Input mode

Input mode: vi [R] i: Enter text before the cursor (insert) a: Enter text behind the cursor (ahead) I: Move the cursor to the first character at the beginning of the line and enter the text immediately before it (Insert) A: Move the cursor to the end of the line and enter the text immediately after that. o: Insert a blank line below the current line and enter text on that line (open line) O: Insert a blank line above the current line and enter text on that line

vi cursor operation command: h: Same as the left arrow (←) key that moves one character to the left l: Same as the right arrow (→) key to move one character to the right k: Same as the up arrow (↑) key to move up one line j: Same as the down arrow (↓) key to move down one line 0: Move to the beginning of the line $: Move to the end of line H: Move to the beginning of the line at the top of the screen L: Move to the beginning of the line at the bottom of the screen gg: Move to the first line of the file G: Move to the last line of the file nG: Move to the nth line of the file : n: Move to line n of the file u: Cancel the last operation i: I want to change from command mode to input mode and input from the left side of the cursor :! Ls I want to check the files in the current directory without exiting the vi editor

Quit vi, save file, execute shell command : q Exit without saving to file : q! Exit without saving the content being edited : wq Save the content being edited and exit ZZ Save the content being edited and exit : x Save the content being edited and exit : w Overwrite and save the file with the content being edited : e! Restore the last saved content : r Read the contents of the file after the current line :! Execute shell command without quitting vi : r! Insert the execution result of the shell command

vi edit command: x: Delete the character at the cursor position X: Delete the character before the cursor position dd: Delete the current line (Press d for the first time on the xth line and d for the second time on the yth line): Cut from the xth line to the yth line. dw: Delete from the cursor position to the next word yy: Copy the current line to the buffer p: Paste the contents of the buffer below the current line (paste) P: Paste the contents of the buffer above the current line (paste) r: Replace one character at the cursor position (replace) -R: Read-only open file command yw: Copy the word at the cursor position to the buffer 3YP: Copy 3 lines including the cursor line and insert them above the cursor yyp: copy the line at the cursor and insert it in the line below : 5 (5G) Move the cursor to the 5th line of the file

vi search command / Pattern Searches the specified pattern backward from the cursor position ? Pattern Search for the specified pattern from the cursor position in all directions n Search for N Search for next (reverse method) :% s / A / B / Replace the first found string A with the string B :% s / A / B / g Replace all string A with string B

vi settings change : set nu Show line number : set nonu Hide line numbers (: set nonumber) : set ts = tab width Specify the tab width numerically (: set tabstop)

Recommended Posts

vim command
Vim
vi (vim) command memo
vim
Linux command # 4
Linux command # 3
Command memorandum
nkf command
command prompt
sed command
Linux command # 5
grep command
command memo
top command
Command memorandum
Command memo
VIM settings
mv command
seq command
Roughly systemctl command
Linux command list
ls command options
[Linux] Search command
Linux command <Basic 2>
First command plugin
pip command collection
scp command memo
nc command memorandum
Linux [directory command]
who command memo
Linux server command
Linux # Command Memo 1
Linux command [read]
Linux Command Summary
Arduino development on the command line: vim + platformio
[Basic] linux command
Linux [shell command]
Convenient command combination
[Linux] Command / Knowledge
IPF command information
change vim settings
My linux command
Future nl command
Vim with Atom
Memorandum conda command
Linux command <Basic 1>
ps command "wchan"
setuptools command memorandum
Django + Docker command
Broken pip command
Linux command collection
Linux mkdir command
Linux command basics
[Linux] Git command
Docker command summary
Linux (command memory)
DNS dig command