Vim Common Nerdtree shortcut keys

Source: Internet
Author: User
Tags closure control characters current time manual exit in lowercase parent directory ranges

Switch workbench and Table of contents

CTRL + W + H cursor focus left tree directory
CTRL + W + L cursor focus right file display window
CTRL + W + W cursor automatically switch to left right window
CTRL + W + R to move the layout position of the current window

o Open a file, directory, or bookmark in an existing window and skip to the window
Go opens a file, directory, or bookmark in an existing window, but does not jump to the window
T opens the selected file/bookmark in the new tab and jumps to the new tab
T Opens the selected file/bookmark in the New tab, but does not jump to the new tab
I split a new window opens the selected file and jumps to the window
GI Split a new window opens the selected file, but does not skip to the window
s vsplit a new window opens the selected file and jumps to the window
GS vsplit A new window opens the selected file, but does not jump to the window
! Execute current File
O recursively open all directories under the selected node
X closes the parent directory of the selected node
X recursive closure Select all directories under the node
e Edit the current dif
Double-click equals Nerdtree-o
The middle key to the file is equivalent to Nerdtree-i, to the directory equivalent to NERDTREE-E
D Delete the current bookmark
P jumps to the root node.
P Jumps to parent node
K jumps to the first node of the same sibling in the current directory
J jumps to the last node of the same sibling in the current directory.
K jumps to the previous node of the same sibling in the current directory
J jumps to the last node of the same sibling in the current directory.
C set the parent directory of the selected directory or selected file as the root node
U sets the parent directory of the current root node to the root directory and becomes the closure root node.
U set the parent of the current root node to the root directory, but keep expanding the original root node
R Recursive Refresh selected directory
R Recursive flush root node
m Display file System menu
CD sets CWD to the selected directory
I toggle whether to show hidden files
F switch whether to use file filters
F Toggle whether to display files
B toggle whether to show bookmarks
Q Close Nerdtree window
? Toggle whether to show Quick help

Toggle tab Page

: tabnew [++opt option] [+cmd] file creates a new tab for the specified file
: TABC Closes the current tab
: Tabo Closes all other tab
: Tabs View all open tab
: TABP before a tab
: Tabn After a tab
In standard mode:
GT before a tab
GT after a tab
Macvim can also use shortcut keys to complete the tab closure, switching
Cmd+w Closes the current tab
cmd+{before a tab
cmd+} after a tab

Common configurations for Nerdtree in. VIMRC

"The default is to open Nerdtree when Vim is started (Autocmd can be abbreviated as AU)
Autocmd Vimenter * Nerdtree
"Press F2 to pull/hide Nerdtree
map:silent! Nerdtreetoggle
"Sets the Nerdtree window to the right of the Vim window (left by default)
Let nerdtreewinpos= ' right '
"Automatically displays the Bookmarks when the Nerdtree window is open
Let Nerdtreeshowbookmarks=1


V. Finding replacements
/pattern search back for string pattern

? pattern forward Search string pattern

"\c" ignores case

"\c" Case sensitive
N Next match (if yes/search, then down next,? Search is next up)
N prev Match (IBID.)
:%s/old/new/g searches the entire file and replaces all old with new
:%S/OLD/NEW/GC searches the entire file, replaces all old with new, and each time you confirm whether to replace

Six, Exit editor
: W writes the buffer to the file, which saves the modification
: Wq Save changes and exit
: x Save changes and exit
: Q Exits, if the buffer has been modified, you will be prompted
: q! Force exit, Discard changes

Keyboard movement (move)

Everything is moving from the keyboard
K-> Up
J-> Down
H-> Left
L-> Right
Z-> the screen, and the current cursor changes to the first line of the screen (redraw at the top of window)
Ctrl-f-> jumps to the next page (Page down)
Ctrl-b-> Skip to previous page (page UP)
Jump Command (jumps)

Jump instruction similar to < forward >< back > button in the browser
CTRL]-> follow Link/tag transfer (follow Link/tag)
Ctrl-o-> back to the last jump (go)
Ctrl-i-> jumps back to the next (go forward)
: Ju-> shows all the places that can jump (print Jump List)
Redo/Reply

U-> Undo
Ctrl-r-> Redo
Vim's undo is a tree structure, you can go back to any place in this structure
: Undo 2-> Undo to 2 layer of structure (undo to Tree 2)
: Undolist-> Displays all Undo lists (show undo list)
: Earlier 10s-> undo to 10 seconds ago edit (undo to ten seconds ago)
: Earlier 10h-> undo to 10 hours ago edit (back to ten hours ago)
: Earlier 1m-> undo to 1 minutes ago (back to 1 minutes ago)
Here is an explanation of the tree structure of undo
... one.. one
........ |
... change 1.
........ |
... one too.
.......... /........\
... change 2 .... Change 3.
..... | .............. |
... one two .... me too?.. me.
........... |
..... Change 4
.... |
... not two
Visual mode (visual)

v-> into visual mode
Can be used as block editor in Visual mode
Ctrl-v-> Visual block
Printing (print)

: hardcopy-> Print content in vim (print text)
Mixed visual mode (visual) can select the area to print
I haven't tried it. can be printed directly to the value (should be possible) For example: 1,15hardcopy print the first 15 lines
Write a file in Web page format (HTML)

: Source $VIMRUNTIME/syntax/2html.vim-> Change current open file to HTML
Formatting (format)

Dos/windows and Unix/linux for the end of the file is not the same. Vim can set/change format directly
Paper Order: Set Fileformats=unix,dos can change the format of the file (changing format)

: Set Ff=unix-> files into UNIX format (set file in UNIX format)
: Set Ff=dos-> set file into DOS format (set in DOS form)
: Set FF? -> Check the current file format (check the format of
If you change the format, Direct: W archive will be saved into a new format.
Encryption (encryption)

Vim can add a password to a file
vim-x filename (filename)-> input 2 times password, save file every time will need password to enter (encrypt the file with password)
Vim processing encrypted files, and will not be password verification, that is, when you open the file, vim regardless of the password you entered is correct, directly with the password to decrypt this article. If the password is wrong, you will see the code is garbled, and will not remind you of the password error (this increased security, there is no place to know whether the password is correct) of course, if using a fast enough machine for poor lifting, vim can still be opened
VIM syntax display (syntax)

: syntax enable-> color display of open syntax (turn on syntax color)
: Syntax clear-> close syntax color (remove syntax color)
: Syntax off-> completely closes all grammatical functions (turn off syntax)
: Syntax manual-> manually set syntax (set the syntax manual, when need syntax Use:set)
Enter special characters (special character)

Ctrl-v code is okay.
For example Ctrl-v 273->ÿ get y
Binaries (binary file)

Vim can display, edit 2 carry File

Vim-b datafile
: Set Display=uhex-> This will be displayed in Uhex. Used to display some characters that cannot be displayed (control characters, and so on) (display in Uhex play Non-display char)

:%!xxd-> Changes the current file to display 2-carry (change display to binary)
:%!xxd-r-> Change the binary to text format (convert back to text)
Automatic completion (auto-completion)

Vim itself has the function of AutoComplete (this is not to say Ctag, but vim built it)
Ctrl-p-> Backward Search automatically complete (search backward)
Ctrl-n-> forward Search automatic completion (search forward)
Ctrl-x+ctrl-o-> Code Auto-complement (codes completion)
Automatic Backups (Backup)

Vim can help you to automatically back up files (when stored, before files are backed up)
: The set backup-> to open the backup, within the construction of the file name is the source file name plus a ' ~ ' (enable backup default filename+~)
: Set Backupext=.bak-> Set the backup file name as the source file name. bak (change backup as Filename.bak)

The problem with automatic backups is that if you save a file multiple times, your backup file will be overwritten and you can only have that backup before the last time you save the file. It doesn't matter, VIM also provides Patchmode, this will take your first original file back down, will not change
: Set Patchmode=.orig-> Save the original file as a filename. orig (keep orignal file as Filename.orig)
Open, Save and exit (Save & Exit)

: w-> Save file (write file)
: w! -> forced Save (Force write)
: Q-> Exit files (exit file without Save)
: q! -> Force exit (force quite without save)
: E filename-> open a file named filename (open file to edit)
: e! FileName-> Force open a file, all unsaved things will be lost (force open, drop dirty buffer)
: SaveAs filename-> Save as filename (save file as filename)
Edit Command (editor)

A-&gt; inserted after the Light table (append after cursor)


A-&gt; inserts at the end of a row (append at the "line")


I-&gt; inserted before the cursor (insert before cursor)


I-&gt; in the first non-white-space character match either insert (insert before one non-blank)


o-&gt; insert a new line below the cursor (open lines below)


O-&gt; Insert a new row above the cursor (open line above)


x-&gt; Delete (or after) the contents of the cursor (delete under and after cursor)


For example x is to delete the current cursor, 3x is to delete the cursor under + cursor after 2-bit characters


X-&gt; Delete the character before the cursor (delete before cursor)


D-&gt; Deletion (delete)


You can delete a row with DD, or 3DW delete 3 words, and so on.


J-&gt; will refer to this line in the next line (join lines)


R-&gt; replaces characters (replace characters)


R-&gt; Replace multiple characters (replace mode–continue replace)


GR-&gt; does not affect the replacement of pattern layouts (replace without affecting layout)


C-&gt; is the same as the D key, but after deletion enter the input mode (same as "D" but after delete, in insert mode)


S-&gt; Deletes a row (like DD) but enters input mode after deletion (same as "DD" but after delete, in insert mode)


s-&gt; Delete character, same as (d), but after deletion into input mode (same as "D" but after delete, in insert mode)


S4s will delete 4 characters into input mode (delete 4 char and put in insert)


~-&gt; To change the case, big to small, small to large (changes upper-&gt; lower or lower-&gt;upper)


Gu-&gt; to lowercase (change to lower case)


For example, GUG will turn the cursor to the file at the end of all lowercase (change lower case all the way)


GU-&gt; to uppercase (change to upper case)


For example, GUG will turn the cursor current to the end of the file into uppercase (change upper case all the way to the)


Copy and paste (copy &amp; paste)

Y-> copy (Yank line)
yy-> copy Current row (Yank)
"{a-za-z}y-> copy information to a register (yank the link into register {a-za-z})
For example, I use "ayy so in the register a, copy a line, and then I use" byw copy a word in the deposit B
Paste, I can choose to stick a inside of the things or b inside, this is like multiple copies of the same version
"*y-> This is a copy of the information into the system (can be posted in other programs) (Yank to OS buffer)
P-> Paste under current cursor (paste below)
P-> Paste on current cursor (paste above)
"{A-za-z}p-> to post the contents of a deposit (paste from register)
For example, the AP then posted the contents of my previous deposit in a under the current cursor. "BP posted the contents of my previously hosted B on the current cursor.
"*p-> reads information from the system Clipboard and pastes it into vim (paste from OS buffer to vim)
Reg-> Displays all of the contents in the Register (list all registers)
Bookmark (Mark)

Bookmarks are a very powerful feature of vim, and bookmarks are divided into file bookmarks and global bookmarks. A file bookmark is a different location in your tag file, and you can quickly jump to the location you want in the file. A global bookmark is a location that marks a different file. Which means you can jump quickly in different files.

M{A-ZA-Z}-> saves the bookmark, the lowercase file bookmark, and can be labeled with any letter (A-Z). Uppercase is a global bookmark, marked with any letter in uppercase (A-Z). (Mark position as bookmark. When lower, only stay in file. When upper, stay in global)
' {a-za-z}-> jumps to a bookmark. If it is a global bookmark, the bookmarked file is opened to jump to the marked line (go to mark. in file {A-Z} or global {-A-Z}. In global, it will open the "file")
' 0-> jump into the file that you edited now, Last Exit (goes to previous exit in file)
"-> jumps as the last jump position (go-to-jump-> go-back to final jump)
'-> jumps to the last edit position (go to end edit)
G ' {mark}-> jump to bookmark (jump to {mark})
:d Elm{marks}-> Delete a bookmark (delete a mark) For example: Delma then delete Bookmark a
:d elm! -> Delete all bookmarks (delete all marks)
: Marks-> display system all bookmarks (show all bookmarks)
Sign (TAG)

: Ta-> jump into the logo (jump to tag)
: TS-> Displays matching flags and jumps to a flag (list matching tags and select one to jump)
: Tags-> display all logos (print tag list)
Run external command (using an external program)

:! -> directly runs an external command in the shell (call no external program)
:!make-> runs the make instruction directly in the current directory (run make on the present path)
: R!ls-> reads the input of an externally running command, writes of course vim. Here the output of the LS is read (read the "LS" and append the result to file)
: 3r!date-u-> to enter the result of the external command date-u in the third line of vim (read the date-u, and append results to 3rd lines of file)

: w!WC-> The content of Vim to external directives to deal with. Here, let the WC handle the VIM content (send Vim's file to external command. This will send the current file to WC command)
Vim has some built-in for common instructions, such as WC (count words) (Vim has some buildin functions, such like WC)
G Ctrl-g-> calculates the number of words in the currently compiled file (Word count on current buffer)
!! Date-> Inserts the current time (insert today date)
Editing of multiple files (edit multifiles)

Vim can edit multiple files, such as
Vim A.txt b.txt C.txt opened 3 files

: Next-> Edit next file (next files in buffer)
: next! -> forces the next file to be edited, which means if the first file is changed (force to next the file in buffer if current buffer changed)
: Wnext-> save files, edit next (Save the file and Goto next)
: args-> Find the name of the file that is currently being edited (found out which the buffer is editing now)
:p revious-> Edit last file (previous buffer)
:p revious! -> force edit last file, same: next! (Force to previous buffer, same as:next!)
: Last-> Edit final file (previous buffer)
: First-> Edit top file (front buffer)
: Set Autowrite-> set automatically save, when you edit the next file, the file currently being edited if changes, will be automatically saved (automatic write the buffer when you switch to next buffer)
: Set Noautowrite-> turn off automatic save (turn Autowrite off)
: Hide e abc.txt-> Hides current file, opens a new file Abc.txt edit (hide the present buffer and edit abc.txt)
: Buffers-> Displays all the files in vim (display all buffers)
: Buffer2-> The second in the edited file (edit buffer 2)

Vim is a lot of things can be written in short, do not have to type so trouble, such as: Edit=:e,: Next=:n.
Split screen (split)

VIM provides a split-screen function (like the split in screens)


: Split-&gt; divides the screen into 2 (split screens)


: Split abc.txt-&gt; the screen into two, and the second new screen shows the Abc.txt content (split the Windows, on New window, display Abc.txt)


: Vsplit-&gt; Vertical split screen (split vertically)


: {d}split-&gt; set the number of rows for the split screen, for example, I want a screen with only 20 lines, you can: 20split (split the windows with {D} lines. 20split:open new windows with 3 line S


: New-&gt; split screen and create a blank file in a new screen (split windows with a new blank file)


CTRL-W+J/K/H/L-&gt; Use Ctrl plus W plus j/k/h/l to switch in different screens (switch, move between split screens)


ctrl-w+-/+-&gt; The size of the split screen (change split size)


Ctrl-w+t-&gt; to the topmost screen (move to the top windows)


Ctrl-w+b-&gt; to the bottom screen (move to bottom window)


: Close-&gt; closes a separate screen (closed splited screens)


: Only-&gt; displays only the current cursor, others will be turned off (only display present active screen, closed all others)


: Qall-&gt; Exit all screens (quite all windows)


: Wall-&gt; Save all screens (write to all windows)


: Wqall-&gt; Save and exit all screens (write and quite all windows)


: qall! -&gt; exit all screens without saving any changes (quite all windows without save)


When you open a file, with the-o option, you can open multiple files directly in the split screen (with-o option from command, it will open files and display in Split mode)


Vim-o a.txt B.txt

Today, some people say will not see the diff, in fact, vim can also be used to see the diff, this is also part of the split screen, here also write.

Vimdiff A.txt B.txt If directly to the-D option is the same vim-d a.txt B.txt
:d Iffsplit Abc.txt If you have opened a file now, want Vim to help you distinguish between your file and abc.txt what is the difference, you can in vim in the Diffsplit way to open the second file, this time vim will split the way to open the second file , and by color, fold to show the difference between two files
So vim will use color to help you distinguish between 2 files. If the file is larger (source) Repeat part will help you fold up (will be said after folding)
Now, Patch.
:d iffpatch filename through: diffpatch Your patch file name, you can use the current file plus your patch to display. Vim will split a new screen, displaying the patch message and using color to mark the difference.
If you do not like up and down contrast, like the left and right (more in line with vision) can be in front of the vert, for example:
: Vert Diffsplit Abc.txt
: Vert Diffpatch Abc.txt
After reading the diff, with: Only back to the original edited file, think the color of the diff or where, as long as: Diffoff close on the good.
And one of the common diff's is:d iffu This is a shorthand for:d iffupdate, updated with
TAB

In addition to split, Vim can also use tab

: Tab split filename-> this tab to display multiple files (using tab to display buffers)
The GT-> to the next tab (go to Next tab)
GT- > To the previous tab (go to Previous tab)
Vim Most things can be done with a number, tab is the same
0GT-> jumps to the first tab (switch to 1st tab)
5GT-> Skip to the Fifth tab (switch to 5th tab)
Close all tabs to use the qall instruction. In addition let Vim in the start of the automatic tabnew way to open multiple files, you can use the alias
Linux: Add alias vim= ' Vim-p ' to ~/.BASHRC
Windows: Write yourself a vim.bat file, and then put it in path, file content:
@echo off
vim-p%*
When you need to change a file in multiple tabs, you can use: Tabdo this is the same as the loop to all of your tab Run the command after.
For example, there are 5 files in the tab, you need to change the name of a variable: ABC to DEF, you can use: Tabdo%s/abc/def/g so all of the 5 tab in the ABC has become DEF the
 
Folding (folding) /p>

Vim's folding feature ... I remember it should be released when the 6 version of it. This is very useful for people who write programs.
ZFAP-> By paragraph collapse (fold by paragraph)
Zo-> open a collapsed (open fold)
Zc-> Turn off a collapsed (close fold)
ZF-> Build folding (Create fold) This can be in v visual mode, can be directly to the number of rows, etc.
ZR-> Open a certain number of folds, such as 3rz (reduce the folding by numbers like 3ZR)
Zm-> Fold Fold a number (before you define a good folding) (fold by)
ZR-> turn on all folds (open all fold)
ZM-> turn off all folds (close all fold)
Zn-> Turn off the folding feature (disable fold)
ZN-> Open Folding (Enable fold)
ZO-> All the folds under the cursor open (open all folds at the cursor line)
ZC -> closes all folds under the cursor (Close all fold at cursor line)
Zd-> deletes the collapse under the cursor, this is not the deletion, but the deletion of the folding tag (delete fold at cursor line)
ZD-> all collapsed deletions under the cursor (delete all folds in the cursor line)
Fold by tab, Python is best used (Ford by indent, very useful for Pytho N)
: Set foldmethod=indent-> set to switch off with ZM and ZR (use ZM ZR)
Save (save view)

For VIM, if you set a fold, but exit the file, whether or not to keep the file, the collapsed part will automatically disappear. This is very inconvenient. So vim gives you the means to keep records of folds, tags, bookmarks, and so on. Most of all, Vim can save up to 10 view for each file, which means you can have 10 different labeling methods for the same file, and these things will be saved as you need them.
: Mkview-> Save setting
: Loadview-> read record (load setting)
: Mkview 2-> Save record in Deposit 2 (save view Register 2
: Loadview 3-> Read records from hosting 3 (Load view from register 3)
Common Instructions (commands)

: Set IC-> is set to be case-insensitive when searching (search case insensitive)
: Set Noic-> search is case-sensitive. Vim default is this (case sensitive)
&-> repeats the last ": S" (Repeat previous ": S")
.-> Repeat Last command (repeat.)
K -> searches the man for the word under the current cursor (Search man page under cursor)
{0-9}k-> finds chapters in man under current cursor, for example 5K is equal to man 5 (search section of Man . 5K Search for man 5
: History-> View command history (see Command Line history)
Q:-> Open vim Command Window (open vim command Windo WS)
: E-> Opens a file, vim can open a HTTP/FTP/SCP file (open file. Also works with HTTP/FTP/SCP)
: E http://www.google.com/ind Ex.html-> here in vim, open Google's index.html (open Google ' s index.html)
: CD-> replace the directory in Vim (changes current directory in VIM)
:p WD-> displays VIM's current directory (display pwd in vim)
GF-> Opens the file. For example, if you have a line in vim that writes #include, then pressing GF,VIM on ABC.H will open the Abc.h file (look for file. If you have a file with #include, then the cursor i s on abc.h Press GF, it'll open the file abc.h in vim
Recording instructions (record)

Q{A-Z}-> records instructions in a register (record typed char into register)
Q{A-Z}-> the directive into the previous register (append typed char into register{a-z})
Q-> End record (stop recording)
@{a-z}-> Execute the instructions in the register (execute recording)
@@-> Repeat last instruction (repeat previours: @{a-z})
Give me an example of how it's easier to understand.
I am now in a file below the QA instruction, then enter itest then ESC then Q
QA here means that my instructions are recorded into a deposit, itest is actually 2 steps, I insert (insert) written text is text then use ESC return instruction mode Q end record. So I'll put the itest record in one more deposit.
I'm going to execute @a then I'll automatically insert the word test. @@ 就 the previous action, so it's still equal to @a
Searching (search)

One of the most powerful features of VIM is search and replace. If you are familiar with the positive expression (regular expressions) This search will be an unbeatable tool (not many editors supporting re).

From a simple start,
#-> The reverse search keywords under the cursor (searching the word under cursor backward)
*-> Search keywords under the cursor (searching the word under cursor forward)
/-> Down (search forward)
? -> Up search (search back)
Here you can use the/ABC or ABC way up and down to search ABC
%-> Find the next end, for example, under (Find Next ")" To find "()", "[]" and "[]" and "[]" and "[]" and "[]" and "[]" and "[]" and "[]" and "[]" and " F

Use a few examples directly below
/a*-> This will search for a AA AAA
/\ (ab\) *-> This will search for AB abab ababab
/ab\+-> This will be found in AB ABB ABBB
/folers\=-> This will search Folder folders
/ab\{3,5}-> This will search abbb abbbb abbbbb
/ab\{-1,3}-> This will be found in abbb. Match AB in abbb)
/a.\{-}b-> This will be found in the Axbxb axb (match ' axb ' in ' Axbxb ')
/a.*b-> will search for any b after the beginning of any a (match a*b an Y)
/foo\|bar-> search for Foo or bar, which is to search 2 words simultaneously (match ' foo ' or ' bar ')
/one\|two\|three-> search 3 words (match ' one ', ' two ' or ' Three ')
/\ (foo\|bar\) \+-> search foo, foobar, Foofoo, Barfoobar, etc. (Match ' foo ', ' foobar ', ' foofoo ', ' barfoobar ' ...)
/end\ (if\|while\|for\)-> search endif, endwhile endfor (Match ' endif ', ' endwhile ', ' endfor ')
/forever\& ; This will search for the "for" in the forever, but will not search for the "for" in Fortuin because we are here to ... The limit (match ' for ' in ' forever ' would not match ' Fortuin ')

Special characters can be preceded by ^ (for special character, user "^" at the start of range)
/"[^"]* "
Here's an explanation.
"Double quotes First" (double quote)
[^] Any thing that isn't a double quote (any character that's not a double quote)
* All other (as many as possible)
"End first quote (double quote close)
The top one will search for "foo" "3!x" including quotes (match "foo"-> and "3!x" include double quote)

More examples, such as the search for license plate rules, assume that the license plate is "1mgu103" that is, the first is a number, 3 uppercase subtitles, 3 digits in the format. So we can search directly for all the characters that match this rule.
(A sample License plate number is "1mgu103″. It has one digit, three upper case
Letters and three digits. Directly putting a search pattern)
This should be very understood, we search
\ number \ capital Letter \ Capital Letter \ Capital Letter \ Digital \ Digital \ Digital

/\d\u\u\u\d\d\d

Another method is to define several numbers directly (or, if 30, 30 \u?) )
(Specify there are three digits and letters with count)

/\D\U\{3}\D\{3}

You can also search by range (using [] ranges)
/[0-9][A-Z]\{3}[0-9]\{3}

Use range search to list some ranges (range)
This has nothing to say, look at it all understand, to all remember ... Use more to remember, with less to forget. See Help every time, hehe

/[A-Z]
/[0123456789ABCDEF] =/[0-9a-f]
\e
\ t
\ r
\b
Abbreviation (item matches equivalent)

\d Digit [0-9]
\d Non-digit [^0-9]
\x hex Digit [0-9a-fa-f]
\x non-hex Digit [^0-9a-fa-f]
\s white Spaces [] (and)
\s non-white characters [^] (not and)
\l Lowercase Alpha [A-z]
\l Non-lowercase Alpha [^a-z]
\u uppercase Alpha [A-z]
\u Non-uppercase Alpha [^a-z]

: Help/[]–> a special definition that can be used in vim (everything about special)
: Help/\s–> Ordinary can also see directly (Everything about normal)
Replace (string substitute) –rx

The replacement is actually the same as the search. Only the substitution is 2 values, one is what you search for, one is the string substitute to be replaced after searching (use Rx)

%s/abc/def/-> replaces ABC to DEF (substitute ABC to DEF)
%S/ABC/DEF/C-> replaces ABC to DEF, will ask you each time ok (substitute on all text with confirmation (y,n,a,q,l))
1,5s/abc/def/g-> only replaces the ABC to def between the first line and line 15th (substitute ABC-def only between lines 1 to 5)
54s/abc/def/-> replaces only the 54th line of ABC to DEF (just substitute ABC to def on Lines 54)

Combining the above search positive expression, this substitution function ... is very strong. Linux is a lot of places are expressed to do things please, so learned to benefit from infinity.
Globals (Global)

This does not know how to translate, anyway vim is called global, can perform some VIM commands on the search for things. I am also 2-3 weeks ago because of reading some special things in the log, to learn to use. (Find the match pater and execute a command)

The method of global concrete self is G/pattern/command
: g/abc/p-> to find and display only ABC rows (only print lines with "abc")
: g/abc/d-> Delete all rows with ABC (delete all lines with "abc")
: V/ABC/D-> This will erase anything that is not in line without ABC (delete all lines without "abc")
Information Filtering (filter)

Vim is another powerful feature

! -> use! is telling vim to execute the filtering process (tell Vim to performing a filter operation)
!5g-> executes the filter from the cursor down 5 lines (tell Vim to start filter under cursor and go down 5 lines)

The formal instructions start with the sort example here:
!5gsort-> starts with the sort from under the cursor, executing 5 lines altogether, which means I just need to sort5 a row (this will sort the text from cursor lines down to 5 lines)
! Gsort-k3-> can directly substitute the sort argument, I want the third paragraph in sort text (sort to the "end of" file by column 3)
!! The-> value filters the current row (filter the present line)

If you feel it! This method 5G is awkward to use (I think so) and can be done in standard command mode.
is actually a:., just (to type the command)
:., Start,end!sort here defines:., start line, end line! Run instructions
:., $!sort-> from the current row to the end of the file (sort from?
:. 0,$!sort-> The first line from the beginning of the file to the end of the file (sort from start.
:. 10,15!sort-> is performed only between lines 10th through 15th of the file (sort between line 15)

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.