VI Cheats / Shorthands

Posted by Unknown Sabtu, 05 Januari 2013 0 komentar

Modes


Vi has two modes insertion mode and command mode. 

The editor begins in command mode, where the cursor can move and text deletion and pasting can work. 

Insertion mode begins upon entering an insertion or change command. 

[ESC] returns the editor to command mode

Quitting


:xExit, saving changes
:qExit as long as there have been no changes
ZZExit and save changes if any have been made
:q!Exit and ignore any changes

Inserting Text


iInsert before cursor
IInsert before line
aAppend after cursor
AAppend after line
oOpen a new line after current line
OOpen a new line before current line
rReplace one character
RReplace many characters


Motion


hMove left
jMove down
kMove up
lMove right
wMove to next word
WMove to next blank delimited word
bMove to the beginning of the word
BMove to the beginning of blank delimted word
eMove to the end of the word
EMove to the end of Blank delimited word
(Move a sentence back
)Move a sentence forward
{Move a paragraph back
}Move a paragraph forward
0Move to the begining of the line
$Move to the end of the line
1GMove to the first line of the file
GMove to the last line of the file
nGMove to nth line of the file
:nMove to nth line of the file
fcMove forward to c
FcMove back to c
HMove to top of screen
MMove to middle of screen
LMove to botton of screen
%Move to associated ( ), { }, [ ]


Deleting Text


xDelete character to the right of cursor
XDelete character to the left of cursor
DDelete to the end of the line
ddDelete current line
:dDelete current line



Yanking Text


yyYank the current line
:yYank the current line



Changing text


CChange to the end of the line
ccChange the whole line



Putting text


pPut after the position or after the line
PPut before the poition or before the line


Markers


mcSet marker c on this line
`cGo to beginning of marker c line.
'cGo to first non-blank character of marker c line.



Search for strings


/stringSearch forward for string
?stringSearch back for string
nSearch for next instance of string
NSearch for previous instance of string



Replace


:s/pattern/string/flagsReplace pattern with string according to flags.
gFlag - Replace all occurences of pattern
cFlag - Confirm replaces.
&Repeat last :s command



Regular Expressions


. (dot)Any single character except newline
*zero or more occurances of any character
[...]Any single character specified in the set
[^...]Any single character not specified in the set
^Anchor - beginning of the line
$Anchor - end of line
\<Anchor - begining of word
\>Anchor - end of word
\(...\)Grouping - usually used to group conditions
\nContents of nth grouping



[...] - Set Examples
[A-Z]The SET from Capital A to Capital Z
[a-z]The SET from lowercase a to lowercase z
[0-9]The SET from 0 to 9 (All numerals)
[./=+]The SET containing . (dot), / (slash), =, and +
[-A-F]The SET from Capital A to Capital F and the dash (dashes must be specified first)
[0-9 A-Z]The SET containing all capital letters and digits and a space
[A-Z][a-zA-Z]In the first position, the SET from Capital A to Capital Z
In the second character position, the SET containing all letters



Regular Expression Examples
/Hello/Matches if the line contains the value Hello
/^TEST$/Matches if the line contains TEST by itself
/^[a-zA-Z]/Matches if the line starts with any letter
/^[a-z].*/Matches if the first character of the line is a-z and there is at least one more of any character following it
/2134$/Matches if line ends with 2134
/\(21|35\)/Matches is the line contains 21 or 35
Note the use of ( ) with the pipe symbol to specify the 'or' condition
/[0-9]*/Matches if there are zero or more numbers in the line
/^[^#]/Matches if the first character is not a # in the line
Notes:
1. Regular expressions are case sensitive
2. Regular expressions are to be used where pattern is specified


Counts


Nearly every command may be preceded by a number that specifies how many times it is to be performed. 
For example, 5dw will delete 5 words and 3fe will move the cursor forward to the 3rd occurence of the letter e. 

Ranges

Ranges may precede most "colon" commands and cause them to be executed on a line or lines. For example :3,7d would delete lines 3-7. Ranges are commonly combined with the :s command to perform a replacement on several lines, as with :.,$s/pattern/string/g to make a replacement from the current line to the end of the file.

:n,mRange - Lines n-m
:.Range - Current line
:$Range - Last line
:'cRange - Marker c
:%Range - All lines in file
:g/pattern/Range - All lines that contain pattern


Files


:w fileWrite to file
:r fileRead file in after line
:nGo to next file
:pGo to previos file
:e fileEdit file
!!programReplace line with output from program


Other


~Toggle upp and lower case
JJoin lines
.Repeat last text-changing command
uUndo last change
UUndo all changes to line



TERIMA KASIH ATAS KUNJUNGAN SAUDARA
Judul: VI Cheats / Shorthands
Ditulis oleh Unknown
Rating Blog 5 dari 5
Semoga artikel ini bermanfaat bagi saudara. Jika ingin mengutip, baik itu sebagian atau keseluruhan dari isi artikel ini harap menyertakan link dofollow ke https://apk-zenonia5.blogspot.com/2013/01/vi-cheats-shorthands.html. Terima kasih sudah singgah membaca artikel ini.

0 komentar:

Posting Komentar

Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of apk zenonia 5.