Quantcast
Channel: Vimタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 5608

Vim notes

$
0
0

Vim Resources

VIM QUICK REFERENCE CARD

Vim Tutorial

vimtutor

To repeat the last change.

. (dot) 

Undo

:edit! # get into the earliest saved state.

Indent

# indent a line 

 >> 

# Indent three lines.

>>j.j. # or >3> or 3>>

# Indent from cursor to the end
>G

Delete

# Change
c

# To delete the character under the cursor.
    x 

# Delete three characters
    x... # or 3x

# To delete the current line
    dd 

# Delete two lines
dd.  # or d2d or 2dd

# Delete upto the end of line and ready to type.
    C #or c$, c stands for change

# Delete one letter and enters Insert mode.
    s # or cl

# Delete the line and enters Insert mode.
    S # or ^C

# Delete a word
daw

# Delete backward
db

# Delete forward
dw

# Delete up to the second comma
d2t,

Move around

# move to the beginning of the line
0

# move to the first non-blank
^

# word, end and back
w # W
e # E
b # B

# Move to the beginning of the line and chnage to the insert mode.
    I or ^i

# Move to the end of line and enters Insert mode.
A # or $a

# move backward by word
b

# move forward by word
w

# move to the beginning of the line
0

# find, find backward
f # F

# find till, find till backward
t # T

Move and insert

# Replace mode, enter insert mode with typing over existing characters
R   

# Append, move to the end of line and insert mode
A

# Open below. Insert a new line under the current line and enters Insert mode.

o # or A<CR>

# Open above. Insert a new line above the current line and enters Insert mode.

O # or ko

# Undo,  redo and undo all in the line
    u
    ^R
    U 

To end vim

ZZ # write and quit
:q! # without write and quit
:e! # return to the original

Saving files

:w! # to overwrite
:w filename # to save to a newfile

Help

:h # or :help
ZZ # to end help
# on a tag 
^] # will move to that tag
# going back
^t
#  get the help on yank
:h yank
# get the help on ^A
:h ^a
# get the help on ^h with the insert mode
:h i_^h

Repeatable change

# find +
f+
# s deletes the character and then enters insert mode
# enter changes space + space
s + 
# repeat the last search
;
# repat
.
# repeat search and replace
;.

Search

# scan line for next character 
fx
# scan line for previous charcter
Fx
# scan line for next character and move to the left of the letter x
tx
# scan line for previous character and move to the right of the letter x
Tx
# scan document for next match
/pattern<CR>
# scan document for previous match
?pattern<CR>
# will search for the word under the cursor
* 
# clear word(cw)(and change to insert mode) and type new word
cwnewword<ESC>
# next search
n
# repeat the change
.

Repeat and reverse

# repeat fx, Fx, tx, Tx
;
# reverse fx, Fx, tx, Tx
,
# repeat /pattern or ?pattern
n
# reverse /pattern or ?pattern
N

Substitue

Search and replace
s[ubstitute]

:s/target/replacement
# repeat substitue
&
# reverse it
u
# g-flag for global
:s/foo/bar/g    # Change each 'foo' to 'bar' in the current line.
:%s/foo/bar/g   # Change each 'foo' to 'bar' in all lines.

Spell checking

:set spell spelllang=en_us
# set locally
:setlocal spell spelllang=en_us
# turn off spelling
:set nospell

# find next misspelled word
]s
# find previous misspelled word
[s

# find alternatives
z= # and type number

Viewing all articles
Browse latest Browse all 5608

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>