vim
into a terminal.~/Source Code/vim/
that I can gain access to by typing out the complete path to the Vim binary file.vim
in a terminal or xterm to point to my new version in ~/Source Code/vim/
?~/Source Code/vim/
for executables before any other directory, so it will find the vim
there instead of the vim
in /usr/bin/
.visual
command in the extended line editor for UNIX--ex, for short. 10dd
, that string would be written to the temporary file, as shown in Figure 1. 10dd
would delete the 10 lines from the temporary file starting from where the cursor is currently placed, as shown in Figure 2. Command | Action |
---|---|
h | Move cursor left |
j, Plus Sign (+), Enter, or Return | Move cursor down |
k, Minus Sign (-) | Move cursor up |
l | Move cursor right |
} | Move cursor to the end of the current paragraph |
{ | Move cursor to the beginning of the current paragraph |
) | Move cursor to the end of the current sentence |
( | Move cursor to the beginning of the current sentence |
^ | Move to the first non-blank character in the current line |
$ | Move to the end of the current line |
0 (zero) | Move to the beginning of the current line |
w or W | Move to the beginning of the next word |
b or B | Move to the beginning of the previous word |
e | Move to the end of the next word |
H | Move to the first line of the screen |
M | Move to the middle line of the screen |
L | Move to the last line of the screen |
G | Move to the end of the file |
gg | Move to the beginning of the file |
:n | Move to line n |
Command | Action |
---|---|
d | Delete region selected |
dd | Delete the entire current line |
10dd | Delete 10 lines, starting with the current line |
dw | Delete words from the current position onward |
db | Delete words from the left of the current cursor position backwards |
dl | Delete the character at the current cursor position |
dh | Delete the character to the left of the current cursor position |
d0 (zero) | Delete text from the current cursor position to the beginning of the line |
D | d$ | Delete the entire line starting at the current cursor position |
x | Delete the character at the cursor's current position |
X | Delete the character before the cursor's current position |
Command | Action |
---|---|
ih | Enter insert mode and insert at the current cursor position |
I | Enter insert mode and insert at the beginning of the current line |
a | Enter insert mode and append after the cursor |
A | Enter insert mode and append to the end of the current line |
c | Change the region selected |
C | Change the entire line starting at the cursor's current position |
o | Create a new blank line beneath the line in which the cursor is currently located and move the cursor to the beginning of the new blank line |
O | Create a new blank line above the line in which the cursor is currently located and move the cursor to the beginning of the new blank line |
r | Replace a single character at the cursor's current position |
R | Replace multiple characters starting at the cursor's current position and ending when exiting insert mode |
<Esc> | Exit insert or visual mode |
> or <Tab> | Indent to the right the region selected |
< | Indent to the left the region selected |
v | Start highlighting characters |
V | Start highlighting entire lines |
yy | Yank/Copy the current line into memory |
10yy | Yank/Copy 10 lines starting with the current line into memory |
p | Put text yanked or deleted; if characters were yanked (yw dw , or D ), put the characters after the cursor's current position. If lines were yanked, put the lines below the cursor's current line. |
P | Same as p , but place characters before the cursor's current position or lines above the cursor's current line |
u | Undo the last change |
<Ctrl> R | Redo |
/<pattern> | Search for the next pattern found, and place the cursor at the beginning of the pattern found |
?<pattern> | Search for the previous pattern found, and place the cursor at the beginning of the pattern found |
n | Repeat the last search |
N | Repeat the last search, but reverse the search direction |
!<cmd> | Execute <cmd> outside the Vim session |
:
). The cursor then moves to the lower-left corner of the window. When you resume typing, all text appears after the colon at the bottom of the window. When you click Enter, the line mode command is evaluated and executed. If you decide not to execute the line entered in line mode, click Escape to return to command mode. ,
). :23
. If you want to modify lines 2319 through 3819, you would type :2319,3819
. To process a command from a starting position of line 45 to the end of the file, replace the last line argument with a dollar sign ($
)—that is, :45,$
. :w <file name>
: Write the file to disk. If an argument is supplied, the editor attempts to write the data to <file name>. :w! <file name>
: Write the file to disk and overwrite any data in the file. :<x>,<y> w <file name>
: Write lines <x> through <y> to <file name>. :q
: Attempt to exit the editor without saving. :q!
: Exit the editor without attempting to write the file to disk. :n
: If editing multiple files, begin editing the next file in the edit list. :e <file name>
: Edit <file name>.:e#
: If editing two files, switch between files.:s/<str1>/<str2>/
: Replace the first occurrence of <str1> with <str2> on the current line. :1,$ s/<str1>/<str2>/g
: Starting at line 1 and continuing throughout the file, replace <str1> with <str2> globally. :r <file name>
: Read <file name> into the current editor session. :<x>,<y> d
: Delete lines <x> through <y>. :<x>,<y> y
: Yank lines <x> through <y>. vimdiff
is bundled with the Vim package. Using vimdiff
, you can display multiple files next to each other, similar to sdiff
, as shown in Figure 6. tar
. When editing a .tar file, Vim displays a handy screen allowing you to select which file in the archive you want to edit, as shown in Figure 7. When you finish editing the file, simply save and exit the file normally (:wq
), and Vim returns to the display, allowing you to select another file to edit in the archive, or you can quit from the selection window (:q
). tar
command, and then Vim was used to select the second file in the archive to edit. v
to enter visual mode, move the cursor through the text to be modified, then type d
to delete the highlighted text.