Vi: Difference between revisions
Jump to navigation
Jump to search
Adamcolton (talk | contribs) No edit summary |
Adamcolton (talk | contribs) No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
http://www.engadget.com/2012/07/10/vim-how-to/ | http://www.engadget.com/2012/07/10/vim-how-to/ | ||
http://www.lagmonster.org/docs/vi2.html | |||
Blank lines beyond the end of the file are ~. | Blank lines beyond the end of the file are ~. | ||
| Line 104: | Line 106: | ||
Buffers can be accessed with " but if no buffer is specified the general buffer is used. | Buffers can be accessed with " but if no buffer is specified the general buffer is used. | ||
[[Category:Quiz]] | [[Category:Quiz]] | ||
Latest revision as of 12:47, 12 July 2016
http://www.engadget.com/2012/07/10/vim-how-to/
http://www.lagmonster.org/docs/vi2.html
Blank lines beyond the end of the file are ~.
To get to command mode, hit Esc or ^[. To quit, :q. Quit without saving :q!. To save, :w or combine them with :wq. To specify the filename do :w filename. Another way to save and quit is ZZ.
The two modes are command and insert. Commands can be prefixed with a number, the command will run that many times.
- a enter insert mode after the cursor
- h left one character
- i enter insert mode before the cursor
- j down one character
- k up one character
- l right one character
- r replace one character under the cursor
- u undo the last change
- x delete character under cursor
- " access a buffer
- "mdd delete the current line and put it in buffer m
- "mp paste contents of buffer m
- d delete until where
- d^ deletes current position to beginning of line
- d$ deletes current position to end of line
- dw deletes current position to end of word
- dd deletes entire line (and places cursor on what was the line below)
- D delete from end of line to current cursor position
- Y copy (yank) current line
- y yank (copy) until where, yy is the current line
- p paste after cursor
- P paste before cursor
- << deindent the current line
- >> indent the current line
- A enter insert mode at the end of the current line
- I enter insert mode at the beginning of the current line
- O enter insert mode in a new line above the current line
- o enter insert mode in a new line below the current line
- ^b scroll backwards one page
- ^d scroll forwards half a window
- ^f scroll forward one page
- ^h move the cursor one space to the left
- ^j move cursor down one line in same column
- ^m move to first character on the next line
- ^n same as ^j
- ^p move cursor up one line in same column
- ^u scroll backwards half a window
- ^e scroll forward one line
- ^y scroll back one line
- $ move to the end of the current line
- % move to matching parenthesis or brace
- ^ move to next beginning of the line
- ( move to beginning of sentence
- ) move to beginning of next sentence
- { move to preceding paragraph
- } move to next paragraph
- + move to first non-whitespace character on next line
- - move to first non-whitespace character on previous line
- _ move to first non-whitespace character on current line
- B back one word, skipping punctuation
- E foreword to end of current word, skipping punctuation
- G goto line number specified in count, if no line number is given, end of file
- H first non-whitespace character at top of the screen
- L first non-whitespace character at bottom of the screen
- M first non-whitespace character at middle of the screen
- W beginning of next word
- b back one word or start of current word
- e or w forward one word, or end of current word
- z redraw the screen
- with no modifier, with the current line at the top
- . puts the current line at the center
- - puts the current line at the bottom
- if you put a count before, it will put that line number at the center
- ~ change character case
- J join the current line with the next one
Searching - basically regex.
- Matching
- ^ beginning of line
- . single character
- $ end of line
- [] matches one of any in block
- , repeat the last f F t or T command in the reverse direction
- / search down for the string specified after
- repeat the last f F t or T
- ? search up for string specified after
- F search the current line backwards for the character specified after
- N repeat the last / or ? in the opposite direction
- T search the current line for the character specified after
- f search for a character move to that character
- n repeat last / or ?
- t search for character and move after it
To go into the EX editor (line editor) type :
- ab string strings Abbreviation. Inserts strings when string is typed so ab usa United States of America
- map keys new_seq Lets you map a key or sequence of keys to another key or sequence of keys
- q quit
- q! quit without saving
- s/pattern/to_pattern/options Substitute. Without options, only once g is global
- una string undo abbreviations
- vi filename starts editing a new file
- w save the current file
- w >> filename Append to file
- wq save and quit
Buffers can be accessed with " but if no buffer is specified the general buffer is used.