VI cursor Movement and common editing commands

Source: Internet
Author: User
Tags first string
<span id="Label3"></p><p><p>Cursor movement</p></p><p><p>Left: h<br>Under: J<br>Top: K<br>Right: L</p></p><p><p>The beginning of the next Line: +<br>The beginning of the previous line:-<br>Beginning of current Line: 0<br>End of current line line: $</p></p><p><p>First Word: W,w<br>Last Word ending: e,e<br>Previous word head: b,b</p></p><p><p>Next Screen: crtl+f<br>Previous Screen: Crtl+b<br>Lower half screen: crtl+d<br>Upper Half Screen: crtl+u<br>Scrolling up the screen: crtl+y<br>Scrolling down the screen: crtl+e<br>Skip to end of File: G<br>Skip to File Header: g<br></p></p><p><p>Top line of the current screen: H<br>Current screen last line: L<br>Current screen center: M</p></p><p><p>Specify line: line number g,: line number</p></p><p><p>Specify string before:/string,? string<br>Current line specified word match either: f character, F character</p></p><p><p>Text Append and insert</p></p><p><p>Append to right of current cursor: a<br>Append at the end of the current cursor line: A</p></p><p><p>Append to the left of the current cursor: I<br>Append to current cursor header: I</p></p><p><p>Append line below current line: o<br>Insert row above current line: O</p></p><p><p>Text Delete</p></p><p><p>Delete cursor position text: x<br>Delete cursor left text: X</p></p><p><p>Delete current line: DD<br>Delete text within the cursor movement range: d cursor Move command</p></p><p><p>Text substitution</p></p><p><p>Replace 1 text to Multi-text: s<br>Replace 1 text to 1 text: r<br>Replace to current line end: C<br>Replace current line: cc<br>Replace from current position until input esc:r</p></p><p><p>Copy and paste text</p></p><p><p>Cases<br>Copy cursor The following 3 lines: 3yy,3y<br>After copying the cursor 6 words: 6yw</p></p><p><p>Paste to the following cursor: p<br>Paste to Cursor above: P</p></p><p><p>Generic Replace command</p></p><p><p>: Line 1, line 2s/string 1/string 2/g</p></p><p><p>"line 1, Line 2" Specifies the method example:<br>Line 5th to 30th: 5,30<br>Current line to line 30th:., 30<br>Line 5th to End: 5,$<br>Line 5th to the row containing end: 5,/end/<br>All lines:%</p></p><p><p>Other common commands</p></p><p><p>Show line Numbers<br>: Set number Or: set Nu</p></p><p><p>Hide Line Numbers<br>: Set Nonumber or: set Nonu</p></p><p><p>Auto Indent<br>: Set autoindent or: set AI</p></p><p><p>Do not indent automatically<br>: Set noautoindent or: set Noai</p></p><p><p>Display tab and end of line characters<br>: Set list</p></p><p><p>Hide tab and end of line characters<br>: Set Nolist</p></p><p><p>Set tab width to 4 characters<br>: Set tabstop=4</p></p><p><p>View current settings<br>: Set All</p></p><p><p><br>:d D Delete the forward<br>: NDD Deletes the following n rows of the current row (including the current Row)<br>:p paste<br>: yy copy when moving forward<br>: Nyy Copy the following n rows of the current row (including the current Row)<br>:d D and NDD can also be considered "cut".<br><br>: N,m Co k copy N to M line, paste to K line (starting from next Line)<br>: n,m m K cut N to M line, paste to K line (starting from next Line)<br>: n,m d Delete N to m rows<br><br>Note that M must be greater than n, and m, n, K are within the body line Number. For example, If the file has 10 rows and you have 11 in your operation, an error occurs. M can use the special symbol $, which represents to the End.<br><br>If you want to process more text, you can use the method of Marking. Specific as Follows:<br><br>Move the cursor to the start line, enter the MA<br>Move the cursor to the end line, enter MB<br>Move the cursor to the pasted row, enter the MC<br><br>Then: ' a, ' B Co ' c, the implementation of the copy and Paste. If the CO is changed to m, the Cut-and-paste is Realized.<br><br>Disorderly typesetting:<br>Ggv=^g<br>Ggv=g</p></p><p><p><br></p></p><p><p><br></p></p><p><p><br></p></p><pre id="recommend-content-1464376154" class="recommend-text mb-10" style="margin-top:0px;margin-bottom:10px;padding:0px;font-family:arial, ‘courier new‘, courier, ‘宋体‘, monospace, ‘Microsoft YaHei‘;white-space:pre-wrap;font-size:14px;color:rgb(51,51,51);line-height:24px;background-color:rgb(243,255,236);">Enter VI command  vi filename : Open or file, and place the cursor at the beginning of the first line  vi +n filename : opens the file and places the cursor at the beginning of nth   Vi + filename&nbsp: Open the file and place the cursor at the beginning of the last  vi +/pattern filename: open file, and place the cursor at the first string that matches the pattern  vi -r filename : a system crash occurred in the last edit with vi, recovery filename vi filename Filename : Open multiple files, edit   Move Cursor class command h : cursor moves left one character  l : cursor moves right one character  space: cursor moves right one character   Backspace: the cursor moves left one character  k or ctrl+p: the cursor moves a row  j or ctrl+n : moves the cursor down a line  enter : moves the cursor down a line  w or w  : The cursor moves one word to the first  b or b : the cursor moves left one word to the beginning  e or e : the cursor moves one word to the end of the word  )  : the cursor moves to the end of the sentence   ( : the cursor moves to the beginning of the sentence  } : The cursor moves to the beginning of the paragraph  {: the cursor moves to the end of the paragraph  ng: the cursor moves to the nth line  n+: the cursor moves down n rows  n-: the cursor moves up n rows  n$: the cursor moves to the nth line end  H  : The cursor moves to the top line of the screen  m : the cursor moves to the middle line of the screen  l : the cursor moves to the last line of the screen  0: (note the number 0) the cursor moves to the current beginning  $: the cursor moves to the current line end   Screen tumbling class command  ctrl+u: to file The first half screen  ctrl+d: to the end of the file half screen  ctrl+f: to the end of the file screen  Ctrl+b; to the top of the file a screen  nz: roll the nth row to the front of the screen, Rolls the current line to the top of the screen when n is not specified.   Insert Text Class command  i :  i&nbsp before cursor;: at the current beginning  a:  a: at the end of the current line: a new line below the current line  o: new line above the current line  r: replace the current character  r: replace the character of the current character and its characters until the ESC key is Pressed.  s: starts at the current cursor position and replaces the specified number of characters with the input text  s: deletes the specified number of lines and replaces it with the input text &NBSP;NCW or ncw: modifies the specified number of words  ncc: modifies the specified number of lines   Delete command  ndw or ndw: delete the n-1 word at the beginning and after the cursor  do: cut to the beginning  d$: Delete to the end of the line  ndd: remove the current line and its subsequent n-1 row  x or x: Delete a character, x after deleting the cursor, and x Delete the  ctrl+u before the cursor: Delete input mode of the text   search and replace command  /pattern: from the beginning of the cursor to the end of the file search pattern  Pattern: from the beginning of the cursor to the top of the file search Pattern n: repeat the last search command  n: repeat the last search command in the opposite direction  :s/p1//g: replace all P1 in the current row with  :n1,n2s/ P1//g: all P1 in line N1 to N2 are replaced P2 with  :g/p1/s//p2/g: all P1 in the file are P2 replace   option settings  all: list all option settings  term: setting the terminal type  igrance: Ignore case  list in search: Show tab stop (ctrl+i) and end of line flag ($)  number: Show line number  report: displays the number modified by the line-oriented command   Terse: displays a short warning message  warn: displays  write information if the current file is not saved when you go to another file  magic: allow in search mode, use the   without "\" in the previous Nowrapscan: Ban VI When the search reaches the end of the file, and then start from the other end  mesg: allow VI to show other users write to their terminal information   last line command  :n1,n2 co  N3: Copy the contents of the N1 line to the N2 row below the N3 line  :n1,n2 m n3: the N1 line to the N2 rowN3 to the next line  :n1,n2 d : Delete the contents of the N1 line to the N2 row  :w : Save the current file  :e filename: open file filename for editing  :x: Save the current file and exit  :q: exit vi :q!: do not save the file and exit vi :!command: Execute shell command command :n1,n2 w! Command: the contents of the N1 line to the N2 line in the file as input and execution of the command, if not specified n1,n2, the entire file contents as the input of the command  :r!command: put the Command's output to the current line   Register Operation   "? nyy: saves the contents of the current row and its next n rows to the register?" , where? is a letter, n is a number   "? Nyw: saves the current line and its next n characters to the register? , where? is a letter, n is a number   "? Nyl: saves the current line and its next n characters to the register? , where? is a letter, n is a number   "? p: take out the register? and place it at the cursor Position. Over here? Can be a letter, or it can be a number  ndd: delete the current line and its total n lines of text, and place the deleted content in the 1th delete register</pre><p><p><br></p></p><p><p>VI cursor Movement and common editing commands</p></p></span>

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.