【Linux Series P4】What does Linux need? editor? package? This article helps you understand and master [yum]&[vim]——basic development tools

foreword

  • Hello everyone, welcome to the YY drop Linux series, a warm welcome!
  • The main content of this chapter is for veterans who have never been in touch with Linux. The main content includes

Welcome to subscribe to the YY drop Linux column! More dry goods are continuously updated! The following is the portal! 

Subscribe to the column reading: YY 's "Linux" series❀❀❀❀❀
【Linux Series-P1】Building a Linux Environment
[Linux Series-P2] Basic knowledge and instructions of Linux
【Linux Series-P3】Linux Permissions
[Linux series-P4] Linux basic tools [yum] [vim]

Table of contents

1. Linux

Table of contents

1. Linux package manager yum

1. The concept of package and package manager yum

2. About rzsz

3. Check the package

4. Install the package 

5. Uninstall software command

6. Install and expand yum source 

2. Linux editor vim

1. Basic introduction to vi/vim

2.Three modes of vim

3. Basic operation/use of vim

1. Enter vim full screen editing screen

2. Diagram of the conversion of the relationship between the three modes 

3. Basic conversion of three modes 

4. Multi-file window cursor switching 

4. vim [normal mode] command set (comprehensive)

5. vim [last line mode] command set (comprehensive)

3. Simple vim configuration

1. The location of the configuration file

2. Common configuration options (test)

3. A set of [ultra-comprehensive configuration files] installation tutorial (lazy people must enter)

1. Linux package manager yum


1. The concept of package and package manager yum

  • To install software under Linux, a common method is to download the source code of the program and compile it to obtain an executable program.
  • But this is too troublesome, so some people compile some commonly used software in advance, make it into a software package (which can be understood as an installer on windows) and put it on a server, and this compilation can be easily obtained through the package manager Good software package, install it directly.
  • Packages and package managers are like the relationship between "App" and "App Store".
  • yum (Yellow dog Updater, Modified) is a very commonly used package manager under Linux . It is mainly used in distributions such as Fedora, RedHat, and Centos.

2. About rzsz

Realize the file exchange between windows system and Linux:

  • This tool is used to transfer files between windows machines and remote Linux machines through XShell. After installation, you can upload files by dragging and dropping

3. Check the package

  The current software packages can be listed through the yum list command. Since the number of packages may be very large, here we need to use  the grep command  to filter out the software packages we care about

Code display:

# yum list | grep lrzsz

The result will appear:

lrzsz.     x86_64      0.12.20-36.    el7        @base 

From the above results, we can interpret:

  • Software package name:    major version number.   Minor version number .   Source program release number - software package release number.   Host platform. CPU architecture .
  • The "x86_64" suffix indicates the installation package for the 64-bit system, and the "i686" suffix indicates the installation package for the 32-bit system. When selecting the package, it must match the system.
  • "el7" indicates the version of the operating system distribution. "el7" indicates centos7/redhat7. "el6" indicates centos6/redhat6.
  • In the last column, base indicates the name of "software source", which is similar to concepts such as "Xiaomi App Store", "Huawei App Store". 

4. Install the package 

Order:

# sudo yum install lrzsz

Precautions:

  • When installing software, because it needs to write content to the system directory, it usually needs sudo or cut to the root account to complete.
  • The yum installation software can only install one after the other is installed. In the process of yum installing a software, if you try to use yum to install another software, yum will report an error.
  • If yum reports an error, please Baidu 

5. Uninstall software command

Order:

# sudo yum remove lrzsz

6. Install and expand yum source 

The yum source is divided into [built-in yum source] and [extended yum source], among which the extended yum source needs to be installed by ourselves:

  • Expand the yum source installation command:
#yum install -y epel-realease

After installing the extended yum source, we can download two interesting packages:

  • car running
#yum install -y sl
#sl
  • Niu said
#yum install -y cowsay
#cowsay "yy"

2. Linux editor vim


1. Basic introduction to vi/vim

  • The difference between vi/vim To put it simply, they are both multi-mode editors . The difference is that vim is an upgraded version of vi. It is not only compatible with all commands of vi, but also has some new features in it. Such as syntax highlighting, visual operation. It can not only run on the terminal, but also run on x window, mac os, windows
  • Vim has a total of 12 total modes: open, close, view, query, insert, delete, replace, undo, copy and so on.

2.Three modes of vim

    There are many modes in vim, you only need to master these three at the basic stage, namely command mode, insert mode and last line mode. The functions of each mode are as follows:

  • Command mode (Normal mode) ———— Control the movement of the screen cursor, delete characters, words or lines, move and copy a section and enter [insert mode], or enter [bottom line mode]
  • Insert mode (Insert mode) ——— Only in Insert mode, text input can be done. In command mode, press [i] to enter Insert mode, and press "ESC" to return to command line mode. This mode is the most frequent editing mode we will use later
  • Last line mode (last line mode) —— save or exit the file, you can also perform file replacement, find strings, list line numbers and other operations. In command mode, shift+: to enter this mode . To view all your modes: open vim, enter the bottom line mode directly

  A list of vim three mode relationship diagrams:


3. Basic operation/use of vim


1. Enter vim full screen editing screen

  • Enter vim, enter vim and the file name at the system prompt symbol , and enter the vim full-screen editing screen :
  • $ vim test.c
  • But one thing to pay special attention to is that after you enter vim, you are in [command mode], you have to switch to [insert mode] to be able to enter text.

2. Diagram of the conversion of the relationship between the three modes 

A list of three mode conversion diagrams:


3. Basic conversion of three modes 

Switch from [Normal Mode] to [Insert Mode] 

  • input a
  • input i
  • input o

Switch from [Insert Mode] to [Normal Mode]

  • Currently in [Insert Mode], you can only input text all the time. If you find that you have entered a wrong word and want to use the cursor keys to move back and delete the word, you can first press the "ESC" key to enter [Normal Mode] and then delete Word. Of course, it can also be deleted directly.

[Normal Mode] switches to [Last Row Mode] 

  • "shift + ;", actually input ":"

Exit vim and save the file. In [Normal Mode], press the ":" colon key to enter "Last line mode", for example:

  • :w (save current file)
  • : wq (enter "wq", save and exit vim)
  • : q! (Enter q!, force exit vim without saving)

4. Multi-file window cursor switching 

  • "ctrl" + "ww": multi-file window cursor switching

4. vim [normal mode] command set (comprehensive)

Insert mode:

  • Press "i" to switch to insert mode "insert mode" , and press "i" to enter insert mode to start inputting files from the current position of the cursor;
  • After pressing "a" to enter the insert mode, the text will be entered from the position next to the current cursor position;
  • After pressing "o" to enter the insert mode, a new line is inserted, and text is entered from the beginning of the line.

 Switch from insert mode to command mode:

  • Press the "ESC" key.

 Move the cursor:

  • Vim can directly use the cursor on the keyboard to move up, down, left, and right, but regular vim uses lowercase English letters "h", "j", "k", and "l" to control the cursor to move left, down, up, and right by one grid
  • Press "G": move to the end of the article
  • Press "$": Move to the "end of line" of the line where the cursor is located
  • Press "^": Move to the "beginning" of the line where the cursor is located
  • Press "w": the cursor jumps to the beginning of the next word
  • Press "e": the cursor jumps to the end of the next word
  • Press "b": the cursor returns to the beginning of the previous word
  • Press "#l": the cursor moves to the #th position of the line, such as: 5l, 56l
  • Press [gg] : go to the beginning of the text
  • Press [shift+g] : enter the end of the text
  • Press "ctrl" + "b": the screen moves one page to the "back" Press "ctrl" + "f": the screen moves one page to the "front"
  • Press "ctrl" + "u": the screen moves half a page "backward" Press "ctrl" + "d": the screen moves half a page "front"
  • "ctrl" + "ww": multi-file window cursor switching

Delete text:

  • "x": Each time you press, delete a character at the cursor position
  • "#x": For example, "6x" means to delete the 6 characters "behind (including yourself)" where the cursor is located
  • "X": uppercase X, each time you press it, delete a character "in front" of the cursor position
  • "#X": For example, "20X" means to delete the "before" 20 characters where the cursor is located
  • "dd": cut / delete the line where the cursor is located
  • "#dd": Delete # line from the line where the cursor is located

copy:

  • "yw": Copy the characters from the cursor position to the end of the word into the buffer.
  • "#yw": copy # words to the buffer
  • "yy": Copy the line where the cursor is located to the buffer.
  • "#yy": For example, "6yy" means to copy 6 lines of text "counting down" from the line where the cursor is located.
  • "p": Paste the characters in the buffer to the position of the cursor.

Note: All copy commands related to [y] must cooperate with [p] to complete the copy and paste functions. 

replace:

  • "r": Replace (that is, overwrite ) the character at the cursor position.
  • "R": Replace the character where the cursor is, until the "ESC" key is pressed. 

PS: "shift" + "R" to enter [the fourth mode]: replace the content as a whole

Undo the last action:

  • "u": If you execute a command by mistake, you can immediately press "u" to return to the previous operation. Multiple restores can be performed by pressing "u" multiple times.
  • "ctrl + r": undo redo (undo previous undo)

Change:

  • "cw": Change the word where the cursor is to the end of the word
  • "c#w": For example, "c3w" means change 3 characters 

Jump to the specified line:

  • "ctrl" + "g": List the line number of the line where the cursor is located.
  • "#G": For example, "15G", means to move the cursor to the beginning of the 15th line of the article. 

Case conversion:

  • 「shift」+「~」: case conversion

5. vim [last line mode] command set (comprehensive)

Note: Before using the end-line mode, please remember to press the "ESC" key to confirm that you are in the normal mode, and then press the ":" colon to enter the end-line mode.

list line numbers

  • "set nu": After entering "set nu", the line number will be listed in front of each line in the file.

 jump to a line in a file

  • "#": "#" means a number, enter a number after the colon, and then press the Enter key to jump to the line. For example, enter the number 15, and then press Enter, it will jump to the 15th line of the article .

 find character

  • "/Keyword": Press the "/" key first, and then enter the character you want to find. If the keyword you find at the first time is not what you want, you can keep pressing "n" to find the key you want later up to the word.
  • "? Keyword": Press the "?" key first, and then enter the character you want to find. If the keyword you find for the first time is not what you want, you can keep pressing "n" to find the key you want up to the word.

 save document

  • "w": Enter the letter "w" in the colon to save the file

 leave vim

  • "q": Press "q" to quit.If you can't leave vim, you can force to leave vim with a "!" after "q".
  • "wq": It is generally recommended to use it together with "w" when leaving, so that the file can be saved when exiting.

3. Simple vim configuration


1. The location of the configuration file

  • Under the directory /etc/, there is a file named vimrc , which is a public vim configuration file in the system and is valid for all users.
  • And in each user's home directory, you can create your own private configuration file , named: ".vimrc". For example, under the /root directory, there is usually a .vimrc file, and if it does not exist, it will be created.
  • Execute [su] to switch users to become yourself, and execute [cd ~] to enter your main working directory
  • Execute [vim .vimrc] to open the .vimrc file in your own directory
  • Generally, one common user has one configuration file, which will not affect each other; try not to configure root ;

2. Common configuration options (test)

  • Set syntax highlighting: syntax on
  • Show line number: set nu
  • Set the number of spaces for indentation to 4: set shiftwidth=4

3. A set of [ultra-comprehensive configuration files] installation tutorial (lazy people must enter)

a) Baidu search 'VimForCpp'

 b) Be careful not to execute directly under root!

c) Copy completely, pay attention [must be a complete line]

d) When the following interface appears, it means success

 e) Copy and paste manually

 f) Enter vim code.c/other files; Done!

Guess you like

Origin blog.csdn.net/YYDsis/article/details/130791876