برگه تقلب vim برای استفاده روزمره

۱۳۹۹/۲/۱۴
🔙

جادی شروع کرد به یاددادن vim همین انگیزه ای شد برم سراغ کامل کردن اطلاعاتم تو این زمینه ویدیو مذکور
خیلی وقتا از vim استفاده می‌کردم برای ادیت های سریع و کوتاه ولی هیچوقت جدی دنبال یادگرفتنش نرفته بودم.
اینجا میشه یه صفحه تقلب و رفرنس برای vim

Move Commands

key action
j move down
k move up
h move left
l move right

Edit Commands

key action
i insert mode
x delete next char
X delete previous char / backspace
o add a new line under this line and go to input mode
O add a new line above this line and go to input mode
r<char> replace this cahrachter with <char>
a write from end of this line
u undo last command
d general delete command / icut
<number><command> repate <number> times <command>
dw delete this word from cursor / cut this word from cursor
diw delete this word/ cut this word
dd delete this line from / cut this line
dt<char> delete from cursor to <char> in this line.
J join this line to next line. (concat them togheter)
<number>G Go to line <number>
G go to eof
y yank, general copy command
yy copy this line
yw copy this word from cursor
yiw copty this word.
c general change command.
cw change this word
ciw change this word (inner word)
p paste under line / after
P page this line / before
$ end of this line
^ start of this line
. repeate last command.

Search Commands

key action
/ Search mode
? Search mode (from end to start)
/<str> search <str> in file.
n find next occurrence
N find previous occurrence
% move between pairs (, [,{
:s/<term1>/<term2> replace first occurrence of term1 with term 2 in this line
:s/<term1>/<term2>/g replace all occurrence of term1 with term 2 in this line
:%s/<term1>/<term2>/g replace all occurrence of term1 with term 2 in whole file
:<line1>,<line2>s/<term1>/<term2>/g replace all occurrence of term1 with term 2 in range of line1 and line2
:s/<term1>/<term2>/gc get confimation for each one

Colon Commands

key action
:w write (save)
:wq write then quit
:w <fileName> write or craeted file
:<line1>,<line2> w <fileName> write changes just between line1 and line2
:q quit
:q! quit without saving.
:set number / :set nonumber enable/disable line numbers
ctrl+g show your location in the file and the file status.
:! run a system shell command
!! run a system command and paste result to vim

Samples

key action
3dd delete (cut) next 3 lines
2yy copy next 2 lines.
diw delete (cut) this word.
yiw copy this word
d$ delte to end of this line