Add Line After/Before

Smart-add a line, from the middle of a line, after or before the current line.

It's easy to overlook, but we frequently add a line of code while in the middle of another line. Perhaps we were fixing something and want to proceed to the next line. Perhaps we were on an import and want another import on the line above.

It's tempting, for adding a line after, to treat this as a two-step process:

  • Go to the end of the line (ugh, sometimes with the mouse)
  • Press (macOS) / Enter (Windows/Linux)

Adding a line above is worse:

  • Go to the beginning of the line

  • Press (macOS) / Enter (Windows/Linux) to make space above

  • Press (macOS) / Up Arrow (Windows/Linux) to go to that new, empty line

  • Perhaps press tab a few times to get the indentation right

Instead, use Start New Line ⇧⏎ (macOS) / Shift+Enter (Windows/Linux). With your cursor anywhere in the current line -- where you are just finishing an edit -- you can then get an empty next line, with correct indentation.

For a line above, use Start New Line Before Current ⌘⌥⏎ (macOS) / Ctrl+Alt+Enter (Windows/Linux) You get a new line, indented appropriately for the language and context.


Related Resources

Navigation Bar - All the power!
Navigation Bar - All the power!
The Navigation Bar can do much more than you think!
Clean Up Messy Imports With Optimize Imports
Clean Up Messy Imports With Optimize Imports
Quickly remove any unused imports and more.
Find in Path with the Navigation Bar
Find in Path with the Navigation Bar
Use the Navigation bar and Find in File together and be faster than all of your team members.