Thursday, 29 October 2009

 

Editing the File name you Save or Write to (2)


Remember you can recall the file name with Control-R %
You can then edit the file name freely

Vim supports wild cards as long as only ONE file matches eg

:r ../*/ref.c

:e long*file*name.h

Saturday, 10 October 2009

 

Write/Save a File to a Changed Name


:sav main.php : Save current file as main.php and "move" to main.php
:sav! %<.bak : Save Current file to alternative extension (old way)
:sav! %:r.cfm : Save Current file to alternative extension
:w %:r.cfm : write Current file to alternative extension
:sav %:s/fred/joe/ : do a substitute on file name
:sav %:s/fred/joe/:r.bak2 : do a substitute on file name & ext.
:!mv % %:r.bak : rename current file (DOS use Rename or DEL)

Monday, 5 October 2009

 

Join Pairs of Lines

Compress every other line

Bob
Jones
Mary
Quite-contrary

:g//,//j

Bob Jones
Mary Quite-contrary

Now if there are empty lines eg
Bob


Jones
Mary
Quite-contrary

use
:g/./,/./j
or slightly tighter
:g/\w/,/\w/j

and to limit it to a range of lines (between markers a and b)
:'a,'bg/\w/,/\w/j

Tip from James Church

Labels:


This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]