Anda di halaman 1dari 13

.TH command 1vim *command.

1vim*
NAME
vim,command \- command line editor
================================================================================
CURSOR MOVEMENT {{{1
w
W
b
B
0
^
$

Advance a word (known separators: space, *, _)


Advance a word (the separator is only the space)
jump backwards to words (puntuaction considered words as w)
jump backwards to words (only spaces considered)
start of the line
First non blank character of the line
end of line

================================================================================
EDITING {{{1
dd
dw
D
J
xp
u
\.

Delete line
Delete word
Delete from cursor to the end of the row
Join the line below to the current one.
tranpose two letters (delete and paste)
undo
repeat last editing command

================================================================================
VISUAL MODE (MARKING TEXT) {{{1
v
start a visual mode
V
start a line visual mode
Ctrl + v start visual block mode
Visual block mode
Modifications in one line are done in all lines. To put a block comment, press c
trl+v, select lines, type I and type //. The escape. all lines will be commented
.
In
>
<
y
d
~

visual mode
shift right
shift left
yank marked text
delete marked text
switch case

================================================================================
AUTOCOMPLETION {{{1
Ctrl + x Ctrl + <key> insert mode
Activate autocompletion mode (^x mode). You can type as key the followin
g to do autocompletion
Ctrl + n
Token autocompletion. Can be used without typing Ctrl + x before.
Ctrl + l
line autocompletion

Ctrl + f
file autocompletion. Autocomplete word with the name of file of the current path
.
================================================================================
MACROS {{{1
Macros are stored in registers.
Modify a macro
If the macro is in register reg type in a new line.
"reg p: print the register (so the macro).
Modify the command
0"reg y$: Move to the beginning of the line, copy the entire line to the registe
r
q <macro_name> <record_macro> q
Only one letter name is permitted.
x@<macro_name>
Executes the macro x times (without the x only 1 time is executed).
================================================================================
BOOKMARKS {{{1
m<bookmark_name>
Assign <bookmark_name> as a bookmark (only one letter).
'<bookmark_name> (this apostrophe is in ? key)
Goes to exact position.
`<bookmark_name> (this apostrophe is in key at the right of p)
To go to macro beginning line position
:marks
Show all bookmarks.
Default
'
[
]
<
.
>
.

bookmarks
position before of the latest jump or where last m was given.
To the line first character of the previously modify or yanked.
same as [ but with last.
First line first selected character in the last visual mode visual mode
same that < but with last.
position where the last change was made.

================================================================================
EX COMMANDS {{{1
:[execute] 'com1' | 'com2'
executes com1 and then com2
:normal normal_mode_command

Executes in ex mode a normal mode command.


For example, to print the value of the register " you will do p in normal mode.
You can do the same from ex mode by typping
:100 normal "ayy
copies line 100 into register a.
:normal p
:let var_name=system('comm')
executes comm and let the result in the variable let. To get the result do echo
var_name.
system is used to execute external commands
:shell
Opens a shell where you can type commands
:! command %
Executes command over the current file. You can do this with whatever command.
:r command or file
Executes command and put the output in the current buffer. You can specify lines
also. if instead a command is a file, read from file and place it in the buffer
.
================================================================================
REGISTERS AND VARIABLES {{{1
:let a=6
Assign 6 to variable a.
:echo a
prints the value of variable a.
:let @a=6
Assign 6 to register a. 7
:echo @a
Prints the value of register a.
"<registry_name>p
Prints the value of a register in the working document . For example, "ap.

================================================================================
LINE COPY {{{1
yy
Copy the current line.
"ayy
Copy the current line to a. First is necessary to do "a to prepare a as a buff
er.

"Ayy
Copy the current line to a concatenating it with the previous stuff.
================================================================================
COMMAND HISTORY {{{1
:his
Show the command history
:his /
Search in the command history
q: or q/
Opens command history in an editor window (the second options is for searches).
You can edit a command from that windows and execute it typing return. To exit,
press Esc twice or Ctrl+c.

================================================================================
OTHER COMMANDS {{{1
Ctrl + o (in insert mode)
Allow to introduce a vim command and then getinto insert mode again.
gq
reflow. Correct the format of the text. For example, if one addition caused the
text to overcome the wrap width.
=
fix indentation. gg=G (go to beginning of the file, fix identation until the end
of the file).
================================================================================
DIGRAPHS AND CODES {{{1
To insert a digraph you must type Ctrl+k before to type the code . With the
Ctrl + v option is possible to instroduce non-printable characters like <return
>.
:set [no]digraph
Activate [deactivate] another form to insert digraph. The form is char1 <BS> c
har2 where <BS> means backspace (delete key)
Ctrl+k <digraph_code> (In insert mode)
Insert the digraph that corresponds to <digraph_code>.
Ctrl+v {u|x} <code> (In insert mode)
Insert a digraph or character by its {unicode|hexadecimal} code. Hexadecimanl ad
mits 2 numbers, unicode 4.

ga (get ascii) or :as or :ascii


Show the code in decimal, octal and hexadecimanl corresponding to the character
under cursor
:digraphs
Show all digraphs of vim.
MOST USED {{{2
symbol
desc
code
small arrow ^v u 2023

small point ^v u 2022

square
^v u 25a1

schwa
^v u 018f

GENERAL {{{2

x
x

plus minus
superscript
subindex
coproduct
summation
dot product
square root
inifinity
left arrow
right arrow
up arrow
down arrow

Code: +Code: 2S
Code: 2s
Code: *P
Code: +Z
Code: Sb
Code: RT
Code: 00
Code: <Code: ->
Code: -!
Code: -v

LOGIC AND CALCULUS {{{2

for all
partial differential
there exists
logical and
logical or
empty set
in, element of
integral
double integral
nabla
tilde operator
approximately equal to
not equal
less than or equal to
greater than or equal to

Code:
Code:
Code:
Code:
Code:
Code:
Code:
Code:
Code:
Code:
Code:
Code:
Code:
Code:

GREEK LETTERS {{{2

delta
theta
i
sigma
hi

Code:
Code:
Code:
Code:

D*
H*
P*
*
Code:

*

FA
dP
TE
AN
OR
/0
(In
Code:
NB
?1
?=
!=
=<
>=

DI

}}}2

hi
omega
lph
et
elta
psilon
ambda
mu
ho
au
si

Code:
f*
Code:
W*
Code:
*
Code:
*
Coe:
*
Cod:
*
Code:
*
Code:
m*
Code:
*
Code:
*
Code:

Moe diga hs a : h ://www.aecjacobson.com/webog/? =443


Unicode codes of Ma h s mbos: h ://s mbocodes.  . su.edu/b anguage/ma hcha
 .h m
IO CODE
h ://f .vim.og/ne woking/kemi / ubic_h m/u f8- 1.h m.~6~
================================================================================
MAPPING {{{1
To see sugges ions of ma ings, e :he ma -which-ke s.
:ma [!] <ke > se
uence
ma se
uence o ke .
ma woks in noma, visua, seec modes. ma ! woks in inse and command in
e mode.
:ma [!]
Lis ma s. o is s ecific mode ma s,
o he mode.

e end ma wi h he e e coes onding

:unma [!] ke
Remove ke fom ma s.
"ke s in ma ing"
You can en e ke s i ea . To inse
h ://vim.wikia.com/wiki/Ma ing_ke s_in_Vim_-_Tu oia_(Pa _1)
h ://vim.wikia.com/wiki/Ma ing_ke s_in_Vim_-_Tu oia_(Pa _2)
================================================================================
ABBREVIATION {{{1
'':[ic!]ab'' ma _ke con en
When ou wi e ma _ke <s ace> i wi be subs i u ed b con en . The e es
inside backe s indica e we he he abbevia ion is done in inse mode, command
mode o bo h.
'':ab''
hows he abbevia ons
'':una'' ma _ke
Dee e ma _ke as abbevia ion

================================================================================
WORKING WITH ILE, TAB AND WINDOW {{{1
vim [{-o-O- }] <fie1> <fie2> ...
O en <fie1> <fie2> ... in diffeen window. Wi h -o o ion o ens hem in he
same window se aa ed b hoizon a ines, \fb-O ve ica ines o - in new a
bs..
:e fie
O en a fie in a new buffe (e of edi ).
:bdee e[!] [#]
Cose a buffe [ he buffe #] [wi hou saving changes (if ! was used)]
:s
Lis cuen buffes
:s i <fie>
 i he sceen in hoizon a and o en he fie <fie>
:vs i <fie>
 i he sceen in ve ica and o en he fie <fie>.
C +w[#]{+-}
{Incease/decease} he size of he window in # ows (defau 1).
c +w[#]{<>}
{decease/incease} he size of he window in # coumns (defau 1).
:[v]new
O en a new em window in hoizon a o [in ve ica].
:[ ab]f[ind] ex 
ook fo a fie caed ex  in he cuen a h. ex  can con ain widcads. O
en i in a window o in a ab ([ ab] used)
:s fiename
O en a fie in a new buffe and s i window
c  + ws
 i windows
c  + wv
 i windows ve ica
:new
O en a new em window.

:nex : evious
Go o he nex o evious fie.
C +w <diec ion_aow>
Move o he window in he diec ion of he aow.
:se
Bind
e
ou

[no]scobind
[o unbind] sevea windows o sco in same amoun . This command has o b
e in each window ha has o be bind. If ou wan o com ae wo fies, ma
ae in ees ed in vimdiff, see vimdiff(11 oos).

: abe [fie] o : abnew [fie]


O en a new ab wi h fie o edi
: abn o : ab // [#]g o gT
swi ch o nex o evious ab. if # is s ecified, move o ab numbe #.
C  + W T (T is in u ecase)
Move cuen  s i sceen o i s own ab.
: abc[ose]
Cose he cuen ab
: abmove [{0,#}]
move cuen ab o he end, beginnig in case of 0 o he

osi ion #.

: abs
show he cuen ab ages and he windows he con ain. hows > fo he cuen
one and + fo modified.
: abd[o] {cmd}
execu es cmd in each ab.
C +g
Name of he fie and numbe of ines. Pecen age of he fie coes onding o cu
so osi ion.
:e
Reoad, efesh an o en fie.
gg
Go o he beginning of he fie.
G
Go he end of he fie.
:se ines=num_ coumns=num_c

se ines of he cuen window o num_ and he numbe of coumns o num_c.


================================================================================
CROLLING {{{1
c  +
one ine u
c  + u
co Haf a age u .
c  + b
one age u
c  + e
one ine down
c +d
sco haf a

age down.

c  + f
one age down
================================================================================
OLD {{{1
Thee is sevea modes of fods. You can ook a i in |o ion.1vim|, in
|fod-o ion.1vim|.
The defau make is hee cu baces { { { # (wi hou s aces, # is a numbe
fo he de h of he fod). The numbe is o iona.
To conseve he s a e of he fods fo a fie, see |sec ion-views|.
zo
O en fod
zO
o en fods unde he cuso ecusive .
zc
cose fod unde he cuso
zC
cose fod unde he cuso ecusive
za
if o en hen cose he fod. If cose, hen o en he fod.
zv
o en enough fods so he ine whee he cuso a eas no foded (visibe)
z

Reduce foding (add 1 o fodeve)


zR
o en a fods
zm
decease fodeve in 1. (fod moe)
zM
cose a fods (se fodeve o 0)
zd
dee e a fod. Chid fods one eve u
zD
dee e fod ecusive
zn (fod none)
ese fodenabe. a fods wi be o enned.
zN (fod noma)
se fodenabe. ods a ea as he wee.

ange fodo[ en][!]


O en he fods in he ange. Aso wi h cose ins ead of o en. Wi h ! o en a fo
ds.
zf (in manua mode)
coa se ex
-------------------------------------------------------------------------------moving hough fods
[z
Jum o he s a of he cuen o en fod. If aead a he s a , jum
s a of he fod con aining i .

o he

]z
Move o end. If aead in he end, o he end of he con aining fod.
zj
Move downwads o he nex fod.
zk
Move u wads o he nex fod.
-------------------------------------------------------------------------------execu ing in fods

ange fodd[oo en] cmd


execu es cmd on a he ines ha ae no in a cosed fod.
Exam e
:foddoo en s/end/oo _end/ge

ange fodd[ocosed] cmd


execu e cmd in he ines of a cosed fod.
================================================================================
IND, EARCH AND REPLACE {{{1
:se [no]hseach
ac iva e [deac iva e] hihgigh when seach fo a wod.
:se [no]ignoecase
ignoe [no ignoe] he case in he seachs.
*
go o he nex wod ha ma ches wi h he wod unde he cuso.
shif + *
Done ove a wod. ind he nex occuence of he wod.
/<wod>
each fo <wod> in he ex . n seach he NEXT ma ch and N he PREVIOU ma ch
.
A G + #
each fo defini ion of a wod. o exam e, in a C ogam.
gd
jum

o oca decaa ion of he wod unde he cuso.

:[%-#,#]s/<text_to_replace>/<new_text>/[gc]
Replace the first occurrence of <text_to_replace> in the current line . If
g is used, replace all occurrences in the current line . If c is used, ask
for comfirmation. If % is used, replace occurrences in the whole document .
If #,# is used, replace text between lines # and #. If #=. indica es he cuen
ine . If #=$ indica es he end of he documen .
================================================================================
ORMAT AND EDITOR APECT CHANGE AND ET COMMAND {{{1
:se au oinden
:se cinden
:se abs o =4
Tabs of 4 s aces.

:se [no]numbe
how o [hide] he ine numbes
:se w=wid h
e he ine wid h ( w= ex wid h) o wid h chaac es. Do g
wi h seec ed i
nes o efow. Wods ha exceed his imi wi no be h hen.
:se shecmdfag=i
ags assed o she when using :! {comm} . The execu ion wi h :! {comm} in sh
e is done as if i was invoked in eac ive if -i ae assed bu exi s fom v
im.
:se un ime a h[?]
in he un ime a h wi h ? o ion. Run ime a h is a vaiabe wi h a hs ha
vim ooks fo fies. ou can add a hs b ing = o += ( o a end).
================================================================================
MICELLANEOU {{{1
g

Refow ex . If an a ibu e of he documen has changed.


================================================================================
YNTAX AND HILIGHTING {{{1
s n ax mus be on. If i is no , e in command mode :s n ax on.
 n ax fies ae oca ed in
/us/shae/vim/vim73/s n ax
:se fie e
Check wha fie e is being used o highigh code
:se fie e= e o :se f e
oces o use he highigh ues of fie e e.
================================================================================
EION {{{1
 oe he buffes ou have o enned o o en hem a e.
:mksession[!] name_of_fie
 oe he session in name_of_fie.
:souce name_of_fie
Load he session.
================================================================================
VIEW {{{1
*sec ion-views*

mkview [numbe]
save he s a e of he fods fo he fie. You can give a numbe as id o es oe
wi h oadview.

oadview [numbe]
es oe he s a e of he fods fo a fie saved wi h mkview. You can give i a n
umbe as an id.
================================================================================
PREDEINED VARIABLE OR TOKEN {{{1
%
name of he cuen fie which we ae woking on.
================================================================================
PRINT THE PAGE {{{1
:hadco > fie. s

H REERENCE
REERENCE {{{1
h ://bog.sesa u.com/w -con en /u oads/Chue aVim-sim e. ng

Anda mungkin juga menyukai