Presentation is loading. Please wait.

Presentation is loading. Please wait.

Text Editing February 2 nd, 2004 Class Meeting 3.

Similar presentations


Presentation on theme: "Text Editing February 2 nd, 2004 Class Meeting 3."— Presentation transcript:

1 Text Editing February 2 nd, 2004 Class Meeting 3

2 Text Editing Last week, you learned to manipulate files in the file system ( cp, mv, rm, ln ) and to view their contents ( cat, more ) How do you modify the contents of files? Unix editors work with plain ASCII text files: vi, emacs, pico Windows systems use their own window- based editors: Notepad, Wordpad

3 Why vi ? Availability included on practically all Unix/Linux systems Command-line editor, allowing use with remote login Simple and powerful

4 vi Basics Invoke with: vi [filename(s)] Editor takes over screen Various modes: command mode – characters send commands to editor (saving, quitting, searching, replacing) insert mode append mode change mode typing changes the text

5 Command Mode vi starts in this mode From other modes, typing Esc will enter command mode Commands for: Cursor movement Editing File operations Searching Entering other modes

6 Cursor Movement Up: k Down: j Left: h Right: l Larger Movements n{j|k|l|h} – move n characters/lines up/down/left/right Ctrl-F, Ctrl-B – page down, page up w – move to the beginning of the word :n – move to line n 0, $ – move to beginning or end of file

7 Editing Commands u – undo last typing x – delete current character dd – delete current line dw – delete current word rx – replace current character with x yy – copy current line p – paste copied/deleted items J – join two lines can be preceded by a number to perform operation multiple times

8 File Operations ZZ, :wq – save and quit :w – save :w – save as :q – quit :q! – quit without saving :e – load another file :n – load next file

9 Search /string – search for string ?string – search backwards for string n – repeat previous search N – repeat search in opposite direction % – find match of current (,[, or {

10 Entering Modes from Command Mode i – insert text before current character I – insert text at beginning of line a – append text after current character A – append text at end of the line o – open line above current line O – open line below current line cw – change (overwrite) current word C – change text after cursor

11 Additional Info Unix in a Nutshell – Chapter 8 lists all vi commands vi uses all lowercase letters except ‘v’ (and many uppercase characters and punctuation) for commands Be careful! Learn undo commands emacs is covered in Chapter 7

12 More Shell Commands ps – list current processes top – dynamic display of system’s utilization by processes kill – terminate a process time – keep timing information for a process


Download ppt "Text Editing February 2 nd, 2004 Class Meeting 3."

Similar presentations


Ads by Google