In Linux under the VI Editor to write Java code, the beginning may be quite awkward, when you use ripe, found that the VI editor is very useful, and no longer need the mouse!!! After almost a week of groping, here is a summary of my use of the VI Editor of the Common shortcut keys (and Linux shortcut keys and the common command to compile Java):
The VI editor is divided into three modes: Command mode, last line mode, input mode
Command mode:
1) H, J, K, l for left, bottom, up, right (move the cursor, use it not used to, or common direction key ⊙﹏⊙ B)
2) U: Undo previous action; Ctrl + R: Redo previous action (fairly common)
3) YY: Copy one line; number +yy: Copy (number of lines of the number of numbers written); p: Paste
4) x: Delete one character, DD: delete one line; DW: Delete a word (the cursor points to the first letter of the word); number +DW: Delete the word (the number of words written)
5) 0 (0): The cursor moves to the beginning of the line; $: The cursor moves to the end of the line where it is located
6) G: The cursor moves to the end of the file; the number +g: the line where the cursor moves to the number you are writing (1G: Cursor moves to the beginning)
7) R: replace one character; CW: replace one word
8) I: Insert at the cursor's current position, a: Insert after cursor position, O (lowercase letter): Insert a blank line under the cursor line, O (capital Letter): Insert a blank line on the line where the cursor is located
In the last line mode:
1): W Save: W newfile Save as new file: Wq Save back: q! Strong retreat
2): 1, $s/old string/new string/g replace full text (or:%s/old string/new string/g)
Second, in the course of taking notes, I started with the editor under Windows, and later because of the old Windows and Linux switch, using putty, remote access to Linux under Windows, but still want to be quite inconvenient, directly under Linux to do a variety of things, Used to become more and more like Linux, where the shortcut key to keep the super key will be displayed, very convenient, the mouse is really a decoration!!!
Third, the command to compile and run Java:
Create two folders mkdir classer SRC First
javac-d Classes Src/hello.java
JAVA-CP Classes Com.briup.chap01.Hello (package name + class name) (-CP represents Classpath, is the current path of the class)
Writing Java with VI Editor