- Vim Version
vim --version
-
View Runtimepath (inside Vim)
:echo &runtimepath
-
Which scripts are loaded
:scriptnames
-
View where a setting was loaded from
:verbose set <setting name>(for example::verbose set background)
- Navigating
- Move to top of screen (Higher)
shft-h
- Move to Middle of screen
shift-m
- Move to Lower of screen
- Move to top of screen (Higher)
shift-l
-
What Line # am I on?
:set number
-
GOTO Line #
<esc>#shift-g
-
GOTO Line #
:#
-
GOTO Last Line
shift-g
-
Input Mode
[ESC]- to end inut.- repeat last editing command# command- repeat command, # times/string/- find patterna- append character modeA- append at EOLcw- change wordd- delete one characterdd- deline linedw- delete wordG- End of Filei- insertO- open/insert linep- paste/put buffer (re: paste a yanked line)r- replace characterR- Replace Charactersx- delete one charactery- yank (copy) a lineyy- copy line in buffer[n]yy- copy [n] lines to the buffer
-
Command Mode
:n- goto line n:q- quit:q!- quit, no save:r file- import file:u- Undo last command:redo- redo:w- write:wq- write & quit
-
Line Numbering
- ON
:set number | nu
- OFF
:set nonumber | nonu
- ON
-
Copy Selection, with Mouse
- In the vim command line to enable copy/paste of text selected using the mouse.
:set mouse&
-
Copy from-to lines, to current cursor position
- Example:
:81,91t.<enter>- This will paste the lines 81-91 under the line the cursor is on.
- Example:
-
Replace text
- http://vim.wikia.com/wiki/Search_and_replace
:%/original_text/new_text/
- https://stackoverflow.com/questions/19994922/find-and-replace-strings-in-vim-on-multiple-lines
%s/foo/bar/g- global search and replace, within the file6,10s/foo/bar/g- search for foo and replace with bar, scoped for just lines 6 to 10.for range in split('6,10 14,18')| exe range 's/<search_string>/<replace_string>/g'- across multiple line number ranges
- http://vim.wikia.com/wiki/Search_and_replace