When using Skim.app for reverse-searches, is there any way to make the .tex file come to the front if it's already open in a macvim tab? What if there are multiple vim windows open (not just tabs)?

The 'standard' script (http://sourceforge.net/apps/mediawiki/skim-app/index.php?title=TeX_and_PDF_Synchronization#Editor_Script_for_VIM) works if you have the file open in the active tab, but NOT if you have it open in a non-active tab (the vim command bufexists doesn't work for other tabs).

The Skim.app standard mvim --remote-silent +":%line" "%file" is, to me, completely useless - it overwrites the current open buffer on the first MacVim window open. Is there any way to change this behavior to find the current open copy of the file?

EDIT: A note I hope is helpful for others - I could not get the applescript to work at all until I added the line

  -e "delay 0.2" \

to the start of the script and changed the ESC key passing to be

-e "    key code 53 "\

1 Answer 1


My answer is this plugin/script pair:

See https://stackoverflow.com/questions/8839846/vim-check-if-a-file-is-open-in-current-tab-window-and-activate-it for details

Short summary: WhichTab.vim searches through all tabs in a macvim session for your filename (hopefully you don't have too many files opened named ms.tex....).

macvim-load-line runs WhichTab on each open VIM GUI window, then if it finds an open copy of the file, it activates that GUI window, switches to that tab, and goes to that line.

Right now the only thing it doesn't do is open a .tex file if it's not already open... which for me, is rarely/never the case if I'm actively editing. But that should be trivial to add.

  • I'm not sure if this is happening for others, but your first two links are broken: WhichTab and macvim-load-line.
    – user2473
    Commented Jan 25, 2012 at 23:58
  • @CJF - thanks; I moved the files and forgot to update the link. Should be fixed now.
    – keflavich
    Commented Jan 26, 2012 at 0:43
  • looks like the links are broken again Commented May 16, 2016 at 21:43
  • Peeter Joot: fixed again.
    – keflavich
    Commented May 17, 2016 at 5:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .