Archive for April, 2012

Running the script you are currently editing in vi

Tuesday, April 24th, 2012

Instead of doing all the typing involved with leaving your vi session to run the script you just edited, you could simply type


“%” is a shortcut for the current filename. For this to work, the current file (%) should be in your $PATH. Or if that’s inconvenient or unwise, you can always just make the call to the file’s absolute path by substituting % with the absolute path of the file. The file should be executable, which, if it isn’t, you change by typing

:!chmod +x %

Of course, if you have just created the file, you’ll need to do a :w to actually commit the file to the filesystem, before you can make any calls to it.

Remember to use


to repeat the last command you just ran from within vi to save yourself more typing.