Skip to content

Add text objects that include surrounding whitespace #24

@padde

Description

@padde

Similar to the way aw, ap etc. also include the surrounding whitespace. This would be useful to delete an entire block e.g. daR without having to delete the remaining empty lines manually. For example:

test do
  foo do
    bar
  end

  baz do
    quux
  end
end

putting the cursor within the first nested block and pressing dar results in:

test do

  baz do
    quux
  end
end

pressing daR should then result in:

test do
  baz do
    quux
  end
end

Analogously, pressing daR when the cursor is in the second nested block should result in:

test do
  baz do
    quux
  end
end

So the included surrounding whitespace should be:

  • All empty lines and whitespace after the block
  • BUT: All empty lines and whitespace before the block, if there is none before
  • This is also analogous to what vaw does, for example

This is also helpful when integrating with the expand-region plugin. It is important here that we have the surrounding whitespace included so that a repeated application of alternating vir and vaR will continue to bubble up to the topmost block. This way the selection will hopefully correctly expand up the hierarchy. Currently it is a big annoyance for me that this does not work properly.

I'd love to give it a shot and make a PR, however I'd first like to hear your opinion on whether I missed anything and whether this is deemed useful. Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions