900 likes | 1.9k Views
The vi editor. CS240 Computer Science II. The three modes of vi Editor. Fucntions of the three mode in vi. Input mode: allows text such as source code to be entered.
E N D
The vi editor CS240 Computer Science II
Fucntions of the three mode in vi • Input mode: allows text such as source code to be entered. • Command mode: allows various commands to be entered for text editing and other purposes. Several commands such as insert, append, open, replace, and change that are issued in the command mode will take you to the input mode. • Last-line mode: all commands that start with a colon : puts vi in the last-line mode. Note: all text entered is temporarily kept in a buffer until permanently saved to disk.
Adding text filename: from command to input mode; must press Escape key to return to command mode
Customizing the vi environment: the set command • In the command mode type :set followed by a parameter listed below and press enter key. • all: lists a complete list of parameters and their current status. • atuoindent (or ai)creates tab stops; Ctrl+T tabs right and Ctrl_D tabs left. noautoindent or noai turns off autoindent feature. • shiftwidth=nn sets the spacing (#characters) between tab stops • number to display line numbers; nonumber remove line numbers. • wrapmargin=nn, where nn is arbitray positive integer representing # characters after which wrap-around takes place. • showmode displays the mode type; noshowmode removes the display. • Note that the parameters can be permanently set in a user’s startup file .profile With Bourne or Korn shell, or .login with C shell. The parameters may also be set in a .exrc file.