History
Article Edit this page Discussion

Open files in same window under Mac OS X

From Vim Tips Wiki

(Redirected from VimTip1500)
Jump to: navigation, search

Tip 1500 Previous Next Created: February 1, 2007 Complexity: intermediate Author: Anon Version: n/a


This tip shows you how to open files from the command line in the same window (Vim instance), using applescript. The applescript is specific to Vim.app.

Create a file called gvim.scpt (for example) with the following applescript code:

on run argv
   tell application "Vim"
      repeat with n from 1 to (count of argv)
         set theUnixPath to item n of argv
         set theMacPath to (POSIX file theUnixPath) as string
         open file theMacPath
      end repeat
      activate
   end tell
end run

This applescript tells a running Vim.app to open each argument in a new buffer. The script can be invoked with the 'osascript' command ('man osascript' for details): a good way to do this is to create a shell script somewhere in your path:

#!/bin/sh
osascript /path/to/gvim.scpt $*

What this doesn't do yet: Create the files automatically if they do not exist. In fact the script will fail and complain if you pass the name of a file that doesn't exist, and any following files also won't be opened.

[edit] Comments

see this page for doing this with the new mac vim


Rate this article:

Share this article:

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto
Pixar
Legend of Zelda Wiki
Terminator Wiki
Everquest II Wiki
Dark Shadows
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions


Vote for collaboration of the month.

Send this article to a friend
"Open files in same window under Mac OS X"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation