2.7 KiB
Basics2
-
To delete a word type
dw -
deleting from left to right(end of line) type
d$ -
Many commands that change text are made from an operator and a motion.
The format for a delete command with the d delete operator is as follows:d motion
Where:
d - is the delete operator.
motion - is what the operator will operate on (listed below).A short list of motions:
w - until the start of the next word, EXCLUDING its first character. e - to the end of the current word, INCLUDING the last character. $ - to the end of the line, INCLUDING the last character. -
Number itself can be used to move cursor
2wcan be used to move cursor 2 words forward and at start of the 2nd word next to it
2elike 2w but instead of first character it moves to last character of the word
0works like home button ie to move to beginning of line
Eg:
Before using2wcursor is on
==L==orem ipsum try it After using it Lorem ipsum ==t==ry it Before using2ecursor is on
==L==orem ipsum try it After using it Lorem ipsum tr==y== it -
Now using
operator number motionsyntaxd2w: will delete 2 words ie current word and next word with syntaxnumber operator motiondd: will delete the whole current line2dd: will delete 2 lines ie current and next one -
Undo command Loprem ipsum try it Some changes like Loorem ipsum try it
u: to undo previous change Loprem ipsum try it Some more changes like Looooorem ipsi bipsy try it So many changes r thereU: to undo all changes for current line and bring back to its original state Loprem ipsum try it Redo :<C-r>Ctrl+R -
Put command For example if u delete a line using
ddthan that line will be stored in neovim register then we can put the line below the cursor usingpBefore using dd for a a. 1st line b. 2nd line After using it b. 2nd line then on moving cursor to line b and usingpb. 2nd line a. 1st line Note:pis used to put down/next to butPis used to put it up/before to it -
Replace command
rwill used for replacing a character Eg : Lor==a==m Now pressingrthene=> Lor==e==m -
Change Like using insert or i but with a variation ie before going to insert word it will delete the corrent word. , type
ceIts a combinationdeandic is like d actually with diffrence that it will put into insert mode after deletion soc2wisd2w+i.