sudo apt-get install vim
/usr/share/vim
.
.vimrc
is the configuration file of Vim, store at /home/"Yourname"/.vimrc
/usr/share/vim/vimrc
.Vi/Vim Modes - Vi/Vim has three main modes
Command mode
"*yny
(n
- how many lines you want to copy), paste into another file by typing "*p
, and you can check the data currently in register by typing command (press ESC first)
:register`.Last line mode - excute command
:g/^$/d
, delete spaces before the first letter of a line: :%s/^\s*//g
, delete spaces after the last letter of a line: :%s/\s*$//g
.!
:set filetype=c
n
line: vim filename +n
.vim filename +/wordname
/word
, n
to next one.:%s/ori/des/g
, example delete "^M" at the end of each line, :%s/
$//g
, in order to input ^
you need type Ctrl
+ v
, input M
you need type Ctrl
+ m
.:split
then typing :open 'filename'
to edit.:split
then typing :open 'filename'
to edit.Input mode - Input text
Letter - new letter before cursor:
i
Letter - new letter after cursor:a
Line - new line behind current line:O
, Equal toA
+ENTER
Navigation use shortcut key (Moving cursor to wherever you like)
Letter
Letter - Move lef :
h
Letter - Mese right:l
Letter - Move up:j
Letter - Move down:k
Letter - First position of the line:o
Letter - First Letter of the line:^
(6)
Letter - Last Letter of the line:$
(4)
Letter - the n'th Letter of the line:n|
Word
Word - Previous word - Beginning:
b
Word - Previous word - Beginning (ignore punctuation):B
Word - Next word - Beginning:w
Word - Next word - Beginning (ignore punctuation):W
Word - Next word - End:e
Word - Next word - End (ignore punctuation):E
Line
Line - First line of the file:
gg
(g mean goto, pressg
twice)
Line - Last line of the file:G
(g mean goto, pressg
+shift
)
Line - n line::n
(n mean number)
Sentence
Sentence - Previous sentence's head:
(
Sentence - Next sentence's rear:)
Paragraph
Paragraph (Spilt with a blank line)
Paragraph - Previous paragraph's head:{
Paragraph - Previous paragraph's rear:}
Page-turning
Page-turning - Full page forward (down):
CTRL
+f
Page-turning - Full page back (up):CTRL
+b
Page-turning - Half page forward (down):CTRL
+d
Page-turning - Half page back (up):CTRL
+u
Screen
Screen - First line's first non-empty Letter:
H
Screen - Middle line's first non-empty Letter:M
Screen - Last line's first non-empty Letter:L