130 vim commands you need to know

Source: Internet
Author: User
Tags php open file
130 basic vim commands: efilenameOpenfilenameforedition: wSavefile: qExitVim: q! Quitwithoutsaving: xWritefile (ifchangeshasbeenmade) andexit: savfilena 130 vim command basics you need to know: e filename Open filename for edition: w Save file: q Exit Vim: q! Quit without saving: x Write file (if changes has been made) and exit: sav filename Saves file as filename. repeats the last change made in normal mode5. Repeats 5 times the last change made in normal mode in the file, move k or Up Arrow move the cursor up one linej or Down Arrow move the cursor down one linee move the cursor to the end of the wordb move the cursor to the ining of the word0 move the cursor The begining of the lineG move the cursor to the end of the linegg move the cursor to the begining of the fileL move the cursor to the end of the file: 59 move cursor to line 59. replace 59 by the desired line number.20 | move cursor to column 20.% Move cursor to matching parenthesis [[Jump to function start [{Jump to block start cut, Copy and Paste y Copy the selected text to clipboardp Paste clipboard content Sdd Cut current lineyy Copy current liney $ Copy to end of lineD Cut to end of line Search/word Search word from top to bottom? Word Search word from bottom to top * Search the word under cursor/\ cstring Search STRING or string, case insensitive/jo [ha] n Search john or joan/\ <the Search, theater or then/the \> Search the or breathe/\ <the \> Search the/\ <STRONG. \> Search all words of 4 letters/\/Search fred but not alfred or frederick/fred \ | joe Search fred or joe/\ <\ d \> search exactly 4 digits/^ \ n \ {3} Find 3 empty lines: Bufdo/searchstr/Search in all open filesbufdo % s/something/somethingelse/g Search something in all the open buffers and replace it replace withsomethingelse: % s/old/new/g Replace all occurences of old by new in file: % s/onward/forward/gi Replace onward by forward, case unsensitive: % s/old/new/gc Replace all occurences with confirmation: 2,35 s/old/new/g Replace all occurences between lines 2 and 35: 5, $ s/o Ld/new/g Replace all occurences from line 5 to EOF: % s/^/hello/g Replace the begining of each line by hello: % s/$/Harry/g Replace the end of each line by Harry: % s/onward/forward/gi Replace onward by forward, case unsensitive: % s/* $ // g Delete all white spaces: g/string/d Delete all lines containing string: v/string/d Delete all lines containing which didn't contain string: s/Bill/Steve/Replace the firs T occurence of Bill by Steve in current line: s/Bill/Steve/g Replace Bill by Steve in current line: % s/Bill/Steve/g Replace Bill by Steve in all the file: % s/^ M // g Delete DOS carriage returns (^ M ): % s/\ r/g Transform DOS carriage returns in returns: % s # <[^>] \ + >## g Delete HTML tags but keeps text: % s/^ \(. * \) \ n \ 1 $/\ 1/Delete lines which appears twiceCtrl + a Increment number under the cursorCtrl + x Decreme Nt number under cursorggVGg? Change text to Rot13 case-sensitive Vu Lowercase lineVU Uppercase lineg ~~ Invert casevEU Switch word to uppercasevE ~ Modify word caseggguG Set all text to lowercasegggUG Set all text to uppercase: set ignorecase Ignore case in searches: set smartcase Ignore case in searches excepted if an uppercase letter is used: % s/\ <. /\ u &/g Sets first letter of each word to uppercase: % s/\ <. /\ l &/g Sets first letter of each word to lowercase: % s /. */\ u & Sets first letter of each line to uppercase: % s /. */\ l & Sets first letter of each Line to lowercase: w outfile Saves lines 1 to 10 in outfile: w> outfile Appends lines 1 to 10 to outfile: r infile Insert the content of infile: 23r infile Insert the content of infile under line 23 file browser: e. open integrated file explorer: Sex Split window and open integrated file explorer: Sex! Same as: Sex but split window vertically: browse e Graphical file explorer: ls List buffers: cd .. move to parent directory: args List files: args *. php Open file list: grep expression *. php Returns a list. php files contening expressiongf Open file name under cursor interacts with Unix systems :! Pwd Execute the pwd unix command, then returns to Vi !! Pwd Execute the pwd unix command and insert output in file: sh Temporary returns to Unix $ exit Retourns to Vi alignment: %! Fmt Align all lines !} Fmt Align all lines at the current position5 !! Fmt Align the next 5 linesTabs/Windows: tabnew Creates a new tabgt Show next tab: tabfirst Show first tab: tablast Show last tab: tabm n (position) Rearrange tabs: tabdo % s/foo/bar/g Execute a command in all tabs: tab ball Puts all open files in tabs: new abc.txt Edit abc.txt in new window split screen display: e filename Edit filename in current window: split filename Split the window and open filenamectrl-w up arrow Puts cursor in top windowctrl-w ctrl-w Puts cursor in next windowctrl-w _ Maximize current window verticallyctrl-w | Maximize current window horizontallyctrl-w = Gives the same size to all windows10 ctrl-w + Add 10 lines to current window: vsplit file Split window vertically: sview file Same as: split in readonly mode: hide Close current window: ­ nly Close all windows, sorted Ted current: B 2 Open #2 in this window automatically Complete Ctrl + n Ctrl + p (in insert mode) Complete wordCtrl + x Ctrl + l Complete line: set dictionary = dict Define dict as a dictionnaryCtrl + x Ctrl + k Complete with dictionnaryMarksm {a-z} Marks current position as {a-z} '{a-z} Move to position {a-z} ''Move to previous position abbreviation: AB mail mail@provider.org Define mail as abbreviation of mail@provider.org text indent: set autoindent Turn on auto-indent: set smartindent Turn on intelligent auto-indent: set shiftwidth = 4 Defines 4 spaces as indent sizectrl-t, ctrl-d Indent/un-indent in insert mode> Indent <Un-indent = % Indent the code between parenthesis1GVG = Indent the whole file syntax highlighted: syntax on Turn on syntax highlighting: syntax off Turn off syntax highlighting: set syntax = perl Force syntax highlighting
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.