vi

vi

The default editor that comes with the UNIX operating system is called vi (visual editor).
The UNIX vi editor is a full screen editor and has two modes of operation:

  • Command mode commands which cause action to be taken on the file.
  • Insert mode in which entered text is inserted into the file.

เรียกใช้งาน vi เปิดไฟล์ filename

เข้าสู่โหมดเขียน (Insert mode) กด i

ออกจากโหมดเขียนเพื่อเข้าโหมดคำสั่ง (Command mode) กดปุ่ม Ctrl+[ หรือ Esc

คำสั่งในโหมดคำสั่ง (Command mode)

dd = ลบทั้งบรรทัด
:w = write (save) ไฟล์
:w ชื่อไฟล์ = write (save) ไฟล์ ด้วยชื่อที่กำหนด
:wq = write (save) ไฟล์ และออกจาก vi (Quit)
:wq! = write (save) ไฟล์ และออกจาก vi (Quit) ใช่กรณี read-only file
:q! = ออกจาก vi โดยไม่ Save
:set nu = สั่งให้ vi แสดงหมายเลขบรรทัด

Link

http://www.webserverthai.com/