简体   繁体   中英

Activating Vim with Applescript

Using MacOS Mojave, I recently intalled the last version of vim thanks to this easy tutorial : https://medium.com/swlh/vim-is-vulnerable-update-vim-on-macos-66402e5ab46a

I am now trying to synchronize it with Skim to do backward search. To do so, I am using a script in which vim is activated using AppleScript with the following command :

osascript -e 'tell app "Vim" to activate'

I get the following error when executing:

18:26: execution error: Il est impossible d’obtenir application "Vim". (-1728)

(translation from French : It is impossible to obtain application "vim")

macerror -1728 gives me:

Mac OS error -1728 (errAENoSuchObject): e.g.,: specifier asked for the 3rd, but there are only 2. Basically, this indicates a run-time resolution error.

I have tried changing "vim" to "Vim" in the command; creating a symlink from vim in /Applications to vim in /usr/local/bin ; changing owner of vim to $USER . Nothing worked.

Anyone has any idea what is going on ?

AppleScript is unfortunately only for GUI apps - therefore you won't be able to manage CLI Vim at all. I can see that any other solutions won't make you happy, since the tutorial is about using particular vulnerability. You can make

brew install macvim

to operate on the functionalities that vim provides, so you can still record keystrokes, print stuff and so on. You can also read about vim +clientserver , it might provide a solution for your needs, but it'd be still just a workaround.

Since vim in this use case is a command line executable , not a standard GUI app , the following example AppleScript code should work:

osascript -e 'tell app "Terminal"' -e 'do script "/usr/local/bin/vim"' -e 'activate' -e 'end tell'

Note: If necessary, change the fully qualified pathname of vim to where you installed it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM