Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a shortcut for inserting date/time in IntelliJ IDEA?

I'd like to add date/time for comments so that I can know when I did those changes, and I am doing that by hand now because I could not find a shortcut. What a great plus for IntelliJ IDEA to have a shortcut for that!

like image 344
John Avatar asked Jan 03 '12 15:01

John


People also ask

What does Alt enter do in IntelliJ?

Fix code problems The most powerful tool in IntelliJ IDEA that operates by means of Alt+Enter is code inspections. Pressing this shortcut on a highlighted code element in the editor opens a list of possible fixes from which you can select the one that works best.

How do I search for a shortcut in IntelliJ?

From the main menu, select Edit | Find | Find in Files Ctrl+Shift+F . In the search field, type your search string. Alternatively, in the editor, highlight the string you want to find and press Ctrl+Shift+F . IntelliJ IDEA places the highlighted string into the search field.

How do I run a shortcut code in IntelliJ?

Ctrl Ctrl. We can run anything from anywhere by pressing the Ctrl key twice. No matter where we are in the IDE or which file is open, if we double tap Ctrl the Run Anything window opens.

How do you jump to method in IntelliJ?

Navigate to Implementation We can use ⌥⌘B on macOS, or Ctrl+Alt+B on Windows and Linux to navigate to one of four implementations. If there is only one implementation, IntelliJ IDEA will take you straight there without the additional prompt.


1 Answers

You can create your own:

  1. In Settings, go to Live Templates
  2. Add a new template with the abbreviation "date"
  3. For "template text", specify $date$. Now the "Edit Variables" button should be enabled.
  4. Edit the variables, and set $date$ to use the expression date().
  5. Enable "Java comment" under the template's context and click OK.

Now when you type "date" and use the default completion gesture (Tab), it will replace "date" with the current date.

You can also make use of the time() expression. Note that it doesn't seem like IntelliJ has great support for specifying the format of this date.

like image 147
Mark Peters Avatar answered Sep 23 '22 15:09

Mark Peters