Linux command line and vim simple learning record

Source: Internet
Author: User

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

    • New File 1.cpp

    Touch./1.cpp

    • Open File 1.cpp with vim

    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

    • To edit mode

    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

    • Show line Numbers

    : Set Nu

: Set Number

3. Other

    • Undo Action

    U

    • Save (write)

    : W

    • Exit (need to save first)

    : Q

    • Force exit (when not saved)

    : q!

    • Save and exit

    : QW

or : x

    • Return to command line (not saved)

    : SH

Back to file ctrl+d

    • Find character x

    /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

    • Area selected

    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

    • Vertical split Screen

    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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.