1

I'm trying to create a macro to quickly enter two matching braces {} with an empty line in between that has the deeper indentation.

My current macro performs this sequence:

  1. {
  2. Enter
  3. Enter
  4. }
  5. Tab

This works fine, and returns the expected brace-pair and indentation between them:

{

}

But with nested brackets, the closing } has no indentation:

{
    {

} <--
}

How to overcome this?

1 Answer 1

1

You could duplicate the indent that was already made to two new lines, using the "duplicate selection" command, usually mapped to Ctrl+D, but check your mapped key in Settings > Shortcut Mapper:

enter image description here

The key sequence would be:

  • End to place the caret at the end of the current line
  • {
  • Ctrl+D to copy the current line (together with the brace)
  • to move caret to the end of the copied line
  • Shift+Home to select the text on the copied line
  • Del to remove that text (at least the brace)
  • Ctr+D to duplicate this empty line
  • }
  • Up
  • Tab

This will also work as expected when there is already text on the current line.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.