Vim Tutor随记

How to use neovim

u will undo the change in Nomarl Mode

How to delete the character in Normal Mode

type the h j k l to move the cursor to the character you want, and press x

How to append something to the sentence tail

move cursor and press A. The Caps A

How to edit a file by nivm

nvim <filename> and :wq to save the changes

The Deletion Command

How to delete the word you want

move the cursor to the beginning of the word, and press dw

Type d$ delete to the end of the line

d - is the delete operator
motion - is what the operator on

motions:
w - delete the word where cursor is
e - delete to the end of current word, INCLUDING the last character
$ - delete to the end of the line.

NOTE: Keep pressing the d will keep deleting the character. Actually, it’s a combination. Just to type once is ok. Like type d, the type $. And the command will run perfectly.

Quick move the cursor

2w – two words the cursor move forward like move right

3e – the third word cursor

0 – MOVE THE CURSOR TO THE START OF THE LINE

Operations on lines

dd – delete a whole line

Undo command

type u to undo once

type U to undo all the line

ctrl + r to undo the undo commands

The PUT COMMAND

Type p to put previously deleted text after the cursor

The REPLACE COMMAND

Type r$ to replace the character at the cursor with $

The CHANGE OPERATOR

To change until the end of a word, type ce.

from the cursor (including the cursor)

Note that ce deletes the word and places you in INSERT MODE

MORE CHANGES USING c

format:
c [cursor] motion
motion:
w word
e end
$ the rest from the cursor

CURSOR LOCATION AND FILE STATUS

Type ctrl + g to show the location where the cursor is in a file and file status

Type G to move to a line in the file

Wanna go to the line$number format is $number + G

THE SEARCH COMMAND

type / + $yourlookingfor

type n to search next

type N to search backward

to search for a parse in the backward direction , use ?

MATCHING PARENTHESES SEARCH

type % to find a matching ), ] or } (need to move cursor to a parenthese)

THE SUBSTITUTE COMMAND

format:
:s/oldStr/newStr/ - only match the first oldSTR /two example/ :s/oldStr/newStr/g - match all oldStr in sentences and substitute

Note: to change every matches from line to line, just type
:#,#s/oldStr/newStr/g
example:
:1,10s/oldStr/newStr/g - use oldStr with newStr from line 1 to line 10

Note: to change every occurrence in the WHOLE FILE, type
:%s/oldStr/newStr/g

EXECUTE AN EXTERNAL COMMAND

Type :! followed by an external command

format:
:! + command
example:
:!ls -la

MORE ON WRITING FILES

To save the changes made to the file, type :w $FILENAME

SELECTING TEXT TO WRITE (Visual selection)

Type v to enter Visual Mode which just like pressing the left key and dragging it to obtain text

Note: after selected, you can type operator like d to delete the text selected

RETRIEVING AND MERGING FILES

To retrieve the contents of a file, type :r $FILENAME

Seems like copy the result to where the cursor is

THE OPEN COMMAND

Type o the open a line below the cursor and place you in INSERT MODE

THE APPEND COMMAND

Type a to insert text AFTER the cursor.

Note: a, i and A will go to the same Insert mode, the difference is the index or position of the cursor

ANOTHER WAY TO REPLACE

Type a R to replace more than one character.

Compared to r which can replace on character, R can replace more.

COPY AND PASTE TEXT

Use the y to copy text and p to paste it.

Note: you can use y as an operator: yw yanks one word. make no sense.
Note: you can use P to paste before the cursor instead of replacing after.

SET OPTION

Set an option that search and substitute commands ignore case.

Set the ‘ic’(Ignore case) option by entering
:set ic
Note: To remove the hightlight of matches
:nohlsearch

option  ":set xxx"
'ic'    'ignorecase'    ignore upper/lower case when searching
'is'    'insearch'      show partial matches for a search phrase(incomplete match)

prepend "no" to switch an option off

GETTING HELP

comprehensive (adj.完整的)

Note:
:help w
:help c_CTRL-D
:help insert-index
and so on

USE Tab to complete the command

use Ctrl d to see possible completions then use tab to complete the commands

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值