I want to delete the first x characters for every line in a region.
Is there any key binding available to do this without using regex?
The best way to do this is to use the "rectangle" family of commands. For example, mark the beginning of the region. Go to the end of the region and place the point at column X. Run the command kill-rectangle
using C-x r k
.
Of course, this is not limited to deleting characters at the beginning of lines.
If the mark is on column 0, put the point on column x and use kill-rectange
:
C-x r k runs the command kill-rectangle, which is an interactive
autoloaded Lisp function in `rect.el'.
It is bound to C-x r k.
(kill-rectangle START END &optional FILL)
Delete the region-rectangle and save it as the last killed one.
When called from a program the rectangle's corners are START and END.
You might prefer to use `delete-extract-rectangle' from a program.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With