[Linux] package manager yum and environment development tool vim

【Linux】series article directory

[Linux] Basic common commands: http://t.csdn.cn/hwLPb

[Linux] Basic permissions: http://t.csdn.cn/faFZg


Table of contents

foreword

1. The package manager yum

1. What is a software package? 

2. Use of yum

(1) Package file query

(2) Installation       

(3) Uninstall

Two, Linux development tool vim

​edit

1. The basic concept of vim

 2. Basic operation of vim

(1) enter vim

(2) Switch from [Normal Mode] to [Insert Mode]

(3) Switch from [Insert Mode] to [Normal Mode]

(4) Switch from [Normal Mode] to [Last Line Mode]

3. vim normal mode command set

(1) Move the cursor

(2) Delete text

(3) Copy and paste

(4) replace

(5) Undo the last operation

(6) change

4. vim last line mode command set

(1) List line numbers

(2) split screen

(2) Find characters

 5. Simple vim configuration

at last


foreword

Learn the yum tool, install software, master the use of the vim editor, and learn the simple configuration of vim 


提示:以下是本篇文章正文内容,下面案例可供参考

                

1. The package manager yum

1. What is a software package? 

        A common way to install software under Linux 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 and make it into a software package (which can be understood as an installer on windows) and put it on a server. This compilation can be easily obtained through the package manager. Good 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. Use of yum

(1) Package file query

Use the format:

    yum list|grep xxx

Function: Through the yum list command, you can list the current software packages. Since the number of packages may be very large, here we need to use the grep command followed by keywords to filter out only the packages we care about.

Example: You can enter the yum list command yourself to display all current software packages

 

Precautions:

  • 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" means the version of the operating system distribution. el7" means centos7/redhat7. "el6" means 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"

(2) Installation       

  • yum install xxx Install xxx, the system will ask if you agree to the installation,

Enter y if you agree, and n if you disagree. The word "complete" appears, indicating that the installation is complete.

  •     yum -y install xxx The system does not ask, download and install xxx directly

 

Precautions:

        When installing the software, it is necessary to write content to the system directory, which generally requires sudo or switching to the root account to complete. The yum installation software can only install one after the other is installed. In the process of installing a software with yum, if you try to install another software with yum, yum will report an error.

(3) Uninstall

  • yum remove xxx Delete xxx The system will ask if you agree to delete xxx, if you agree, enter y, if you disagree, enter n
  • Yum -y remove xxx The system does not ask, delete xxx directly

Two, Linux development tool vim

1. The basic concept of vim

        The difference between vi/vim To put it simply, they are all multi-mode editors , and each mode can be switched between each other . 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. inside. For example, syntax highlighting and visualization operations can be run not only on the terminal, but also on x window, mac os, and windows.

        There are three modes of vim (in fact, there are many modes, and you can master these three at present), which are command mode, insert mode and last line mode. The functions of each mode are distinguished as follows:

  • Normal/Normal/Command mode (Normal mode): Control the movement of the screen cursor, delete characters, words or lines, move and copy a certain segment and enter Insert mode, or go to last line mode
  • Insert mode (Insert mode): Only in Insert mode, text input can be done, press the "Esc" key to return to the 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: help vim-modes

 2. Basic operation of vim

 case:

 The following steps describe the implementation of the case shown in the figure above.

(1) enter vim

       After entering vim and the file name at the system prompt, it will enter the vim full-screen editing screen: $ vim test1.c

 Pay special attention, that is, after you enter vim, you are in [normal mode] and cannot enter any content. You have to switch to [insert mode] to be able to enter text.

(2) Switch from [Normal Mode] to [Insert Mode]

       Type i (at current location)

           or o (on a new line)

           or a (move one character backward)

           or s (delete a character)

  At this point, you can enter what you want to enter

input content

(3) Switch from [Insert Mode] to [Normal Mode]

       Currently in [Insert Mode], you can only enter 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 press the "ESC" key to enter [Normal Mode] and then delete Word. Of course, it can also be deleted directly.

 

(4) Switch from [Normal Mode] to [Last Line Mode]

"shift + ;", actually input ":" to exit vim and save the file, in [normal mode], press the ":" colon key to enter "Last line mode"

 

             : w                        save current file
             : q                        Exit vim without saving
             : wq                        Enter "wq", save and exit vim
             : q!                        Enter q! to force quit vim without saving
             : wq!

                       Force save and exit vim

3. vim normal mode command set

(1) 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 format, refer to the vim keyboard map.
  • Press [shift+g] or "G": move to the end of the article
  • "#G": For example, "15G", means to move the cursor to the beginning of the 15th line 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 "b": the cursor returns to the beginning of the previous word
  • "#w", "#b": according to the word as a unit, move forward and backward, w backward, b forward
  • Press "e": the cursor jumps to the end of the next word
  • Press [gg]: go to the beginning of the text
  • Press "ctrl" + "b": move the screen to "back" by one page
  • Press "ctrl" + "f": the screen moves "forward" by one page
  • Press "ctrl" + "u": the screen moves half a page "backward"
  • Press "ctrl" + "d": the screen moves half a page "forward"

(2) 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": delete the line where the cursor is located

"#dd": Delete # line from the line where the cursor is located

(3) Copy and paste

"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.

"#p": For example, "6p" pastes the same content of 6 lines below the line where the current cursor is.

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

(4) replace

"r": Replace the character where the cursor is located.

"R": Replacement mode, replace the character where the cursor is, until the "ESC" key is pressed.

(5) Undo the last operation

"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

(6) change

"cw": Change the word where the cursor is to the end of the word

"c#w": For example, "c3w" means change 3 characters

 Precautions:

  • If you don't know what mode you are in, keep pressing the "Esc" key without thinking
  • When exiting, generally save first and then exit
  • When operating in vim, try not to use the mouse and mouse wheel

4. vim last line mode command set

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

(1) 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 the 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 Skip to line 15 of the article.

(2) split screen

"vs file": After entering "vs file", a split screen will appear.

 Press [ : ] to enter q to exit split screen. Under the vim split screen, wherever the cursor is, we will write which file.

Switch the cursor to a different interface, [ Ctrl ]+[ ww].

(2) Find characters

"/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.

Question: / and ? Find the difference between have and ? Operate it

 5. Simple vim configuration

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. Switch users to become yourself and execute su, enter your main working directory, and execute cd ~. Open the .vimrc file in your own directory,

Execute vim.vimrc .

(1) Configure by yourself (not recommended)

Commonly used configuration options for testing

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

(2) Automated configuration (currently only centos 7.X is supported)

Directly use the URL VimForCpp: Quickly build vim into a c++ IDE (gitee.com), enter the following page and follow the steps.


at last

       Happy time is always short. The above is what I want to talk about today. This article introduces in detail Xiao Zhao's preliminary understanding and use cases of the Linux package manager yum and the development tool vim. Family members are welcome to criticize and correct. Comrade Xiao Zhao continues to update, the motivation for continuous learning is the support of Baozi with one button and three consecutive links~

                                                     ​ 

Guess you like

Origin blog.csdn.net/weixin_70411664/article/details/131316046