wyłączenie kolorowania:
syntax off
skasowanie pustych linii:
:g/^$/d
wyszukanie ^M
:%s/<Ctrl-V><Ctrl-M>//g
dopisanie czegoś do końca linii:
%s/$/ddd/gSET TERMOUT OFF; spool M:\Documents\test; select * from employees; / spool off;
vim:
For example, to delete all lines containing "profile" (the first command is optional;
it shows the lines that the second command will delete):
:g/profile
:g/profile/d
skasowanie początku lini do określonego wyrażenia:
:%s/^.*QUERY: //g
dodanie średnika na końcu każdej linii
:%s/$/;/g
skasowania linii od znaku "*" do końca linii
:%s/*.*//g
:%s/OU=.*//g
skasowanie linii od zanku "*" np. 5 znaków
:%s/*.....//g
dodanie czegoś na początku linii
:%s/^/Coś /g
skasowanie linii do ostatniej spacji
:%s/^.* //g
skasowanie całości tekstu
:%s/.*//g
x - delete current character
dw - delete current word
dd - delete current line
5dd - delete five lines
d$ - delete to end of line
d0 - delete to beginning of line
:1,.d
delete to beginning of file
:.,$d
delete to end of file
More complex patterns can be used, such as deleting all lines that are empty or that
contain only whitespace:
:g/^\s*$/d
To delete all lines that do not contain a pattern, use g!
, like this command
to delete all lines that are not comment lines in a Vim script:
:g!/^\s*"/d
Delete all trailing whitespace (at the end of each line) with:
:%s/\s\+$//
Like with ed(1), the substitution text can be omitted if blank:
:%s/\s\+$
More rarely, a user might want to delete (leading) whitespace at the beginning of each line:
:%s/^\s\+
" Same thing (:le = :left = left-align given range):
:%le
:%s/<Ctrl-V><Ctrl-M>//g
Źródło:
http://vim.wikia.com/wiki/Delete_all_lines_containing_a_pattern