Professional Documents
Culture Documents
1" Tips
vi!1" Tips
Essential vi/vim Editor Skills
by
Jacek Artymiak
First Edition
Lublin 2008
!i"1# Tips, 1st ed. by Jacek Artymiak
Published by devGuide.net
www: http://www.devguide.net/books/vitips1
email: jacek@devguide.net
08! 10 9 8 7 6 5 4 3 2 1
ISBN: 978"83"60869"00"0
The author and the publisher disclaim any and all liability for the
use of information and programs contained in this book.
Chapter 1: Essentials## # # # 3
! PANIC!!! ! ! ! ! 5
! Canceling Commands! ! ! ! 5
! Switching Between Command Mode and
! ! Insert Mode! ! ! ! 6
! Escaping from the ex Editor Mode! ! 6
! Unscrambling the Screen!! ! ! 6
Chapter 2: Basic File Operations# # # 7
! Starting vi#1$! ! ! ! ! 9
! Starting vi#1$ and Opening a File for Editing! 10
! Starting vi#1$ and Opening Multiple Files for
! ! Editing! ! ! ! ! 11
! Switching Between Files! ! ! ! 13
! Opening a File after Starting vi#1$! ! ! 14
! Saving the Current File! ! ! ! 15
! Forcing vi#1$ to Save the Current File! ! 16
! Saving the Current File Under a Di%erent Name! 17
! Saving a Part of the Current File! ! ! 18
! Saving a Part of the Current File Under a
! ! Di%erent Name! ! ! ! 19
! Appending the Current File to Another! ! 20
! Appending a Part of the Current File to Another! 21
! Saving the Current file and Quitting vi#1$! ! 22
! Forcing vi#1$ to Save the Current File and Quit! 23
! Table of Contents "
! Entering Text! ! ! ! ! 55
! Inserting Lines! ! ! ! ! 57
! Inserting Files! ! ! ! ! 59
! Table of Contents "
! Running Commands! ! ! ! 91
! Sending vi#1$ to the Background! ! ! 92
! Shell Access! ! ! ! ! 92
Index ## # # # # # 95
List of Tables
Table 1: UNIX filename wildcards.! ! ! 12
Table 2: Motion commands.! ! ! ! 66
Table 3: Regular expressions.! ! ! ! 76
Index
! Index "
A lines, 82%83
arrow keys, 29%30, 63 words, 81
Page 97
! Index "
first, 34 F
last, 34 file operations, 6
next, 34
previous, 34 filename, 11%12 , 17, 59
start of the line, 33%34 changing, 17
paragraph, wildcard, 11%12
next, 45%46 testing, 11
previous, 45%46
screen, file, 10%11, 13%24, 26, 59
bottom of, 38, 51 access path, 10, 19, 59
middle of, 38, 51 appending to, 20
top of, 38, 51 a part of, to another, 21
sentence, current, 20%22, 24%26, 59
next, 44 forcing to save and quit, 23
previous, 44 editing, 10%11
word, forced saving the current, 16
end of, 43 inserting, 59
next, 43 location, 17
previous, 43 opening, 10, 14
screen, half a opening multiple, 11
down, 38, 40 read"only, 23
up, 38, 40 recovery, 26
search match, saving, 22
next, 50 a part of, 18
previous, 50 under a di%erent name, 19
current, 15
cutting text, see deleting quitting, 22
under a di%erent name, 17
D switching between, 13
deleting, 67, 69%71, 73%75, 80, 84
characters, 71 I
lines, 70%71, 73%75 insert mode, 6, 29, 55, 58, 63, 69%70
words, 71, 73
inserting, 55, 57
display, adjusting, 51 empty lines, 57
above the current line, 57
E below the current line, 57
editing, text, 10%11, 13%14, 17, 22%24, text, 55
53, 55, 63, 67, 91
J
entering, text, 55, 63 joining, lines, 85
ex mode, 6
Page 98
! Index "
L up, 66
lines, 6, 21, 61 word,
blocks of, 21, 61 end of, 66
long, 6 next, 66
previous, 66
line, 9, 30, 36, 70
current, 60 N
empty, 9 numbers, 87
number, 36, 70 decrementing, 87
source, 30 incrementing, 87
target, 30
O
lowercase, 86 out of control, 5
M overtype mode, 67
markers, 9, 48, 60%61,63, 77, 82
~, 9 P
end of region, 63 panic, 5
Page 99
! Index "
Page 100
! Index "
scripts, 91 Y
yank, see yanking
searching, 50, 77 yanking, 80
backward, 50
forward, 50
shell access, 92
T
text editor, 6
tricks, 89
U
undo, 87
history, 87
uppercase, 86
V
vi, 9%11, 22, 24%25, 92
forcing to quit without saving, 25
quitting without saving, 24
quitting, 22, 92
starting, 9%11
W
way out, 5
whitespace, 43
wrapping lines, 62
Page 101