4.4-vi Command

TOC

"Embedded Linux Development Basics"

Foreword

  • Remote access need to use the shell built-in text editor, you must learn basic skills
  • HELLOWORLD program as an example to the basic program editing, compiling, debugging, practice!

VI Learning

  • There are three states: Edit mode, insert mode and command mode, when you enter vi, will be the first to enter the command mode (also edit mode), press i to enter insert mode, press ESC back to the command state (also edit mode)
  • In the insert mode, can not enter the instruction, you must first press <Esc> key, return to command mode. If users do not know where he will state may be press <Esc> key, no matter in what state, will return to command mode. When you modify a file, quit and how to archive specified files are very important. In vi, the exercise archive or exit command, first by a colon (:), change the command mode, the user can see at the bottom left of the screen, there colon (:), has been changed to display the vi command mode, you can conduct such as archiving or quit working.

Common Commands

Command Mode (ESC to enter)
View
  • Exit abandon Archive:q!
  • Read-only file archive force:w!
  • Archive and exit:x
  • Jump to line nnG
  • Displays the current number of ranksCtrl+G
  • Left and right up and downh j k l
Enter edit mode
  • Before the cursor after the character location inserti a r

    i=insert; a=append; r=replace;

  • Inserted at the beginning of a lineI
  • End of the line insertedA
  • Under the new open line cursoro
  • The new open line above the cursorO
Edit mode
  • Clear entire line begins to fillcc
  • Delete current characterx
  • After you remove the cursor n charactersnx
  • Delete the cursor first n charactersnX
  • After you remove the cursor n wordsndw
  • Delete the entire linedd
  • Delete the cursor to the end of the lineD
  • go backu
search for
  • Reverse search the file until the beginning of str?str <return>
  • Repeat retrievaln N
Copy and Paste
  • Open the two filesvi file1 file2
  • Copy rowyy
  • Switch to next file:n
  • Pasted at the current cursorp
  • Switch back to file:n
Save as
  • Save as file between rows:20,59w /tmp/1
Go to execute shell
  • :!s

Guess you like

Origin www.cnblogs.com/lizhensheng/p/11117167.html
Recommended