VI Basic Commands: DW D DD
VI Basic Commands: DW D DD
VI Basic Commands: DW D DD
vi basic commands dw
D delete the remainder of the line after the cursor.
Summary of most useful commands dd delete the current line.
©Copyright 2017-2005, Free Electrons, http://free-electrons.com. Latest update: Feb 8, 2017
Free to share under the terms of the Creative Commons Attribution-ShareAlike 3.0 license. Electronic copies, sources, Repeating commands
translations and updates: http://free-electrons.com/doc/legacy/command-line/. Thanks to: Liubo Chen.
. repeat the last insertion, replacement or delete command.
Entering command mode
Looking for strings
[Esc] Exit editing mode. Keyboard keys now interpreted as commands.
/string find the first occurrence of string after the cursor.
Moving the cursor ?string find the first occurrence of string before the cursor.
h (or left arrow key) move the cursor left. n find the next occurrence in the last search.
l (or right arrow key) move the cursor right. Replacing strings
j (or down arrow key) move the cursor down.
k (or up arrow key) move the cursor up. Can also be done manually, searching and replacing once, and then using
[Ctrl] f move the cursor one page forward . n (next occurrence) and . (repeat last edit).
[Ctrl] b move the cursor one page backward. n,ps/str1/str2/g between line numbers n and p, substitute all (g:
^ move cursor to the first non-white character in the current line. global) occurrences of str1 by str2.
$ move the cursor to the end of the current line. 1,$s/str1/str2/g in the whole file ($: last line), substitute all
G go to the last line in the file. occurrences of str1 by str2.
nG go to line number n.
[Ctrl] G display the name of the current file and the cursor position in Applying a command several times - Examples
it. 5j move the cursor 5 lines down.
30dd delete 30 lines.
Entering editing mode 4cw change 4 words from the cursor.
i insert new text before the cursor. 1G go to the first line in the file.
a append new text after the cursor.
o start to edit a new line after the current one. Misc
O start to edit a new line before the current one. [Ctrl] l redraw the screen.
J join the current line with the next one
Replacing characters, lines and words u undo the last action
r replace the current character (does not enter edit mode).
s enter edit mode and substitute the current character by several Exiting and saving
ones. ZZ save current file and exit vi.
cw enter edit mode and change the word after the cursor. :w write (save) to the current file.
C enter edit mode and change the rest of the line after the cursor. :w file write (save) to the file file.
:q! quit vi without saving changes.
Copying and pasting
yy copy (yank) the current line to the copy/paste buffer. Going further
p paste the copy/paste buffer after the current line. vi has much more flexibility and many
P Paste the copy/paste buffer before the current line. more commands for power users!
It can make you extremely productive
Deleting characters, words and lines in editing and creating text.
All deleted characters, words and lines are copied to the copy/paste Learn more by taking the quick tutorial:
buffer. just type vimtutor.
x delete the character at the cursor location.