0% found this document useful (0 votes)
26 views1 page

Devhints Io Vim

Uploaded by

hrytsevivan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views1 page

Devhints Io Vim

Uploaded by

hrytsevivan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

DEVHINTS.

IO Edit

Vim cheatsheet

Introduction Exiting Exiting insert mode

:q Close file Esc / <C-[> Exit insert mode


Vim is a very efficient text editor. This reference was
made for Vim 8.0.
:qa Close all files <C-C> Exit insert mode, and abort
For shortcut notation, see :help key-notation. current command
:w Save

:wq / :x Save and close file

ZZ Save and quit

:q! / ZQ Quit without checking changes

Editing

Editing Clipboard Visual mode

a Append x Delete character v Enter visual mode

A Append from end of line dd Delete line (Cut) V Enter visual line mode

i Insert yy Yank line (Copy) <C-V> Enter visual block mode

In visual mode
o Next line p Paste

d / x Delete selection
O Previous line P Paste before

s Replace selection
s Delete char and insert "*p / "+p Paste from system clipboard
y Yank selection (Copy)
S Delete line and insert "*y / "+y Paste to system clipboard

C Delete until end of line and insert See Operators for other things you can do.

r Replace one character

R Enter Replace mode


Find & Replace
u Undo changes
:%s/foo/bar/g Replace foo with bar in whole
<C-R> Redo changes document

Navigating

Directions Character Window

h j k l Arrow keys fc Go forward to character c zz Center this line

<C-U> / <C-D> Half-page up/down Fc Go backward to character c zt Top this line

<C-B> / <C-F> Page up/down zb Bottom this line

H Move to top of screen


Document
M Move to middle of screen
Words gg First line
L Move to bottom of screen
b / w Previous/next word G Last line

ge / e Previous/next end of word :{number} Go to line {number}

{number}G Go to line {number} Search

{number}j Go down {number} lines n Next matching search pattern


Line
{number}k Go up {number} lines N Previous match
0 (zero) Start of line
* Next whole word under cursor
^ Start of line (after whitespace)
# Previous whole word under cursor
$ End of line

Operators

Usage Operators list Examples

d Delete
Operators let you operate in a range of text (defined by Combine operators with motions to use them.
motion). These are performed in normal mode.
y Yank (copy)
dd (repeat the letter) Delete
d w c Change (delete then insert) current line

Operator Motion > Indent right dw Delete to next word

< Indent left db Delete to beginning of word

= Autoindent 2dd Delete 2 lines

g~ Swap case dip Delete a text object (inside


paragraph)
gU Uppercase
(in visual mode) d Delete selection
gu Lowercase
See: :help motion.txt
! Filter through external program

See :help operator

Text objects

Usage Text objects Examples

p Paragraph vip Select paragraph


Text objects let you operate (with an operator) in or
around text blocks (objects).
w Word vipipipip Select more

v i p s Sentence yip Yank inner paragraph

Operator [i]nside or [a]round Text object [ ( { < A [], (), or {} block yap Yank paragraph (including newline)

' " ` A quoted string dip Delete inner paragraph

b A block [( cip Change inner paragraph

B A block in [{
See Operators for other things you can do.

t A XML tag block

Diff

gvimdiff file1 file2 [file3] See


differences
between files,
in HMI

Misc

Tab pages Marks

:tabedit [file] Edit file in a new tab `^ Last position of cursor in insert mode

:tabfind [file] Open file if exists in new tab `. Last change in current buffer

:tabclose Close current tab `" Last exited current buffer

:tabs List all tabs `0 In last file edited

:tabfirst Go to first tab '' Back to line in current buffer where jumped from

:tablast Go to last tab `` Back to position in current buffer where jumped from

:tabn Go to next tab `[ To beginning of previously changed or yanked text

:tabp Go to previous tab `] To end of previously changed or yanked text

`< To beginning of last visual selection

`> To end of last visual selection


Folds
ma Mark this cursor position as a
zo / zO Open
`a Jump to the cursor position a
zc / zC Close
'a Jump to the beginning of the line with position a
za / zA Toggle
d'a Delete from current line to line of mark a
zv Open folds for this line
d`a Delete from current position to position of mark a
zM Close all
c'a Change text from current line to line of a
zR Open all
y`a Yank text from current position to position of a
zm Fold more (foldlevel += 1)
:marks List all current marks
zr Fold less (foldlevel -= 1)
:delm a Delete mark a
zx Update folds
:delm a-d Delete marks a, b, c, d
Uppercase ones are recursive (eg, zO is open recursively).
:delm abc Delete marks a, b, c

Navigation
Misc
% Nearest/matching {[()]}
. Repeat last command

[( [{ [< Previous ( or { or <


]p Paste under the current indentation level

]) Next
:set ff=unix Convert Windows line endings to Unix line endings

[m Previous method start

[M Previous method end


Command line

<C-R><C-W> Insert current word into the command line

Jumping
<C-R>" Paste from “ register

<C-O> Go back to previous location


<C-X><C-F> Auto-completion of path in insert mode

<C-I> Go forward

gf Go to file in cursor
Text alignment

:center [width]
Counters :right [width]
:left

<C-A> Increment number


See :help formatting
<C-X> Decrement

Windows Calculator

z{height}<Cr> Resize pane to {height} lines tall <C-R>=128/2 Shows the result of the division : ‘64’

Do this in insert mode.

Tags

:tag Classname Jump to first definition of Classname Exiting with an error

<C-]> Jump to definition


:cq
:cquit
g] See all definitions

<C-T> Go back to last tag Works like :qa, but throws an error. Great for aborting Git commands.

<C-O> <C-I> Back/forward

:tselect Classname Find definitions of Classname


Spell checking
:tjump Classname Find definitions of Classname (auto-select 1st)
:set spell spelllang=en_us Turn on US English spell checking

]s Move to next misspelled word after the cursor


Case
[s Move to previous misspelled word before the
~ Toggle case (Case => cASE) cursor

gU Uppercase z= Suggest spellings for the word under/after the


cursor
gu Lowercase
zg Add word to spell list
gUU Uppercase current line (also gUgU)
zw Mark word as bad/misspelling
guu Lowercase current line (also gugu)
zu / C-X (Insert Mode) Suggest words for bad word under cursor
from spellfile
Do these in visual or normal mode.

See :help spell

Also see

Vim cheatsheet (vim.rotrr.com)

Vim documentation (vimdoc.sourceforge.net)

Interactive Vim tutorial (openvim.com)

17 Comments for this cheatsheet. Write yours!

devhints.io / Search 357+ cheatsheets

Other Vim cheatsheets Top cheatsheets

Vimdiff Vim scripting Elixir ES2015+


cheatsheet cheatsheet cheatsheet cheatsheet

Over 357 curated


cheatsheets, by developers Tabular Projectionist React.js Vimdiff
for developers. cheatsheet cheatsheet cheatsheet cheatsheet

Devhints home
Vim digraphs Vim Easyalign Vim scripting Vue.js
cheatsheet cheatsheet cheatsheet cheatsheet

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy