Tutorials

5 GoLand Shortcuts to Boost Your Productivity

Read this post in other languages:

GoLand has many shortcuts for any action you can perform in the IDE. The good news is that you don’t have to learn all of them to be productive.

How to choose a keymap

Let’s start by choosing the right keymap to ensure that you feel right at home more quickly. By default, GoLand has several predefined keymaps to choose from:

  • Keymaps based on your environment: macOS or Windows/Linux.
  • The IntelliJ IDEA Classic keymap is recommended for users who have experience with IntelliJ IDEA or any other JetBrains IntelliJ-platform-based IDE and have used the IntelliJ/macOS keymap in that IDE.
  • Emacs, Sublime Text and Sublime Text (macOS) keymaps are recommended for users who migrated from other code editors.
  • Last but not least, you can always can search for alternative keymaps in Preferences / Settings | Keymap by clicking Get more keymaps on top of the window.

In this article, we will go through the must-know shortcuts. Even though all of the key combinations used here are from the default keymaps for macOS and Windows / Linux, you can customize your keymap configuration in Preferences / Settings | Keymap.

Search Everywhere: ⇧⇧ / Shift+Shift

Search Everywhere is a multi-tool action that helps you find literally anything! Any item in the source code, databases, actions, elements of the user interface, plugins, settings, ​​Git branches, commits, tags, messages, and so on.

To narrow down your search, press ⇥ / Tab to navigate between tabs or click the filter icon on the window toolbar and select the appropriate option.

Last but not least, you can open the current search results in a separate tab in the Find Tool Window and run another query. Simply click the Open in Find Window icon on the right corner of the Search Everywhere.

Show Context Actions: ⌥↵ / Alt+Enter

As you work in the editor, GoLand continually analyzes your code, searches for ways to optimize it and detects potential problems. It covers a wide range of situations, from errors and warnings to optimization suggestions that you can apply directly via Alt+Enter.

To review the full list of available intention actions, open the IDE settings and select Editor | Intentions. Disable any actions that you don’t need at the moment by simply unchecking the boxes next to them. In addition, you can do this on the fly as follows: just place the caret on your code, press ⌥↵ / Alt+Enter, select the action you want to disable, click the right arrow next to it, and then click Disable <intention action name>.

Refactor This ⌃T / Ctrl+Alt+Shift+T

Refactor This is a key to the set of refactorings available in GoLand from Rename to Move, Change Signature, Extract and Introduce method/type/interface, Inline, and ​​Safe Delete refactoring to remove files from the source code safely.

This means you only have to remember one shortcut for all refactoring purposes. To quickly access the list of available refactorings for the selected code, press ⌃T / Ctrl+Alt+Shift+T.

Generate ⌘N / Alt+Insert

This hotkey opens a variety of options for creating common code constructs and recurring elements. Generate a function that creates values of a struct type, getters and setters, an empty test file, tests for files, packages, functions, and copyrights. Also, it implements all the methods that are listed in the interface in just a few seconds.

Smart Code Completion ⌃⇧Space / Ctrl+Shift+Space

Code completion reduces the number of things you need to memorize and helps you avoid typos and other common mistakes. Basic Code Completion pops up as you start typing code in GoLand and works mostly automatically, whereas Smart Code Completion has to be explicitly called by pressing ⌃⇧Space / Ctrl+Shift+Space. GoLand gives you a list of the most relevant symbols that are applicable in the current context.

To learn more about code completion in GoLand, please read this article.

One step further

To make everything even faster, download the Key Promoter X plugin to learn shortcuts while you are working and replace tedious mouse movements with keystrokes. Every time you use the mouse on a button inside the IDE, Key Promoter X shows you the keyboard shortcut that you could have used instead.

Good luck, and happy coding!

image description