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

See VCS Changed Lines In Gutter
Quickly spot which parts of your file have changed since the last commit.
Autocomplete Django Settings Strings
Use autocomplete when typing a string in the apps section of your settings file.
Split Screen Without Tabs
Get your code and tests side-by-side without resorting to tabs.