Hacker News new | past | comments | ask | show | jobs | submit login
My Favorite Shortcuts for JetBrains' IDEs (markusdosch.com)
120 points by Sukram21 on April 20, 2020 | hide | past | favorite | 67 comments

While we talk about JetBrains, I think they really should push some priority on their remote development support. Take the VS Code Remote SSH extension as a good example of how it could work, which is extremely seamlessly, and it just works. E.g. even the embedded terminal provides a shell on the remote host, and if you e.g. open a file in there via `code somefile.txt`, it will open in your VS Code.

It's basically this feature request: https://youtrack.jetbrains.com/issue/IDEA-226455

Maybe they just need a few more votes on it. Or some more popularity.

Or is it just me and most people don't really need this? I'm still not really sure about the optimal remote work setup. Other people might just use Mosh + Tmux + Vim... I heard that Google has some very nice internal web IDE. If there would be a web IDE as powerful as PyCharm and the other JetBrain IDEs, that would also be a nice option.

FWIW: In the 2020.1 updates that have been rolled out in the last week the SSH support is now much better.

But serious question though: what workflow do you have that remote code editing is necessary?

I find remote code editing to be useful when I don't have the necessary resources on my machine such as disk/memory/gpu and I am still prototyping a solution, which happens a lot in ML/DL.

I agree that remote code editing is not strictly necessary since you can perform such task with sshfs or git push/pull workflows.

On the other hand, having the remote environment in your local IDE quickens the development and you don't have to setup a full replica of your environment locally.

edit: ML/DL here stands for Machine Learning/Deep Learning

I also tried SSHFS, but there are hiccups. I did not really debug this. But sometimes PyCharm just freezes for 5-10 seconds. Which is extremely annoying, basically this makes it unusable. Maybe too much files are opened at the same time or so. Maybe I have to increase the cache size. I don't really know...

Also doing any Git action (git commit or so) over SSHFS is way too slow because it needs to go through the whole project directory. Maybe it's fine if the repo and project is smaller. But in this case, a Git commit can easily take a minute (while locally it takes a few milliseconds).

A Git push/pull workflow would also be quite annoying when you are prototyping and just want to try out things.

I get that through remote interpreter and automatic upload features.

I sometimes code on my Surface Go (with a Pentium Silver CPU) and remote in to my home desktop (with a ryzen 3900x). For one of my Rust projects, the Surface Go takes about 25 minutes for a clean build and 2-3 minutes for incremental build. The desktop does a clean build in 2 minutes and an incremental build in 10-20s.

Since it needs to do an incremental build to provide any of the intelligent tools for Rust, it means editing directly on the Surface Go degrades to a text editor experience, while doing the remote editing lets the IDE-like features work.

Not the parent, but I do all my development with VS Code's remote editing. I generally don't run anything on my main desktop. Instead, I have a local VM server that runs a dedicated VM for each of my projects. Dedicated VMs are great because I never run into a situation where project A relies on node.js version X and starts clashing with project B that relies on node.js version Y. And I just manage everything with Ansible so it's easy to blow away a VM and rebuild it if I ever need to.

I wrote a bit more about my setup here: https://mtlynch.io/building-a-vm-homelab/

I do research on speech recognition and machine learning, i.e. I run lots of TF code, on lots of big data, and it runs for a long time (days, weeks). All the data, user files, everything in our lab is accessible via NFS, and every node in the cluster has the same FS. From the outside, I only have SSH access.

I want to work on code which runs there in the cluster.

I could have a local Git checkout of the code (partly). But sometimes it's a lot of trial and error, and it would be quite annoying to keep extra care that my local Git checkout gets synchronized with the copy in the cluster. Sometimes it might also have other files as dependencies which are simply only there in the cluster - or it would be extremely complicated to replicated all the same locally, and keep it all in sync. Even if PyCharm could help on the syncing part, it would still not be perfect, and would be annoying.

VS Code Remote SSH is basically perfect and exactly like I want it. The only problem is that I still prefer PyCharm.

For me the big one was using linux VM's on a windows host. If I want to work with Linux command line tools by far the easiest way is to have VS Code ssh'd into my VM and a few terminals open. I get the comfort of my normal daily driver and access to whatever command line tools are best suited to my current project.

Would you mind elaborating on what the improvements are? I've just been through this a couple of days ago and found it quite messy.

Many companies build/execute code on cloud desktops.

I develop on multiple machines and have just been through this exact thing with both VS Code and Pycharm. I was surprised at how different the implementations are. The VS Code SSH extensions work great - I would almost say "seamlessly", actually - whereas the Pycharm approach feels like a real kludge.

For starters, there seems to be more than one way to do it - one of the responses below refers to remote-mounting the filesystem using SSHFS, but another way to do it is through the Tools -> Deployment menu. The SSHFS approach is presumably the better one if your particular problem is trying to write code across several machines; the Tools -> Deployment avenue seems much better suited an actual deployment (it is, after all, in the name).

It's got me wondering whether I could get away with doing all my Python development in VS Code but obviously everyone has different constraints.

Using remote dev boxes can definitely be a huge productivity boon, from having better specs to much faster networks.

Here's an example of how Databricks improved their dev cycle with beefy machines running Bazel + remote cache: https://databricks.com/blog/2019/02/27/speedy-scala-builds-w...

With sshfs, what is the point? It seems to me that an editor shouldn't be dealing with the particularities of on what machine a file resides, that should be handled by the kernel or a userspace module. Like if Intellij had a feature that could allow it to access NFS drives people would decry it as unnecessary, but for some reason ssh is different.

Your point stands for an editor. Do note that PyCharm tries to be more than that, providing a bunch of tools around the editor.

In Pycharm, you don't just open remote files via SSH, the files are actually stored on the local machine. The point is to run the interpreter and the debugger on the remote machine.

This allows an integrated workflow with access to things you might not have on the local dev machine.

If your workflow is editing files in Vim / Sublime Code / whatever and then running them from the command line, I guess there really isn't that much benefit to this.


- Access to some firewalled-off machine - Load big amounts of data from another machine while your dev machine is on a low bandwidth connection - Access hardware you might not have locally, such as a big GPU while coding on a light laptop

The remote machine might have packages installed that are required to run, debug and code-completion.

Agreed, SSH-based remote development could certainly be smoother. But I love the way PyCharm uses pydev to run a Remote Debugging Server - that works for most remote-development use cases I encounter. Once you get it set up and a run configuration working, it’s a joy.

i'm using remote dev right this second in pycharm. other than the terminal thing (which is solved by just having ssh open) i don't have any issues.

You can use Tools -> Start SSH Session and select the session used for the interpreter. I think it would be event better if the Terminal tab opened it directly, but this is good enough for me.

A couple of "problems" I've had with Jetbrains' (more specifically IntelliJ IDEA's) shortcuts are:

- Not everybody uses a "standard" set of shortcuts (understandable); so whenever I need to do something on another's system, unless they're on "IntelliJ IDEA Classic" keymap, I'm clueless for a while.

- Not wanting to re-learn the "default" (shipped with) "macOS" keymap in case they change it again because of clashes with system shortcuts

- When switching to Linux (when my MBP just decides to limit all cores to 0.8GHz for thermals and I can get no work done), I have no idea what shortcuts are there. It's a hit-and-miss, hoping Cmd maps to Alt and it's the same combination. If it were possible to replicate the entirety of the Apple keymap on Linux, I'd switch to using IntelliJ IDEA on my beefier linux machine in an instant. (Oh and if there's a terminal configurable such that I can set up iTerm's shortcuts, bliss!)

- "complex" shortcuts, like Cmd-Shift-Option-N; afraid to remap it to something (moreso, figuring out what'd be the best remap option), afraid to hurt my little-finger the more I use that.

FYI you can export your shortcuts (and other settings): https://www.jetbrains.com/help/idea/sharing-your-ide-setting...

I've switched so many times between my own machines and using others' (on both Mac and Windows) that I can tolerate most of the standard keymaps. I just keep banging until stuff starts to click and my brain can slowly switch over.

Personally I just use Shift-Shift for practically everything. Saves me learning someone else's keymap or dealing with platform-specific bindings, and there are quite a few useful commands that aren't bound to keys anyway.

Ctrl-alt-L (cmd-alt-L) is my all-time favorite. It reformats the code consistently. It's the first thing I do when I start work on a new codebase, and the last thing I do before a commit.

No need for endless discussions on which style is best, as the IDE allows you to set the preferences on a per-project basis. It can also read editor config dotfiles so you can use code formatting consistently throughout a team.

+1 on this one.

And yes, there is no such thing as best style, so at the end of the day it boils down to personal preference. I find myself using the ctrl+alt+l often but before i commit any code i carefully go over everything and change it to my particular liking(which is often close enough to what the IDE has done so I rarely spend more than a minute or two on it). Also the reason why I haven't bothered to dig deep into the preferences.

A potential next step if it fits your workflow is to create a macro triggered by save. I have one that optimizes imports, reformats code and do silent code cleanup.

There is already an intellij plugin called Save Actions which does this (import, reformats, and some extra stuff, like adding final to variables wherever possible(optional off course).

Oh that's nice! Thank you.

IntelliJ IDEA's commit dialog already offers checkboxes to "optimize imports" and "reformat code" ("run gofmt" in case of Go), among others.

I'm a JS dev, and Webstorm integrates perfectly with ESLint and Prettier. it takes like two clocks to set up a file watcher on a project and never have to worry about formatting your code again

Thank you! I've been using Resharper and IntelliJ (Rider, etc) forever and I somehow I managed to miss that shortcut.

`Ctrl+W` is awesome, but after it has been ingrained in the fingers it's easy to close browser tabs by accident :D

Another one (not mentioned) is "Dobbel tap and hold Ctrl" to add multiple carets using the arrow keys (might need to enable in settings (Under smart keys)).

Another "smart keys" settings I recommend is "Surround selection on typing quote or brace" (not sure it's default or not)

> Ctrl+W is awesome, but after it has been ingrained in the fingers it's easy to close browser tabs by accident :D

This is why Ctrl+Shift+T is my favorite browser shortcut!

I recently installed the "Key Promoter X" plugin, which tells me the keyboard shortcuts for things I do frequently with the mouse. Pretty handy.

The JetBrains IDEs implement their own raw keyboard event handling, which means that if you have your system set up with a non-standard keyboard layout and JetBrains hasn't implemented their own support, it just won't work.

The issue on their public issue tracker has been open for something like 8 years.

Unfortunately for me this means that no keyboard shortcuts using the Cmd key work, despite me using a built-in macOS keyboard layout with no special customisation.

> despite me using a built-in macOS keyboard layout with no special customisation.

I also use a built-in macOS keyboard layout with no special customisation, and I regularly use shortcuts with Cmd. Perhaps you might want to change your Keymap in IntelliJ(this can be done by Double Shift -> Type Keymap -> Select new value.

Edit: For me, almost all the shortcuts detailed in this post work, just need to replace Ctrl with Cmd.

I'm using the Dvorak Cmd-QWERTY layout in macOS. This changes the layout to QWERTY whilst the Cmd key is held so that keyboard shortcuts are mostly in the same physical place (because most are about easy hand movements rather than letter). JetBrains does not match this behaviour.

Huh, never realized that was a thing. Do the shortcuts in the menu show the QWERTY key or the Dvorak one? I'm curious how you learn the shortcuts if it still shows the QWERTY keys.

Shortcuts all show the correct letter value. So for Ctrl+T, I'd press what is the K key on a QWERTY keyboard. For Cmd+T, I'd press what is the T key on a QWERTY keyboard.

This can get a little confusing, but most common shortcuts contain the Cmd modifier on a Mac, so it's only really Terminal/iTerm where things are different.

My keyboard is still physically a QWERTY keyboard which makes knowing where Cmd shortcuts are very easy, I can just look. I switched to Dvorak when I was 18, but learnt with a Dvorak keyboard so I didn't learn it well enough and when I got to uni and had to use shared lab machines I couldn't manage and had to switch back. Then just over 3 years ago I had 3 weeks off work so switched at the beginning with no physically different keyboards and learnt it all by position and I'm still using it today. Less hand pain, and I can touch type where before I was proficient but not entirely by touch.

One of my favorites, which I didn't think to look for for years, is 'Ctrl + Shift + Enter'. This completes your statement for you. Very convenient and lots of wasted punctuation characters skipped.

My favorite too. I always remap that to shift+enter though.

The best thing about this is the consistency across languages. Whether I am writing Java,C++,Rust, Go,Javascript, the shortcuts are the same with similar behaviour as much as possible. Shift F6 refactors the variable name. Cmd Alt M refactors a method from a chunk of code. Being able to use this muscle memory across languages is fantastic.

> Shift F6 refactors the variable name.

Funny you mention that. As a long-time Windows user, that is the first thing I remap when I set up any JetBrains IDE. F2 is the rename shortcut in File Explorer, so I set it to be the refactor variable name shortcut too.

I use the vim plugin and various jetbrains commands in IntelliJ.

Multi-cursor select is taken care of by vim's visual block. Basic editing/macros/navigation within a single file also done with vim.

For more IDE/multi-file specific tasks I use IntelliJ's shortcuts:

* cmd+shift+f for global search

* 2xshift for symbol search

* cmd+b to jump to method declaration

* cmd+shift+left/right is also useful to jump to previously navigated cursors


* cmd+alt+v/c/m for extracting variable/constants/methods (good for refactoring after prototyping)

* shift+f6 for renaming variables

* alt+enter for suggestions

EDIT: formatting

I've asked this before in other conversations but, what makes VS Code so popular compared to more mature IDEs with a more full fledged set of features like IntelliJ?

I have tried VS Code and the minute I couldn't ctrl + click navigate the code or get contextual ctrl + space bar method or input parameter suggestions I abandoned it.

> I have tried VS Code and the minute I couldn't ctrl + click navigate the code or get contextual ctrl + space bar method or input parameter suggestions I abandoned it.

I'm using VSC for a project the moment. You can definitely Cmd+Click on Mac to navigate, so I assume you could too, but perhaps it's not indexing your code for some reason?

I also see completions for method parameters, but I don't yet know the shortcut to redisplay it. Typing the opening brace, or a comma will display it, however.

What I miss the most in VSC is a decent VIM emulator. A number of the shortcuts in that list (and more) can be key combinations in Vim. But even crucial things like search with /, *, #, and ? (find symbol and regex search prev/next) aren't implemented properly, and undo/redo sometimes falls apart and corrupts your code. I believe the emulation in JetBrains products are actually made by the JB team themselves, so they can probably get all the necessary hooks in the extension API for Vim to function properly.

Last I heard, they were embedding neovim in VS Code, have you tried this? Or did they give up on this?

Looks like it's a thing:


When my annoyance at the vanilla Vim plugin exceeds my laziness to install and configure Neovim, I'll have a look at it :) Thank you.

I think WebStorm has the problem that the keyboard shortcuts are more or less meaningless key-combinations, it's difficult to remember them unless you use them frequently.

Luckily you can reassign the functions to different keys. For instance I have re-assigned "Show Breakpoints" to Ctrl-Break. Easy to remember right?

I re-assigned Ctrl-I to also Ctrl-E. Why? Because that Evaluates Expressions.

I've been using WebStorm for years now and I still discover useful stuff and keyboard shortcuts in it. That is both great but also a sign of how it is not completely obvious how to do things.

Recently I discovered what I think is the greatest shortcut of them all: Ctrl-Tab.

That pops up a widget from which I can choose which tool-window to make current. Keep the Ctrl down and you can use Tab or arrow-keys to navigate to the tool-window-name you want to activate.

You forgot a huge timesaver. I can't remember the shortcut (maybe Ctrl+F6) change method signature.

You can add a parameter and specify a default value that will be added to every call site. You can also reorder parameters or delete one and all the call sites will be updated.

Another favourite that I'd been missing since switching from Eclipse (back around Eclipse 3.6/4.2 days) is Field Call Hierarchy. Cursor on a data element and get the 'call hierarchy' from it.

Of course fields aren't 'called' per se, so JetBrains didn't do this. I'd been promoting issue IDEA-160274 where ever I could and now you can cursor on a field and press Ctrl+Alt+H (macOS) and see references to that field, and then selectively expand those references in a caller tree.

[0] https://youtrack.jetbrains.com/issue/IDEA-160274

Ctrl + Shift + A is my favourite shortcut in JetBrain IDEs. Having all editor commands in one go without the need to click through menus is a bliss. Especially so because I don't use IDEs as regular as Neovim and thus keep forgetting some shortcuts.

Double Shift is also extremely helpful to navigate to a file if the project has a lot of nested subdirectories.

Here's a video showing top 15 IntelliJ shortcuts by Trisha Gee. I know it's like watching top 15 Federer shots. Some of your favorites may not be there. Still it's quite good.


Alt-shift-arrow up/down for creating more cursors above/below. Easy multi-line editing (I may have set that up manually, but I do it in every ide now if it's not by default)

Ctrl-Q opens documentation, which you can pin as a tool window.

One of the best things I did now that I work on a Mac was use the force touch trackpad to ctrl-click whenever I push harder and a custom gesture for forwards and backwards.

I really wish they had ctrl-shift-t - reopen tab. I use it in chrome so much and it kills me when I accidentally close a file and I can't just reopen.

They have a "Reopen Closed Tab" action you can map in Settings -> Keymap. You can also use "Recent Locations" Ctrl-Shift-E to see recently touched files, the first one will be the one you just closed.

You can use Ctrl+E / Cmd E to invoke the `Recent Files` dialog -- the first file in the list will be the last closed tab.


There is also the `Reopen Closed Tab` action, which it seems doesn't have assigned shortcut by default, but you can assign it to whatever you feel comfortable with.

To accomplish similar I use "Back" from the Navigate menu regularly and have it bound to cmd+opt+left arrow. Works pretty well - also puts your cursor back to where it was in that file.

You know what the best shortcut is?

The menu key (windows and linux only)

Want to fix spelling of a word? Press menu key Want to refactor? Press menu key

You name it... press the menu key.

While we are at it: Does anyone know how to hide the new commit view? I haven't found a related action I could assign a shortcut to.

In the Keymap editor, Tool Windows -> Commit

Thanks, it works.

Ctrl+J to select multiple occurrences for editing. That works for me on Linux. I think it’s different on Windows/Mac.

Ctrl + G is select multiple occurrences on Mac.

It's one of my favorites as well. It is really good when you need to quickly rename, reformat or tweak a handful of lines that isn't a viable refactor action.

ctrl+Up: selects increasingly larger scopes, great for selecting the content of a string literal (either with or without the quotes) or grabbing chunks of call chain

One of my absolute favorites is multi-cursor editing. I first stumbled upon this in Sublime Text, but now I can´t live without it.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact