Written February 1, 2015. Tagged Vim, OS X, AppleScript.
When I double-click a code file in Finder, I want it to open in Vim in a terminal. Not in MacVim. Not in some lesser editor.
There's plenty of prior work, but nothing worked well for me on OS X 10.10 Yosemite, so I rolled my own.
The end result: double-clicking a file opens a new iTerm window with the file opened in Vim.
Since it exec
s Vim (replaces the shell process), the window closes when you quit Vim. This also means you can't ⌃Z
out of the Vim session. Think of it as an editor window, not a full-fledged terminal.
.app
Download TerminalVim.app, unzip it and stick the app in /Applications
.
Or make your own:
on run {input, parameters}
set myPath to POSIX path of input
set cmd to "vim " & quote & myPath & quote
tell application "iTerm"
activate
set myTerm to (make new terminal)
tell myTerm
set mySession to (make new session at the end of sessions)
tell mySession to exec command cmd
end tell
end tell
end run
/Applications/TerminalVim.app
..rb
file.⌘I
to open the "Get Info" window.Now all .rb
files in Finder will open in Vim.
That's it!