JohnBeckett (talk | contribs) m (Change to TipImported template + minor clean) |
(change "anon" author to blank; trim "created" date; minor manual clean) |
||
(One intermediate revision by the same user not shown) | |||
Line 5: | Line 5: | ||
|created=February 1, 2007 |
|created=February 1, 2007 |
||
|complexity=intermediate |
|complexity=intermediate |
||
− | |author= |
+ | |author= |
− | |version= |
+ | |version=6.0 |
|rating=5/14 |
|rating=5/14 |
||
+ | |category1=Mac OS X |
||
+ | |category2= |
||
}} |
}} |
||
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. |
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: |
Create a file called gvim.scpt (for example) with the following applescript code: |
||
− | |||
<pre> |
<pre> |
||
on run argv |
on run argv |
||
Line 27: | Line 28: | ||
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: |
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: |
||
− | |||
<pre> |
<pre> |
||
#!/bin/sh |
#!/bin/sh |
||
Line 39: | Line 39: | ||
---- |
---- |
||
− | [[Category:Mac OS X]] |
Revision as of 03:02, 4 December 2009
created February 1, 2007 · complexity intermediate · version 6.0
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.
Comments
see this page for doing this with the new mac vim