My Favorite Shortcuts for JetBrains' IDEs

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

内容简介: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.


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

查看所有标签

猜你喜欢:

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

宇宙涟漪中的孩子

宇宙涟漪中的孩子

谢云宁 / 四川科学技术出版社 / 2017-11 / 28.00元

近未来。日冕科技公司通过建造围绕太阳的光幕搜集了近乎无穷的能源,这些能源主要用于地球上的网络空间建设。随着全球网络时间频率的不断提升,越来越多的人选择接驳进虚拟空间,体验现实中难以经历的丰富人生。 网络互动小说作者宁天穹一直自认为是这些人中普通的一员,有一天却被一名读者带进反抗组织,了解到日冕公司的各种秘密,并被告知自己的小说将在抵抗运动中起到重要作用。 起初他拒绝参与,但看到地球被笼......一起来看看 《宇宙涟漪中的孩子》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

MD5 加密
MD5 加密

MD5 加密工具