DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Coding
  3. Tools
  4. IntelliJ IDEA - Small tips with big value

IntelliJ IDEA - Small tips with big value

Vaclav Pech user avatar by
Vaclav Pech
·
Aug. 28, 09 · Interview
Like (3)
Save
Tweet
Share
26.34K Views

Join the DZone community and get the full member experience.

Join For Free
This time I'd like to share a couple of little tips on using IntelliJ IDEA, which can make your coding more productive and enjoyable at the same time. However small they may look at first, they are likely to have a huge impact on your performance and enjoyment over time. At least, they have had such an effect on me.

Method separators

Let's start with something simple. Having methods visually separated by a horizontal line helps code readability.


If you want to have the methods visually separated, go to the settings with Control + Alt +S, immediately start typing what we're looking for - "sepa..."

and see how the dialog gradually limits its content to show only the relevant entries in the settings. Check the checkbox for "Show method separators" and you're ready to go.

And as for the tip regarding text search inside the settings dialog - take it as a free bonus tip.

Invoke action by name

Following on the same wave, the proven wisdom goes that search is faster than a look-up. IDEA allows you to invoke commands like refactorings or code generation by name (or just a part of it). To see the magic, choose a block of code worth refactoring and instead of going up into the menu press Control + Shift + A and enter the name of the command you want to perform. Wild cards or incomplete names are of course allowed.

Faster than scanning the menu, I'm certain.

Go To Symbol

The last example of the same search-over-navigation principle. Searching for a method or a variable you only know a name of or a part of it, but can't remember in which file/class it is defined? The Control + Alt + Shift + N key shortcut is a quick way to search for such an element in your project.

No matter how deep it has hid, you'll get it.

 

Highlight element at caret

This is a feature I've gradually grown into liking. Having all occurrences of the element you're looking at instantly highlighted in the editor can be a great help for some.

Not surprisingly, the feature works equally well in other supported technologies, like e.g. HTML or JavaScript. To turn the feature on, press Control + Alt + S to open the settings dialog, search for "Highlight usages of element at caret" and check the checkbox.

Done.

Block selection

Copying a block of code or applying a refactoring requires you to select a piece of code for these actions to operate on. Using Control + W to expand selection around caret and Control + Shift + W to shrink it you make sure you always select a semantically valid block of code.

It is as easy as that, in all supported languages, not only Java.

Compare with clipboard

The last trick for today: now when you know how to effectively select a block of code, how about comparing it with the snippet you've just received from your colleague by email? Or with the class in the org.project.used.but.unmainteintable package? IDEA allows you to quickly compare a selected block of code with the content of the clipboard. In fact it goes further than that. You get a complete merge tool, allowing you to make changes to your code or copy and remove distinct pieces of code as blocks.

Refreshing the knowledge from earlier, remember the shortcut for invoking a command by name?

[Control + Shift + A, you're correct]

And here's the merge tool:

Conclusion

These were some of the small shiny productivity pearls I wanted to show today. What are your favorite little IDEA tricks? Let others know in the discussion!

intellij

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Use Golang for Data Processing With Amazon Kinesis and AWS Lambda
  • Microservices Testing
  • What Are the Different Types of API Testing?
  • A Gentle Introduction to Kubernetes

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: