Preface
VI learning
common commands
Command Mode (ESC enter)
view
into edit mode
Edit mode
search
copy and paste
the Save As
execution to shell
VI learning
common commands
Command Mode (ESC enter)
view
into edit mode
Edit mode
search
copy and paste
the Save As
execution to shell
"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 n
nG
- Displays the current number of ranks
Ctrl+G
- Left and right up and down
h
j
k
l
Enter edit mode
- Before the cursor after the character location insert
i a r
i=insert; a=append; r=replace;
- Inserted at the beginning of a line
I
- End of the line inserted
A
- Under the new open line cursor
o
- The new open line above the cursor
O
Edit mode
- Clear entire line begins to fill
cc
- Delete current character
x
- After you remove the cursor n characters
nx
- Delete the cursor first n characters
nX
- After you remove the cursor n words
ndw
- Delete the entire line
dd
- Delete the cursor to the end of the line
D
- go back
u
search for
- Reverse search the file until the beginning of str
?str <return>
- Repeat retrieval
n
N
Copy and Paste
- Open the two files
vi file1 file2
- Copy row
yy
- Switch to next file
:n
- Pasted at the current cursor
p
- Switch back to file
:n
Save as
- Save as file between rows
:20,59w /tmp/1
Go to execute shell
:!s