Go logo

GoLand

A cross-platform Go IDE with extended support for JavaScript, TypeScript, and databases

GoLand’s Hidden Gems

We all know how tricky it is to unlock the full power of an IDE. There will always be more features you haven’t fully explored yet. But we’ve all been in at least one situation where we discovered a tiny feature or action by accident and it pleasantly surprised us or saved us a ton of time. 

While working on features for GoLand, our team put together a collection of the specific features that were the most helpful in allowing us to focus more on creativity and less on the repetitive “grunt work”.

Welcome hidden gems in GoLand, edition by the team! Please note, if you are using IntelliJ IDEA with the Go plugin, as well as any other products, you will find these features in your IDEs. 

Sort lines action

The Sort lines action is useful when you’re looking at the text file with lines of data (for instance, names, import paths, log files, and so on). Alphabetical sorting helps to understand the file more easily or find duplicating lines.

To quickly sort lines in the whole file or in a code selection, choose Edit | Sort Lines or Edit | Reverse Lines from the main menu. Alternatively, you can run this action using the Find Action command via ⌘⇧A on macOS or Ctrl+Shift+A on Windows/Linux).

Open Blank Diff Window

Open Blank Diff Window will help you review the differences between any files, folders, text sources, database objects, as well as local files and their repository versions. For example, you can open this window, paste the logs, and the IDE will show the diff, just like it does for VCS changes. 

You can call the Open Blank Diff Window action by pressing ⌘⇧A on macOS or Ctrl+Shift+A on Windows/Linux. Then just start typing Open Blank Diff Window to locate it.

Alternatively, you can assign a shortcut for this action on the Keymap page of the IDE in the Settings under Version Control Systems | Diff & Merge.

Besides that, you can compare any piece of code copied into your clipboard by right-clicking anywhere in the editor and choosing Compare with Clipboard from the context menu.

Scratch files: ⇧⌘N / Ctrl+Alt+Shift+Insert

Sometimes you need a place to edit a piece of arbitrary text, take a few notes related to the task you’re working on or draft up some code outside the project context. This is where Scratch files come to rescue!  

Scratch files are not simply notes, they support syntax highlighting, code completion, and all other features for the corresponding file type.

And here’s the cherry on top of the pie: Scratch files are not related to a specific project and live with your IDE. You can easily access them from within any project, so there is no need to leave your IDE.

You can create a Scratch file from the main menu. To do so, select File | New | Scratch File or press ⇧ ⌘ N on macOS or Windows/Linux. 

Multiple cursors

Multiple cursors let you make changes to your code faster by applying changes in several places simultaneously. In addition, multiple cursors are equipped with Code completion and Live Templates and will apply them at each caret position.

To add multiple carets, you can press ⌥/Ctrl twice, and then without releasing it, press the Up Arrow or Down Arrow key. You can also make a multiple selection by pressing ⌥⇧ on macOS or Shift+Alt on Windows/Linux and dragging the caret. To delete all carets, just press the Escape key.

Collapse All / Expand All: ⇧⌘- /⇧⌘+ or Ctrl + Shift + NumPad + /  Ctrl + Shift + NumPad –

We read code constantly. And sometimes we find ourselves unable to figure out the structure of the code we’re reading – even though it’s code that we wrote! 

Rest assured that there’s an easy work-around. The Collapse All and Expand All actions help you to navigate the wall of code more quickly. To collapse or expand all code fragments, press ⇧⌘- /⇧⌘+ on macOS and on Ctrl+Shift+NumPad +Ctrl+Shift+NumPad – Windows/Linux.

GoLand collapses or expands all fragments within the selection, or, if nothing is selected, all fragments in the current file, for example, all methods in a file.

What’s more –  you can collapse or expand code recursively, press ⌥⌘- / ⌥⌘+ on macOS and Ctrl+Alt+NumPad + / Ctrl+Alt+NumPad –. GoLand collapses or expands the current fragment and all its subordinate regions within that fragment.

Recent Files: ⌘+E / Ctrl+E 

Recent Files features help you quickly jump to the files you’ve opened most recently. This action will also open the Recent Files tool window with the list of the recently opened files to let you navigate there. 

But, if you press the same ⌘+E on macOS or Ctrl + E on Windows/Linux shortcut while the Recent Files tool window is open, then the list will only display the files that have been changed recently.

That was the version about hidden gems in GoLand by the GoLand team. What’s your timesaver in the IDE? Share it here in the comments or via Twitter, we would like to hear! 

image description