标题: 体验VI的强大功能-Advanced part [打印本页] 作者: diandianrong 时间: 2007-05-25 20:43 标题: 体验VI的强大功能-Advanced part
Starting and Ending VI Starting VI
vi filename
Edits filename
vi -r filename
Edits last save version of filename after a crash
vi + n filename
Edits filename and places curser at line n
vi + filename
Edits filename and places curser on last line
vi +/stringfilename
Edits filename and places curser on first occurance of string
vi filenamefile2 ...
Edits filename, then edits file2 ... After the save, use :n
Status
:.=
Shows current line number
:=
Shows number of lines in file
Control-G
Shows filename, current line number, total lines in file, and % of file location
l
Displays tab (^l) backslash (\) backspace (^H) newline ($) bell (^G) formfeed (^L^) of current line
Ranges
:n,m
Range - Lines n-m
:.
Range - Current line
:$
Range - Last line
:'c
Range - Marker c
:%
Range - All lines in file
:g/pattern/
Range - All lines that contain pattern
Shell Functions
:! cmd
Executes shell command cmd; you can add these special characters to indicate:% name of current file# name of last file edited
!! cmd
Executes shell command cmd, places output in file starting at current line
:!!
Executes last shell command
:r! cmd
Reads and inserts output from cmd
:f file
Renames current file to file (实验没通过,不知道是不是因为OS的原因)
:w !cmd
Sends currently edited file to cmd as standard input and execute cmd
:cd dir
Changes current working directory to dir
:sh
Starts a sub-shell (CTRL-d returns to editor)
!}sort
Sorts from current position to end of paragraph and replaces text with sorted text