CÁC BÀI THỰC HÀNH LINUX - Trang 21

- 20-

x<p>

Places the contents of buffer x after the cursor

:w [file]

Writes contents to disk as file

:q

Quits vi

:q!

Quits file without saving changes

:wq

Saves changes and quits vi

:r file

Reads specified file into editor

:e file

Edits file

:!command

Executes specified shell command

:number

Moves to specified line number

:f

Prints out current line and filename (same as <Ctrl-G>)

/string

Searches forward for string

?string

Searches backward for string

:x,ys/oldstring/newstring Replaces oldstring with newstring from line x to line y

(entering y = $ will replace to end of file)

<ESC><u>

Undoes last command

<n>

Finds next occurrence of string. Repeats last command

~

Changes character to opposite case

<ESC>

Switches to command mode

THỰC HÀNH

1. Dùng chương trình vi để soạn thảo tập tin vanban.doc

$vi vanban.doc

2. Sao chép văn bản
4dd Cắt 4 dòng và đưa vào vùng đệm
Ctrl+d

Chuyển xuống cuối văn bản

p

Sao

từ vùng đệm vào sau dòng hiện hành

3. Đặt và bỏ chế độ hiển thị số dòng :

:set nu
:set nonu

4. Lưu nội dung tập tin và thoát khỏi vi:

:wq

5. Xem lai nội dung tập tin vanban.doc.