1, an exemplary (a command provided to cut state)
^ Move the cursor to the beginning of the line$ Cursor to the end of the lineset nu show line numbers:% s / foo / bar / g looks at global scope (%) foo and replaced named bar, then all occurrences are replaced (g) refer to: Find and replace regarding the vimu undo earlier actionctrl + r is restored just undone
2, Command List
command | Explanation |
x | Delete the character at the cursor position, and put the characters into the clipboard |
nx | Remove the cursor is positioned behind the n characters, and the character into the clipboard as 5x |
X | Delete the cursor position in front of the character, and the character into the clipboard |
nX | Delete position the cursor in front of n characters, and the characters into the clipboard |
yy | Copy the line where the cursor, and put the characters into the clipboard |
nyy | Copy n lines starting with the cursor, and put the characters into the clipboard |
dd | Delete cursor line and put the characters into the clipboard |
ndd | N cursor to delete the line that begins, and put the characters into the clipboard |
p (lowercase) | Paste the clipboard text to the bottom line of the cursor |
P (uppercase) | This text is pasted to the upper side of the line the cursor |
in | Revocation, if there has been misuse edit, use this command to undo the previous step, continuous revoked |
ctrl + r | After using u found undo edits can use this command can be used to redo |
Search and Replace
command | Explanation |
/word | Searching downwardly from the cursor position "word" string |
?word | Searching downwardly from the cursor position "word" string |
n | Before repeating a search operation, under a similar search |
N | And n contrast, a reverse search |
:set ic | Ignore case when searching |
:set noic | Ignore case when searching canceled |
:s /word1/word2/g | The current line "word1" replaced "word2" |
:s /word1/word2/gc | The current line "word1" replaced "word2", asks if you want to replace |
:%s /word1/word2/g | All of the current file "word1" replaced "word2" |
:%s /word1/word2/gc | All of the current file "word1" replaced "word2", it asks if you want to replace |
:set noic | Ignore case when searching canceled |
:set noic | Ignore case when searching canceled |