Lessons‎ > ‎


  • แบบฝึกหัด LABVILESSON.PDF ส่งในห้องเรียนถึงหัวข้อการแทนที่ข้อความ โดยไม่เปิดไฟล์ของเดิมขึ้นมาแก้ไข
  • LABVILESSON.PDF ทำให้จบทุกหัวข้อบันทึกเป็นอีกไฟล์
  • แบบฝึกหัด VI_LAB.PDF ดาวน์โหลดด้านล่างไซต์ กำหนดส่งวันพุธที่ 6 กันยายน 2560
  • แบบฝึกหัด Unix Command & vi ส่งที่ฟอร์มนี้ กำหนดส่งวันอังคารที่ 12 กันยายน 2560
  • https://docs.google.com/forms/d/e/1FAIpQLSfOJtVP0DVPXETSvs7uuJetmM_KvHwYqhuYJwGcmuZoL_zqoA/viewform
vi Text Editor

Lesson 1
  1. Start by typing vi followed by the file(s) you want to edit. Example: vi one.txt two.txt etc.txt
  2. There are two modes: command mode and insert mode. You will begin in command mode. (Unless you have a config file which changes this. Rare.)
  3. Hitting the Esc key always puts you in command mode. It never takes you out of command mode.
  4. Commands only work in command mode. Get used to hitting Esc a lot.
  5. Esc is your friend. If you begin to issue a command and then change your mind, always hit Esc a few times to cancel.
Basic Editing
  1. Hitting i or a from command mode puts you in insert mode. i starts inserting text before the cursor. a starts appending text after the cursor.
  2. Type : Your name, Last name, Subject, Section, ID, Department, University
  3. Use h j k l to move left, down, up, and right, respectively.
  4. Use w e b to move forward one word, forward to the next end of a word, and back one word, respectively.
  5. Use x to delete one character, dw to delete one word, or dd to delete one whole line.
  6. Use a number before a command to repeat the command that many times. Example: 3dw deletes three words starting from the current cursor position.
  7. u (lowercase) means undo the last change.
  8. ZZ (uppercase) saves any changes and quits.
  9. :wq! save and quits.

Cut and Paste ( yy  p  dd  dw )
  1. yy yanks the current line into the buffer. This is like copying the current line to the clipboard.
  2. Example: 3yy yanks three lines into the buffer starting with the current one.
  3. p (lowercase) pastes the buffer contents to the line under the current one.
  4. P (uppercase) Pastes the buffer contents to the line above the current one.
  5. Lines deleted with dd also end up in the buffer and can be pasted.
  6. Words deleted with dw also end up in the buffer and can be pasted.

Going to a Line or Column
  1. Type a number followed by G (uppercase) to go to that line number. Example: 24G goes to line 24. Example: G goes to the last line of the buffer.
  2. Type a number followed by | (pipe) to go to that column in the current line. Example: 40| goes to column 40.

Search for a String
  1. Use / (foward slash) followed by a string to search for that string. Example: /foobar would find the first occurrence of foobar after the cursor position. It would also find, for example, something like foobariciousness.
  2. After the first occurrence of the string is found, use n (lowercase) to find the next occurrence. Continue hitting n as needed.
  3. Use N (uppercase) to find the previous occurrence of the string.
  4. Use ? (question mark) followed by a string to search backwards through the file for that string.

Useful Tricks
  1. G by itself goes to the last line of the file.
  2. $ goes to the end of the current line.
แบบฝีกหัด VI

Pattamaporn Pimhanam,
29 ส.ค. 2560 08:59
Pattamaporn Pimhanam,
29 ส.ค. 2560 09:10
Pattamaporn Pimhanam,
4 ก.ย. 2560 10:12
Pattamaporn Pimhanam,
27 ส.ค. 2560 23:28