Vim: Difference between revisions

From Psygen Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 24: Line 24:
<code>/<i>string</i></code> search forward for <i>string</i>
<code>/<i>string</i></code> search forward for <i>string</i>


?string
<code>?<i>string</i></code> search backword for <i>string</i>
search backword for string


CTRL + f
<code>CTRL + f</code> scroll forward one screen
scroll forward one screen


CTRL + b
<code>CTRL + b</code> scroll backword one screen
scroll backword one screen


%
<code>%</code> go to the "mate", if one exists, of the parenthesis, brace, or bracket.
got the "mate", if one exists, of the parenthesis, brace, or bracket.


== Manipulating Text ==
== Manipulating Text ==
<code>u</code> undo the latest change
<code>:earlier 15m</code> reverts the document to how it was 15 minutes ago. You can substitute any valid time instead of 15m.

Revision as of 03:03, 19 December 2016

Modes

i goes into insert mode

Esc goes back to command mode.

Commands

Saving and Exiting vim

ZZ Save and exit vim

:w Write the file to disk, stay in vim

:w !sudo tee % Saves the file, even you don't have permission to write to the file (do this instead of closing the file, opening with sudo, and re-doing your changes)

:wq Save the file and exit vim

:q</code Quit vim (Note: if you've made changes, you'll get a message that the file has changed. To quit without saving changes, use: :q! )

Navigating Within the Document

/string search forward for string

?string search backword for string

CTRL + f scroll forward one screen

CTRL + b scroll backword one screen

% go to the "mate", if one exists, of the parenthesis, brace, or bracket.

Manipulating Text

u undo the latest change

:earlier 15m reverts the document to how it was 15 minutes ago. You can substitute any valid time instead of 15m.