2: Linux-environmental basic development tools and their use

One: Linux package manager yum and preparations

(1) What is a software package

A: Software package

  • Different from Windows, to install software under Linux, the first method is to download the program source code, and then compile it to get the program; the second method is to install the rpm package. But these two methods are not recommended
  • We recommend using yum (Yellow dog updater, Modified) installation. In order to solve this kind of trouble, some people compile the software in advance and make it into a software package (similar to the installer .exe on Windows) and place it on the server, and get it through the package manager (yum is a package manager) The software package is installed directly. Software packages and package managers are similar to the relationship between "App" and "App store" . Yum has the functions of searching, downloading, installing and uninstalling

B: Note

  • The package name is: major version number-minor version number-source program release number-software package release number-host platform-CPU architecture

C: Basic use of yum

  • sudo yum install -y [软件名]//yum安装软件基本语法(-y表示无需确认)
  • sudo yum remove[软件名]//yum卸载软件
  • sudo yum list//列出软件

(2) Install rzsz

Function : This tool can be used for Windows machines and remote Linux and installation via xshell transfer files

Insert picture description here

use
Insert picture description here
Insert picture description here

Two: Linux development tools-Vim editor

Foreword
Before writing C language programs, VS is often used. VS is a representative of IDE , which is an integrated development environment . It integrates many of the above functions, allowing developers to only care about code writing operations without too much Taking into account other aspects, it is very convenient for users.

Just as why not use Python to implement data structures, because Python is too encapsulated, and it is not convenient for us to grasp these details in a deeper level. Therefore, IDE is indeed very convenient, but this kind of convenience is not conducive to our in-depth understanding of computers, understanding of program compilation and so on. For example, everyone knows that the main function has two parameters, but why there are two parameters, many people can not answer. However, these questions will be answered one by one in Linux programming.

To write C language or other languages ​​in Linux, you can install an integrated development environment similar to VS, but we deliberately make these functions independent. Write code using the vim editor, compile code using gcc / g ++ compiler, use gdb debugger, etc. when debugging code .

(1) Create file

After installing vim, type in the terminal vimto open the vim editor and
Insert picture description here
use it directly vim [文件名], you can create a file and write it. But it is not recommended to do this. Create directories and files before writing the code, and then open the existing files for writing

(2) Three basic modes

Vim is a multi-mode editor with 12 modes in total, of which the following three modes are mainly used

  • Command mode: Just after entering, you will find that any character input will not be echoed, because you are in command mode at this time
  • Insert mode: Only in insert mode can you enter text input, press ito enter insert mode, press ESCto return to command mode
  • Last line mode: The last line mode can be used to save and exit files. Enter in command mode to enter this mode

1:
Three ways to enter insert mode After opening a file with vim, you can enter insert mode in three ways, with slight differences

the way description
i The cursor is in its original position and will not move
a Cursor backward
O Cursor to the next line

2: How to return to command mode
Press ESCto return to command mode
3: How to enter the last line mode After
switching to the command mode, enter it to enter the last line mode. Save, exit and other operations can be performed in the last line mode. Enter when you need to save, and enter when you w!need to exit q! , Save and exit then enter wq!. as follows:
Insert picture description here

(3) Vim command mode instruction set

Note the following commands, you must command mode operation in

A: Copy and paste

1: Copy and paste a single line

  • Press yyto copy the line where the cursor is to the buffer
  • Press pto paste the characters in the buffer to the next line of the line where the cursor is

2: Copy and paste multiple lines

  • Input nyy, copy n lines
  • Type np, paste n lines

B: delete

1: Delete a row

  • Input ddmeans to delete the line where the cursor is

2: Cut

  • After the input is dddeleted, and then input in a certain line p, the cutting function can be realized

3: Delete multiple lines

  • Input ndd, you can delete n lines (multiple lines can also be cut)

4: Delete characters

  • Input x, delete the character under the cursor, input one at a time
  • Input nx, delete the n characters at and after the cursor position
  • Enter X, delete the previous character at the cursor position
  • Input 3X, delete the cursor position and the previous n characters

C: cursor movement

1: Up and down positioning of the cursor

  • Enter ggto position the cursor to the beginning
  • Enter Gto position the cursor to the end
  • Enter nGto position the cursor to the nth line

2: Left and right positioning of the cursor

  • Enter $, position the cursor to the end of the line
  • Type ^, position the cursor to the beginning of the line
  • Type w, position the cursor to the first letter of the next word in the line
  • Type b, position the cursor to the first letter of the word on the line

3 : hjkl

  • Type h, move the cursor forward to the previous character
  • Type j, move the cursor down to the next line
  • Type k, move the cursor up to the previous line
  • Type l, move the cursor backward to the next character

D: Withdraw

  • Input umeans to undo the last operation
  • Input ctrl+rmeans reorganization

E: Other

1: Case conversion

  • Enter shift+~to switch the letter under the cursor between uppercase and lowercase

(4) Vim last line mode command set

Note that the following command would all be in the last line mode carried out under

A: Find

  • Enter /[查询关键字], you can find all matching keywords, then highlight them, press and hold ndown to switch among keywords

B: Set line number

  • Enter the set nucalling line number

C: Cross file operation

1: Split screen

  • Input vs[文件名](if it is not created automatically, you can split the screen)
    Insert picture description here

2: Switch window

  • In command mode , type ctrl+w+w(double-click w) to switch back and forth in the open window

Guess you like

Origin blog.csdn.net/qq_39183034/article/details/113090908