Sublime Forum

Key binding to open current project in IntelliJ/VSCode

#1

Hello,
A common workflow for me is to clone or pull changes on a repo and then opening it in IntelliJ or VSCode.
For single files, I can often use the “Open in editor” action of a changed file.
But if I want to open the whole project, the fastest way I have found is to click Repository -> “open containing folder”, navigating up one folder and selecting “Open in other application” -> IntelliJ.

Can I create a keybinding to directly open the whole folder in IntelliJ or VSCode?

I tried keybindings like this, but could not get it to do anything. I tried “$path” and “$working_dir”.

{
    "keys": ["ctrl+l"],
    "command": "open_in_editor",
    "args": { "path": "$path" , "line": "0", "col": "0"}
}
0 Likes

#2

You should be able to do this via a custom git alias, I would think. An example of how that might work is in the linked post below. The custom command could be bound to a key, added to the menu or command palette, etc.

1 Like

#3

Nice, thank you a lot! This is a great starting point
I now use:

.gitconfig:

[alias]
  intellij = "!f() { idea $1; }; f"
  pycharm = "!f() { pycharm $1; }; f"
  code = "!f() { code $1; }; f"

~/.config/sublime-merge/Packages/User/Default (Linux).sublime-keymap:

[
  {
    "keys": ["ctrl+shift+i"],
    "command": "git", 
    "args": {
      "argv": ["intellij", "$working_dir"]
    }
  },
  {
    "keys": ["ctrl+shift+p"],
    "command": "git", 
    "args": {
      "argv": ["pycharm", "$working_dir"]
    }
  },
  {
    "keys": ["ctrl+shift+v"],
    "command": "git", 
    "args": {
      "argv": ["code", "$working_dir"]
    }
  }
]

I still have some problems with pycharm and intellij causing the process to wait instead of opening the editor and finishing.
But that seems to be a bug with pycharm and intellij and their handling of the --wait flag: https://youtrack.jetbrains.com/issue/IJPL-35321
VSCode works perfectly wtih this.

0 Likes

#4

Current setup
.gitconfig:

[alias]
    intellij = "!idea . >/dev/null 2>/dev/null &"
    pycharm = "!pycharm . >/dev/null 2>/dev/null &"
    code = "!code $1"

~/.config/sublime-merge/Packages/User/Default (Linux).sublime-keymap:

[
  {
    "keys": ["ctrl+shift+i"],
    "command": "git", 
    "args": {
      "argv": ["intellij"]
    }
  },
  {
    "keys": ["ctrl+shift+p"],
    "command": "git", 
    "args": {
      "argv": ["pycharm"]
    }
  },
  {
    "keys": ["ctrl+shift+v"],
    "command": "git", 
    "args": {
      "argv": ["code", "$working_dir"]
    }
  }
]
0 Likes