3- VI editor.pdf
Document Details
Uploaded by Deleted User
Tags
Related
- VI LA SÉCURITÉ DANS LA LIBERTÉ PDF
- Modul Neuro-Otologi Edisi III 2022 PDF
- Social Studies Textbook Class VI - Provisional Edition 2021 - PDF
- VI Editor Cheat Sheet PDF
- Planificación de actividades educativas de atención a las necesidades básicas PDF
- Planificación de la Intervención en el Desarrollo Afectivo PDF
Full Transcript
Introduction to VI Editor June 1, 1999 Vi Editor 1 Overview of vi Performance Objectives 1. Start/End VI (vi, ESC, :wq) 2. Move the Cursor and Window (h,j,k,l, ^f, ^b) 3. Insert, Change, Delete Te...
Introduction to VI Editor June 1, 1999 Vi Editor 1 Overview of vi Performance Objectives 1. Start/End VI (vi, ESC, :wq) 2. Move the Cursor and Window (h,j,k,l, ^f, ^b) 3. Insert, Change, Delete Text (i, a, x, dd) 4. Search and Replace text (/.../, :n, $s/.../.../g) 5. Move/Copy Text (ma, d'a, p) 6. Write and Read Files (:w file, :r file) 7. Tailor the VI Environment (:set) June 1, 1999 Vi Editor 2 Why learn VI? Available on most UNIX systems. Works with a variety of terminals. Needs no special keyboard definition files. Provides for a customized editing environment. June 1, 1999 Vi Editor 3 Some Conventions vi commands do not require a. vi commands not echoed. ex commands begin with : / ? ex commands are echoed and ended with a The character ^ represents the key. Ø vi lyrics.txt Ø >i June 1, 1999 Vi Editor 4 Vi Modes: COMMAND mode – The default mode on entering vi. – Anything typed is interpreted as a command. – : to get back to command mode INSERT mode – Enter INSERT mode by typing one of several commands. – Anything typed is interpreted as data. – Enter insert by using typing i, a, or o – Exit INSERT mode by typing the key. June 1, 1999 Vi Editor 5 Vi Modes UNIX Shell vi filename :q :wq Command Mode i a o Input Mode June 1, 1999 Vi Editor 6 vi Window Display Line one File text Line two Line three ~ ~ ~ Null lines ~ ~ ~ Line n Command line EX cmd line June 1, 1999 Vi Editor 7 Vi Window Positioning vi window ^f Display Next segment File June 1, 1999 Vi Editor 8 Basic Window Positioning Move window forward 32 lines ^f Move window backward 32 lines ^b Move window forward one line ^e Move window to line n of file :n Move window to end of file G Move cursor up/dn left/rt or h j k l June 1, 1999 Vi Editor 9 Making Changes Permanent vi uses a temp file for changes: Perm Temp :w File File Write file and quit editor :wq Undo last command: u or U Recovery: vi -r filename June 1, 1999 Vi Editor 10 Insert/Delete Functions Del current line dd Del current char x Insert before current char i... Insert after current char a... Insert after current line o... (opens file at a line) June 1, 1999 Vi Editor 11 More Vi Functions Open several files vi file1 file2... End editor :q (does not save changes) Redraw screen ^l (L) Join this line with next J June 1, 1999 Vi Editor 12 Search For a Pattern Search forward to pattern /... / Search backward to pattern ?... ? Advance to next pattern n (forward or reverse) June 1, 1999 Vi Editor 13 Replace A Pattern Replace string with another :s/.../.../ (only on same line) Replace string (global) :%s/.../.../g June 1, 1999 Vi Editor 14 Moving Text ma mark the starting position with a d'a delete text into a buffer p put buffer contents after cursor ma Area to be moved d’a p Insert location June 1, 1999 Vi Editor 15 Copying Text ma mark the starting position with a y'a yank text into a buffer p put buffer contents after cursor ma Area to be copied y’a p Insert location June 1, 1999 Vi Editor 16 Writing to a file write current file :w write named file :w filename overwrite named file :w! write lines m - n to named file m,nw file June 1, 1999 Vi Editor 17 Useful Functions Re-edit current file, discard changes :e Edit named file :e file Read in and insert file at cursor :r file Execute command and return to vi :!cmd June 1, 1999 Vi Editor 18 Go to line number To go to a specific line in the file :linenumber 1. Go to the 3rd line by typing :3 2. Go to the 1st line by typing :1 3. Go to the last line by typing G More commands yl yank a single character. Specify count to yank more characters yw yank a single word. Specify count to yank more words d^ Deletes from current cursor position to the beginning of the line d$ Deletes from current cursor position to the end of the line Dw Deletes from current cursor position to the end of the word Tailoring the Environment For current session :set options Example: :set nu will set line numbers To view possible settings: :set all noautoindent nonumber noslowopen autoprint nonovice tabstop=8 noautowrite nooptimize taglength=0 nobeautify paragraphs= tags=tags /usr/lib/tags directory=/tmp prompt term=vt100 noedcompatible noreadonly noterse noerrorbells redraw timeout flash remap ttytype=vt100 hardtabs=8 report=5 warn noignorecase scroll=11 window=23 nolisp sections= wrapscan nolist shell=/bin/csh wrapmargin=0 magic shiftwidth=8 nowriteany mesg noshowmatch nomodelines noshowmode June 1, 1999 Vi Editor 21 Reference http://tnerual.eriogerg.free.fr/vimqrc.pdf