2

I would like to be able to mark the current block scope. In other words, given some piece of code like:

...
if (1) {
  ...
}
...

If my cursors was sitting somewhere inside the if-body, it would mark that area of code. I guess a quick and dirty solution would be to just have a script scan for the previous curly brace and select everything between it and its match.

If there's no existing command for this, would someone know how to implement it?

0

2 Answers 2

1

Does either M-x mark-defun or c-mark-function (C-M-h in my setup) do what you want?

If not, expand-region is another very good option (a video demo can be found here). With that package installed (it is available through MELPA) you can use the command er/expand-region to expand the selected region by semantic units. It may not select the area you want on the first invocation, but repeated invocations will definitely get you what you want. That package is amazing, and will work intelligently with many different modes (i.e., what is considered a "semantic unit" will differ from mode to mode).

1

The way I'd do it is: M-C-u M-C-SPC: the first moves up-list and the second selects the next sexp.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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