In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to use the vim program editor in linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Enter: wq in command mode to save away, enter: wq! Indicates that you are forced to write and leave, provided that your permissions can be changed.
List of buttons in general mode:
Method of moving the cursor h or ← the cursor moves one character j or ↓ cursor down one character k or up arrow key (↑) cursor moves one character l or right arrow key (→) cursor moves one character to the right if you put your right hand on the keyboard, you will find that the hjkl is arranged together So you can use these four keys to move the cursor. If you want to do it multiple times, for example, move 30 lines down, you can use the combination button of "30j" or "30 ↓", that is, add the number of times you want to do, and press the action! The [Ctrl] + [f] screen "moves down" one page, which is equivalent to [Page Down] button (commonly used) [Ctrl] + [b] screen "move up" one page Equivalent to [Page Up] key (commonly used) [Ctrl] + [d] screen "move down" half page [Ctrl] + [u] screen "move half page + cursor moves to the next column of non-blank characters-the cursor moves to the previous column of non-blank characters n that n represents" number ", for example, 20. Press the number and then press the blank key, and the cursor will move n characters of the line to the right. For example, a 20 cursor moves 20 characters back. 0 or ^ or function key [Home] this is the number "0": move to the foremost character of this line (commonly used) $or function key [End] to the last character of this line (commonly used) the H cursor moves to the first character M of the top line of this screen, the first character L of the central line of this screen moves to the bottom of this screen. The first character G of that line is moved to the last line of the file (commonly used) nGn as a number. Move to line n of this file. For example, 20g will be moved to line 20 (match: set nu) 1G or gg will be moved to line 1 (commonly used) nn of this file is a number. Move the cursor down n lines (commonly used) to search and replace / word to look under the cursor for a string called word. For example, to search for the string yidao in a file, type / yidao! Word looks over the cursor for a string with the name word. N this n is the lowercase key n in English. Stands for "repeat the previous search action". For example, if we just executed / yidao to search down for the string yidao, then pressing n will continue the search for the string named yidao. If you are executing yidao, pressing n will continue to search for the string named yidao! N this N is the English capital key N. In contrast to n, perform the previous action for "reverse". For example, after / yidao, pressing N means "up" to search for yidao. Using / word with n and N is very helpful! It allows you to repeatedly find some of your search keywords! The numbers N1 and N2 are the numbers, n1jjn2sqqpxxxxxxxxxx. Look for the string word1 between lines N1 and N2 and replace the string with word2! For example, search for yidao between 100 and 200 lines and replace it with YIDAO:
": 100200s/yidao/YIDAO/g" (commonly used): 1 find the word1 string from the first line to the last line and replace the string with word2! (commonly used): 1 word1 word1 look for the string from the first line to the last line, and replace the string with Word2GCC! The user will be prompted whether the message should be replaced before each replacement! Delete, copy, paste x, X in one line, x deletes one character backward (equivalent to [del] key), X deletes one character forward (equivalent to [backspace], that is, backward key) (commonly used) nxn is a number, deletes n characters in a row. For example, I want to delete 10 characters in a row, "10x". Dd removes the line where the cursor is located (usually) nddn as a number. Delete the cursor where the downward n column, for example, 20dd is to delete 20 lines (commonly used) d1G delete cursor to the first line of all data dG delete cursor to the last line of all data d$ delete cursor, to the last character D0 that is the number of 0, delete cursor place, to the first character of the line yy copy cursor where the line (commonly used) nyyn is a number. Copy the downward n line where the cursor is located, for example, 20yy is to copy 20 lines (commonly used) y1G copy all the data from the line of the cursor to the first line, copy all the data from the line where the cursor is located to the last line, copy all the characters from the beginning of the cursor to all the characters at the beginning of the line, $copy the characters at the end of the line, and Pp paste the copied data on the next line of the cursor. P is pasted on a line above the cursor! J merges the cursor row and the next row of data into a row c repeatedly deletes multiple data, such as deleting 10 rows down, [10cj] u restores (undo) the previous action. (commonly used) [Ctrl] + r redo the last action. This u and [Ctrl] + r are very common instructions! One is to restore, the other is to redo ~ use these two function buttons, your editor, hey! It was fun! . No doubt, this is the decimal point! It means to repeat the previous action. If you want to delete, paste, etc., press the decimal point. "that's it! (commonly used)
= Block selection (Visual Block) =
Block selection button description v character selection, will be the cursor over the place to select the V line selection, will the cursor over the line anti-white selection! [Ctrl] + v column selection mode y copies the highlighted area d deletes the highlighted area
= multi-file editing
You can use vim file1 file2 to open multiple files and edit them at the same time, three commands for multiple files:
Key for multi-file editing: n edit next file: n edit previous file: files lists all files currently opened by this vim
= multi-window function =
Enter: sp [filename] in command mode to open the filename file in a new window. If you do not enter filename, the current file will be cut into two by default.
Window toggle:
* ctrl+w+j moves the cursor to the next window
* ctrl+w+k moves the cursor to the previous window
* ctrl+w+q actually means: Q ends leaving
= vim environment settings: ~ / .vimrc, ~ / .viminfo====
Have you found that if we use vim to find the contents of a file, and then open it again, the found string will still be highlighted. In addition, the number of lines in our cursor is also the number of lines the last time you turned off vim, which is recorded through the ~ / .viminfo file. Equivalent to the history file edited by vim, the history of your editing is basically recorded in it. It's automatically generated. O (╯□╰) o
The configuration file of vim is / etc/vimrc, but it is not recommended to modify it, because it is the default configuration file common to all users. If you want to have your own configuration file, you can modify ~ / .vimrc. This file is not available by default. You can manually create one and write your own personalized settings:
The code is as follows:
[root@www] # vim ~ / .vimrc
"the double quotation marks (") of this file are comments.
Set hlsearch "High brightness reflection"
"set backspace=2" can be deleted with the Backspace key
Set autoindent "auto indent
"set ruler" displays the status of the last line
Status of the line in the lower left corner of "set showmode"
Set nu "can display the line number at the front of each line!"
"set bg=dark" shows different background tones
The "syntax on" syntax is highlighted.
= DOS and linux line break characters =
The dos line break character is CR (carriage return) and LF (line feed), while linux has only one character LF (line feed). If the dos and windows systems need to interact with linux systems for files, they need to be converted.
Command:
# dos2UNIX [- kn] file [newfile]
# UNIX2dos [- kn] file [newfile]
-k: the mtime time the file is retained
-n: keep the old file and input the converted content into the new file newfile
= language transcoding =
# iconv-list
# iconv-f original code-t new code filename [- o newfile]
Example analysis: convert traditional Chinese utf8 into simplified Chinese utf8 code:
# iconv-f utf8-t big5 vi.utf8 | iconv-f big5-t gb2312 | iconv-f gb2312-t utf8-o vi.gb.utf8
The above is all the contents of the article "how to use the vim Program Editor in linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.