XCode – Open file in current tab in external editor (MacVim)

I wanted to open the current file from XCode 5 in MacVim similarly as I do in IntelliJ. After some research I found following solution that works for me. If Assistant editor is opened, the file from the Standard Editor (on the left side) is opened regardless which editor is active.

First raised as a StackOverflow question.

Update: In case you were wondering how to start MacVim from XCode, you should maybe try XVim instead. It brings Vim mode right into XCode.

Starting Vim (gVim) from IntelliJ

Ever wanted to use Vim editing features while inside IntelliJ IDEA? Here is how to do it… You can even jump to the very same line you are on in IntelliJ.

Go to Settings > External Tools, add a new tool and use something similar:

Program: c:\Program Files (x86)\Vim\vim71\gvim.exe
Parameters: "+call cursor($LineNumber$,$ColumnNumber$)" "$FilePath$"
Working directory: $FileDir$

Update: IdeaVim – Vim commands right in the IDE

Additionally I finally tried the IdeaVim plugin for IntelliJ and my experience so far is pretty good. The need to start gVim externally almost disappeared.

Update: Open file in IntelliJ from gVim (Windows)

Save file + Open current file on the same line in IntelliJ + Close file in VIM

map! <F3> <Esc>:update<CR>:silent exe "!openIntelliJ.bat c: --line " . line(".") . " %:p"<CR>:q<CR>

  • :map! command creates a key map that works in insert and command-line mode.
  • :update is similar to ":w" or ":write", but only writes when the buffer has been modified.
  • silent prevents Hit enter cmd window.
  • line(".") returns current line number (dot is for the current)
  • %:p returns full file path of the current file
  • IntelliJ commmand line uses following syntax: [IntelliJ Path] [path1 = path to the project that contains the desired file] --line[number] [path to the file to be opened]

Here is my openIntelliJ.bat – one of the advantages is that I have just one place to change when I upgrade to a newer version (giving the exe to path variable would an option too):

start "" "c:\Program Files (x86)\JetBrains\IntelliJ IDEA 12.1.6\bin\idea.exe" %1 %2 %3 %4

The second attribute for Windows “start” command is title, I don’t need it, so I supply empty string.

References: