If you want to comment N lines of a Bash script (for example) with the VI (or VIM) editor you have to type in ESC- mode (type ESC before typing the command):
:.,25s/^/# /
where ".,25s" stands for "from the current line to line number 25" and the sequence added to comment a line is "# " (hash plus a white space).
For a single line:
:11s/^/# /
for the 11th line or
:.s/^/# /
for the current line pointed by the cursor.
To uncomment:
:1,$s/^# //
where "$" stands for "last line", i.e. "from line 1 to the end of file".
Wednesday, January 9, 2008
VI editor: comment a whole line or N lines
Pubblicato da
Pelerin-Voyageur
a
10:32 AM
Etichette: bash, programming, system administration, VI
Subscribe to:
Post Comments (Atom)
0 commenti:
Post a Comment