Vim Operation Shallow Solution

Source: Internet
Author: User
Tags exit in

Vim is a more powerful, full-screen text editor than VI. Vim has three modes during its work: edit mode, insert mode, and last line mode.

Edit mode (default): Also known as the command mode, its work includes moving the cursor, cut, paste, delete input mode: Also known as insert mode, mainly in the file to modify the text content of the last line mode: Also known as the Extended command mode, mainly the implementation of vim built-in command

Vim three modes of switching between: such as 650) this.width=650; "src=" Http://i.imgur.com/3QDsVI2.png "style=" margin-top:0px;margin-right:0px; margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px; border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px, "alt=" 3QDsVI2.png "/ >

(1) Edit mode--Input mode

I: Enter I at the cursor: Enter a at the beginning of the line where the cursor is located: Enter a: At the end of the line where the cursor is located enter O: Opens a new line below the line where the current cursor is located o: Opens a new row above the line where the current cursor is located

(2) Input mode----> Edit mode

Press the ESC key

(3) Edit mode----> last line mode

: (colon)

(4) Last-line mode----> Edit mode

Press the ESC key
1, the basic operation of VIM (1) VIM syntax is its common choice
vim [options] [File ...] Option:-b: Open file in binary-D: followed by multiple files to open and compare multiple files-m: Open file as read-e: Directly into the last line mode
(2) Open file
+#: Indicates that the cursor is placed directly at the beginning of line # after opening the file +/pattern: After opening the file, the cursor is immediately at the beginning of the first line that is matched to the PATTERN: Vim ' +/uuid '/etc/fstab+: After opening the file, the cursor is in the last line of the file
(3) Exit file 1) exit in last line mode
: Q indicates exit: q! Indicates forced exit: Wq means save exit: X means save exit: W/path/to/somefile does not quit, but saves the file to the specified file
2) Edit mode exit
ZZ: Represents the Save Exit ZQ: Indicates that exit is not saved
(4) Cursor movement (in edit mode) 1) move between characters
H: Move one character to the left at a time J: move one character at a time K: Move up one character at a time L: (lowercase L) move one character to the right at a time. You can also use #+{h,j,k,l} to move several characters, such as "3h" to move 3 characters to the left
2) Move between words
W: Move to the beginning of the next word e: Move to the ending of the current or next word B: Move to the first word of the current or next word #+{w,e,b} indicates the first (ending) of a word that moves to the nth character
3) movement within the current page
H: Moves to the beginning of the first line of the current page m: moves to the beginning of the middle row of the current page L: Moves to the end of the last line of the current page
4) in-line movement
^: jumps to the first non-whitespace character at the beginning of the current line 0: jumps to the beginning of the current row (absolute beginning) $: jumps to the end of the current line
5) Moving between rows
G: Jump to the beginning of the last line of the file 1G (GG): Jump to the beginning of the first line of the file #g: Jump to the beginning of the specified # line
6) Move between sentences (divided by a blank line)
): Move down one sentence (: Move up one sentence
7) Move between paragraphs (with a blank line to divide # # # # # # # # #
{: Move down a paragraph}: Move up a paragraph
(5) Flip screen operation
CTRL+F: Flip a screen to the end of the file ctrl+b: turn to the file header ctrl+d: Half-screen to the end of the file Ctrl+u: half-screen to the file header
2. Vim's edit Mode command (1) Character deletion
X: Delete the character at the cursor #x: Delete the # character at the beginning of the cursor D: delete (cut) command, you need to use the cursor to move the character (w/b/e/$/0/^, etc.) such as: "d$" means the deletion of the cursor after the content, "3DW" Represents the 3 words after the cursor is deleted DD: Delete the line where the cursor is located D: from the current cursor position to the end of the line, the equivalent of D$XP: The position of the character where the swap cursor is located and its following characters ~: Conversion case
(2) Character substitution
R: Replace the character at the cursor, only one character at a time R: Switch to replace mode, can be replaced by characters
(3) Copy
Y: Copy command, can be combined with the cursor to move characters using (w/b/e/$/0/^, etc.) such as: "Y0" means the copy cursor at the beginning of the content, "0y$" represents the entire row. YY: Copy entire line #yy: one copy # line
(4) Paste (with D or y command)
P: (lowercase) If copied to an entire row, paste the copied content below the current cursor line, or paste the copied content at the end of the current cursor if you copied the contents of the line. P: (uppercase) If copied to an entire row, paste the copied content above the line where the current cursor is located If you copy a portion of a line, paste the copied content in front of the current cursor
(5) Modify, that is, first delete in the input mode
C: Modify the command, can be combined with the cursor to move characters using (w/b/e/$/0/^, etc.) cc: Delete the current line and enter new content C: Delete the current cursor to the end of the line and switch to insert mode
(6) Undo and redo Operations
U: Undo Recent changes, undo only one action at a time #u: One undo # Action Ctrl+r: Undo the last undo operation.: Repeat the previous action N.: Repeat the first n actions
(7) Other editing operations 1) visualization mode
V: Select by character V: Select Ctrl + v. by row: SELECT by block
2) input n times the same content at a time, example shows
100iwang [ESC]: Enter 100 first, enter I, then enter Wang, and finally press ESC, which means 100 Wang characters are entered
3. Vim's last-line mode operation (remember ":") (1) Address bound
1) #: The specific # line, such as 2 for line 2nd, 2) #,#: From the left # indicates the start of the line, to the right # indicates the end of the line, such as 3,8 represents 3rd to 8th line 3) #,+#: The left # shows the start of the line, plus the right # represents the number of lines, such as 2,+3 2 to 5 : Current line 5) $: last line 6)%: Full text, equivalent to 1,$7)/pattern1/,/pattern2/: The first time the line that was matched by pattern1 pattern starts, until the end of the line that was first matched to the PATTERN2 8) w/path/to/ Somefile: Indicates that the contents of the range are saved to the specified file 9) R/path/from/somewhere: Indicates that the contents of the externally specified file are transferred into the specified location
(2) Find
/pattern: Look at the end of the file from the current cursor location? PATTERN: Looks up from the current cursor to the file header N: Previous, with command counter N: Next, same direction as command
(3) Find and replace
s///: Find and replace, delimiter can be customized such as: [Email protected]@@,s###. Format: s/What to look for/replace with content/modifiers to find: what you can replace with: you can't use patterns, but you can use \1, \2, ... You can also use the "&" reference to the content modifier found when you first looked up: I: Ignore case g: global substitution; By default, each row replaces only the one match to the GC: global substitution, asking before each replacement
4. Vim register (in edit mode)
1) There are 26 named registers and 1 unnamed registers, often hold different contents of the Clipboard, can be shared between different sessions 2) 26 named registers are corresponding to 26 letters one by one, with a, b,..., z, denoted by "letter register, placed between the number and the command, such as" 3 "Ayy" means replication 3 Row to a register, "AP" means to paste 3 of the contents of the a register to the next line at the cursor 3) does not specify a name, will use a non-named register, directly using 3yy can be copied 4) There are 10 digital registers with 0,1,...,9, 0 to store the most recently copied content, 1 to store the most recently deleted content. When the new text is changed and deleted, 1 is dumped to 2, 2 to 3, and so on. Digital registers cannot be shared between different sessions.
5. Open multiple Files
Vim FILE1 FILE2 FILE3 ... Switching between files: (in edit mode): Next jumps to the next file: Prev jumps to the previous file: first jumps to file: Last jumps to the final file: Wall saves all files but does not exit: Qall exit All Files: Wqall Save and exit all Thing
6, Multi-window mode (1) Multi-file segmentation
Vim-o |-o FILE1 FILE2 FILE3 ...-o: Horizontal split-o: Vertical split ctrl+w Toggle Window
(2) Single File segmentation
Ctrl+w,s:split, horizontal split () ctrl+w,v:vertical, vertical split ctrl+w,q: Cancel adjacent window ctrl+w,o: Cancel all windows: Wqall exit
7. Custom Vim's working characteristics (1) Auto Indent
Enable: Set AI disable: Set Noai
(2) Highlight Search
Enabled: Set Hlsearch disabled: Set Nohlsearch
(3) syntax highlighting
Enable: Syntax on disable: syntax off
(4) Ignore character case
Ignore: Set IC does not ignore: set Noic
(5) Set line number
Display: Set NU does not display: Set Nonu
(6) pairs of parentheses match
Enable: Set SM disable: Set NOSM
(7) configuration file (to make custom features permanent)
Global Settings:/ETC/VIMRC personal settings: ~/.VIMRC
(8) file format
Enable UNIX format: Fileformat=unix enable DOS format: fileformat=dos### (9) Set text width ###:set textwidth=65:set wrapmargin=15
8. Exercise (1) How to set the tab indent to 4 characters
In the last line mode input: Set ts=4, if you want to permanently take effect can write to the configuration file

650) this.width=650; "src=" Http://i.imgur.com/aMl4qNg.png "style=" margin-top:0px;margin-right:0px;margin-bottom:0 px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;border-top-width:0px; border-right-width:0px;border-bottom-width:0px;border-left-width:0px; "alt=" Aml4qng.png "/>

(2) Copy the/etc/rc.d/init.d/functions file to the/tmp directory, replace the/etc/sysconfig/init in the/tmp/functions file with the/var/log;
Input in last line mode:%[email protected]/etc/sysconfig/[email protected]/var/[email protected]

650) this.width=650; "src=" Http://i.imgur.com/5BRtJDH.png "style=" margin-top:0px;margin-right:0px;margin-bottom:0 px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;border-top-width:0px; border-right-width:0px;border-bottom-width:0px;border-left-width:0px; "alt=" 5brtjdh.png "/>

(3) Delete the # Number of all lines beginning with # in the/tmp/functions file, with at least one white space character followed by #;
In the last line mode input:%[email protected]^#[[:space:]]\[email protected]@g
(4) Replace All enable=0 in the/etc/yum.repos.d/centos-base.repo file with enable=1, all gpgcheck=0 replaced by gpgcheck=1;
In the last line mode input:%[email protected]\ (enabled\|gpgcheck\) [email protected]\[email protected]


This article is from the "Learn Linux for Beginners" blog, please make sure to keep this source http://kop309.blog.51cto.com/9034739/1836662

Vim Operation Shallow Solution

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.