Linux command line
1. Open the command line
Ctrl+alt+t
2. Catalogue
- Displays a list of files for the current directory
Ls
- Jump to the X folder in the current directory
CD x
- Return to the root directory
Cd
3. Documents
Touch./1.cpp
Vim./1.cpp
- Compiling files with g++ 1.cpp
g++./1.cpp (The executable file named "1.out" is generated after compiling)
- Compile file 1.cpp with g++ as an executable file named "1"
g++./1.cpp-o./1-g
- Compile when using the random number template
g++./1.cpp-o./1-g-std=c++0x (New version: g++/1.cpp-o./1-g-std=c++11 )
- Run the executable file 1
./1
- To pass file 1.in as an input file to an executable file 1
./1 <1.in
- Pass file 1.in as input file to executable file 1 and output to file 1.out
./1 <1.in >1.out
- Continuously run the executable file gen output to file in, and each time with in as input file input to 1 and 22 executables, respectively output to 1.out,2.out, and compare two output files is the same (on the shoot, different words will stop)
While ./gen >in && 1 <in >out1 &&./2 <in >out2 && diff -W./OUT1/out2;do Echo Ok;done (-W: Ignore extra carriage return spaces)
Vim's simple operation
1. Toggle Mode
- To "Watch" mode (cannot change, can enter in this mode with many strange instructions to do many strange things)
Esc
I (to the front of the cursor)
a (after the cursor)
s (as if to remove something)
a (to the end of the line)
2. Instructions that can be used for pre-set
- You can use the mouse (delete with D after the mouse is selected)
: Set Mouse=a
- Auto Indent (Form C indent)
: Set AI cin
or : Set cindent
Cancel : Set Nocindent
- Set indent Length (default = 8)
: Set ss=4 sw=4 ts=4
: Set Nu
: Set Number
3. Other
U
: W
- Exit (need to save first)
: Q
- Force exit (when not saved)
: q!
: QW
or : x
- Return to command line (not saved)
: SH
Back to file ctrl+d
/x
Finds the next character X /A
Find previous character x ? x
Continue looking for characters x n in the current direction
Open Find highlight : Set HLS
Turn off find highlighting : Set Nohls
Ctrl + V (then use the upper and lower left and right operation) (Direct V is the normal selection)
Use x instead of the selected area r+x
Vs+filename
or vsp+filename
Press C after closing the current split screen ctrl+w
Close all other split screen ctrl+w outside the current split screen and press o
Linux command line and vim simple learning record