Basic vi Commands [zz]
来源:互联网 发布:淘宝助理上架 编辑:程序博客网 时间:2024/05/09 19:42
Basic vi Commands
What is vi?
- The default editor that comes with theUNIX operating system is called vi (visual editor).[Alternate editors for UNIX environments include picoand emacs, a product of GNU.]
- The UNIX vi editor is a full screen editor and has two modes of operation:
- Command mode commandswhich cause action to be taken on the file, and
- Insert mode in which entered text is inserted into the file.
- While there are a number of vi commands, just a handfulof these is usually sufficient for beginning vi users.To assist such users, this Web pagecontains a sampling of basic vi commands. The most basic and useful commands are marked with an asterisk(* or star) in the tables below.With practice, these commands should become automatic.
- NOTE: Both UNIX and vi are case-sensitive.Be sure not to use a capital letter in place of a lowercaseletter; the results will not be what you expect.
To Get Into and Out Of vi
To Start vi
- To use vi on a file, type in vi filename. Ifthe file named filename exists, then the first page (or screen)of the file will be displayed; if the file does not exist, then anempty file and screen are created into which you may enter text.
To Exit vi
- Usually the new or modified file is saved when youleave vi. However, it is also possible to quitvi without saving the file.
- Note: The cursor moves to bottom of screen whenever acolon (:) is typed. This type of command is completed byhitting the <Return> (or <Enter>) key.
Moving the Cursor
- Unlike many of the PC and MacIntosh editors, the mouse does notmove the cursor within the vi editor screen (or window). You must use thethe key commands listed below. On some UNIX platforms, the arrow keysmay be used as well; however, since vi was designed withthe Qwerty keyboard (containing no arrow keys) in mind, the arrowkeys sometimes produce strange effects in vi and shouldbe avoided.
- If you go back and forth between a PC environment and a UNIXenvironment, you may find that this dissimilarity in methods forcursor movement is the most frustrating difference between the two.
- In the table below, the symbol ^ before a letter meansthat the <Ctrl> key should be held down while theletter key is pressed.
[or down-arrow]
[or left-arrow]
[or right-arrow]
Screen Manipulation
- The following commands allow the vi editor screen (or window) tomove up or down several lines and to be refreshed.
Adding, Changing, and Deleting Text
- Unlike PC editors, you cannot replace or delete text by highlighting it withthe mouse. Instead use the commands in the following tables.
- Perhaps the most important command is the one that allows youto back up and undo your last action. Unfortunately, thiscommand acts like a toggle, undoing and redoing your most recentaction. You cannot go back more than one step.
- The main purpose of an editor is to create, add, or modify textfor a file.
Inserting or Adding Text
- The following commands allow you to insert and add text.Each of these commands puts the vi editor into insert mode;thus, the <Esc> key must be pressed to terminate theentry of text and to put the vi editor back into command mode.
Changing Text
- The following commands allow you to modify text.
starting with thecharacter under cursor, until <Esc> hit
e.g., c5w changes 5 words
stopping when <Esc> is hit
Deleting Text
- The following commands allow you to delete text.
e.g., d5w deletes 5 words
e.g., 5dd deletes 5 lines
Cutting and Pasting Text
- The following commands allow you to copy and paste text.
Other Commands
Searching Text
- A common occurrence in text editing is to replace one word orphase by another. To locate instances of particular sets of characters(or strings), use the following commands.
Determining Line Numbers
- Being able to determine the line number of the current lineor the total number of lines in the file being edited is sometimesuseful.
in the file at the bottom of the screen
Saving and Reading Files
These commands permit you to input and output files otherthan the named file with which you are currently working.
(the line with cursor)
http://www.cs.colostate.edu/helpdocs/vi.html
- Basic vi Commands [zz]
- Basic vi Commands
- some basic linux commands
- [转] Basic FTP Commands
- Selenium Basic Commands
- Basic FTP Commands
- MQ basic commands
- Basic Git commands
- Basic GDB commands
- Linux Basic Commands
- Basic Git commands
- Git basic commands
- zz: Windbg: debugging commands
- Linux Commands vi
- Frequently used vi commands
- basic and common shell commands
- Replace commands in VI editor.
- Basic "vi" features
- 显卡故障原因分析
- 【POJ3281 Dining 】最大流
- 基于UML的Blog系统分析与设计之四------用例描述2
- iReport默认参数和变量的意义
- Unix平台防止僵尸进程
- Basic vi Commands [zz]
- 早餐不能吃的食物,否则会肥胖
- ASP.NET里的文件上传大小限制的问题
- 全文索引在SQL200和SQL2005的简单建立过程及用法
- 实战DeviceIoControl 系列 之四:获取硬盘的详细信息
- Pittsburgh Penguins vs. Philadelphia Flyers: Riot on Broad Street
- WPF窗口跳转及window和page区别
- Setting JAVA_HOME in Linux [zz]
- Philadelphia Flyers: 5 Reasons Falling in the Standings Isn't a Bad Thing