3

I have MacVim 7.1 (patch level 903). When I drag a file onto it from the Finder, desktop, etc., it opens in a new tab. However, I would prefer that it open in a split. According to :help drag-n-drop, holding down Ctrl should do this, but on my MacVim at least, this doesn't seem to do anything.

Is this possible with MacVim?

1 Answer 1

5

The "Open files from applications" preference in the General preference pane gives more options on how dropped files should open, in case tabs are not desired. See :h macvim-drag-n-drop.

After setting up dropped files to be opened in splits, they will be opened in horizontal splits by default. If you prefer vertical splits, execute the following command. See :h macvim-user-defaults.

defaults write org.vim.MacVim MMVerticalSplit -bool TRUE

Also, you could add the following snippet to your ~/.vimrc file to automatically set these defaults.

if has('gui_running') && has('macunix')
    " open dropped files in vertical splits
    call system('defaults write org.vim.MacVim MMOpenLayout -bool TRUE')
    call system('defaults write org.vim.MacVim MMVerticalSplit -bool TRUE')
endif
1
  • Perfect! That's exactly what I was looking for (especially the second example). Shame that these preferences are not set using vim options themselves, but via Mac system defaults instead, but this still seems to work fairly robustly. Thanks! Commented Mar 15, 2016 at 23:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.