My Favorite Shortcuts for JetBrains' IDEs

栏目: IT技术 · 发布时间: 4年前

内容简介:IDEs are full of features - shortcuts enable you to access these features much faster. They make you a much faster programmer, so you can concentrate on solving actual problems and not loose time fiddling through menus. :wink: They are an essential part in

JetBrains , the makers of the popular IntelliJ IDEA, offer a range of powerful IDEs for all kinds of programming languages. At work, we use them as well - I am usingPhpStormandGoLanda lot.

IDEs are full of features - shortcuts enable you to access these features much faster. They make you a much faster programmer, so you can concentrate on solving actual problems and not loose time fiddling through menus. :wink: They are an essential part in improving one’s software development craft.

I would like to share the shortcuts that I am using the most. All shortcuts here are given for a Windows keyboard layout:

Essentials

  • Ctrl + Click
    • When clicking on a method call: Jump to the method’s implementation
    • When clicking on a method signature: See usages of the method.
    • Alternatives : Keyboard-only Ctrl + B , mouse-only Middleclick .
  • Ctrl + Shift + A : Search in Actions. This is an awesome starter shortcut: You can use it to learn which other actions exist. Each action in the result list is accompanied by its shortcut - so you can use this feature to improve your action & shortcut knowledge! Besides that, I use it for executing actions I don’t use often (like increasing or decreasing the font size).

Finding Stuff

  • Ctrl + Shift + N : Search in File Names (and Paths). Also useful: Adding a :<LINE-NUMBER> suffix - this will let you jump directly to the respective line. Especially nice when you already know the line of an error (e.g. because of a compiler error message).
    • Ctrl + G : scroll to a specific line (a popup will open, where you enter the line number)
  • Ctrl + F12 : See & access the structure of the current file - e.g. method names or class attributes. Useful: When the popup is open, you can directly start typing - the list will be filtered!
  • Finding text
    • Ctrl + Shift + F : Search in contents of all files. Tip : When you have selected a folder in the left project tree view and then use this shortcut, only this folder is searched (not the whole project).
    • Ctrl + F (obvious, but included for completeness) : Search inside the current file.
    • Similarly, these shortcuts let you “Find and Replace”: Ctrl + Shift + R and Ctrl + R .
  • Shift (two times): Search everywhere. This is the master search, a combination of all specialized searches - it will search in actions, file names, symbols (like method names),… I used to use it more often, but nowadays I prefer the faster more specialized searches.

Refactoring & Code Generation

  • Alt + Enter : See IDE suggestions (e.g. when your cursor is on a line with an error or a warning)
  • Shift + F6 : Rename a symbol (e.g. a method name or a variable name).
  • Ctrl + Shift + Alt + T : See possible refactorings (e.g. extract some code into a separate method, extract some value into a constant…)
  • Alt + Insert : To generate stuff (e.g. a constructor, getters/setters)

Navigating

  • Ctrl + W : Extend selection (e.g. for selecting the whole word, the whole method…)
    • Likewise, Ctrl + Shift + W lets you un-expand the selection.
  • Ctrl + Tab : Open the “Switcher”, e.g. to switch between open files.

Git Version History

I set up the custom shortcut Ctrl + Shift + G to toggle annotations ( G for Git). So I can easily see when each line of code was last modified and access the commit. This helps me understand the context for a modification.

This was all for now, I hope this blogpost helped you with improving your efficiency with JetBrains’ IDEs!

Update 2020-04-18

After sharing this blog post in our internal company channel, a nice discussion emerged and my colleagues shared some of their favorite shortcuts as well! Here are they:

Essentials

  • Middleclick : A mouse-only alternative to Ctrl + Click and Ctrl + B . I now mention it there. (Thanks Cagatay!)

Finding Stuff

  • Alt + J : When doing a text search, this shortcut adds the next occurrence to the selection. You can then edit all selections at the same time ( multi-cursor ). (Thanks Philipp!)
    • The shortcut for doing the opposite is Alt + Shift + J (unsurprisingly).

Refactoring

  • Shift + F6 : Rename a symbol (e.g. a method name or a variable name). I use this shortcut every single day - how could I forget about it? I now added it to the list of refactoring shortcuts.
  • F2 : Jump to the next problem/IDE suggestion. I did not know about this, but I think this is super-useful. This could very well become one of my most-used shortcuts. (Thanks Jens!)

Navigating

  • Ctrl + E : Show the list of recent files. This could possibly become my replacement for Ctrl + Tab , as this is what I want most of the time - and is easier on my fingers. (Thanks Benjamin!)
  • Ctrl + Shift + E : Similar to Ctrl + E , but shows all recent positions incl. the surrounding lines. A potentially very powerful feature! (Thanks Torsten!)
    • The “Show shanged only” toggle is especially useful.
    • Good to know (already familiar from other modals): When the overview is open, you can just start typing and it will filter instantly by file name & code.
  • Alt + Shift + ArrowLeft/Right : Navigate to the last/next edited location. I think this could be very useful as well! (Thanks Sebastian F.!)

Editing

  • Ctrl + / : Comment/Uncomment line (or selection). This can be very useful and I will try to remember it for when I need it! (Thanks Sebastian A.!)
    • Note: On your NumPad, “/” might be printed as “÷”.
  • Ctrl + Y : Delete line (Thanks Sebastian A.!)
  • Ctrl + D : Duplicate line (Thanks Sebastian A.!)
  • Alt + Shift + ArrowUp/Down : Move line up or down (Thanks Sebastian A.!)
    • Very similar is Ctrl + Shift + ArrowUp/Down which lets you move whole methods as well.

Various

  • Ctrl + P : Show the list of parameters for a function call. (Thanks Jens!)
  • An interesting tip by Cagatay was to modify your IDE’s shortcuts so that they match the shortcuts you already know from your browser. So you do not have to remember two different shortcuts for the same thing. Examples include Ctrl + T for opening a new tab, Ctrl + Shift + T for reopening a closed tab, and Ctrl + W for closing a tab.
  • F11 : Toggle a bookmark on the current line. I don’t use the bookmarks feature, but can see how this can be useful. (Thanks Jens!)
  • Ctrl + Shift + Alt + Insert : This creates a new “scratch” file, a temporary file e.g. for notes. I use other tools for such temporary files (I did not know about this feature before), but can see how they can be useful, especially when you do not want to leave the IDE for that, and/or want to profit from your IDE’s features like syntax highlighting (Thanks Cagatay!)

Update 2020-04-19

My brother (Thanks Andy!) reminded me of the very useful shortcut Ctrl + Alt + L to reformat selected code. For my work projects, I mostly trigger this action via “Find in Actions” (I should really remember this shortcut though…). For my own personal projects, I can luckily spare it and use automatic code formatters likePrettierto re-format my code on every save.


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

UML用户指南

UML用户指南

[美] Grady Booch、James Rumbaugh、Ivar Jacobson / 邵维忠、麻志毅、马浩海、刘辉 / 人民邮电出版社 / 2006-6 / 49.00元

《UML用户指南》(第2版)是UML方面最权威的一本著作,三位作者是面向对象方法最早的倡导者,是UML的创始人。本版涵盖了UML 2.0。书中为具体的UML特征提供了参考,描述了一个使用UML进行开发的过程,旨在让读者掌握UML的术语、规则和语言特点,以及如何有效地使用这种语言,知道如何应用UML去解决一些常见的建模问题。《UML用户指南》(第2版)由7个部分组成,而且每章都描述了一个特定UML特......一起来看看 《UML用户指南》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

html转js在线工具
html转js在线工具

html转js在线工具