Editing visual selections
Visual selection is a powerful tool for applying commands to specific regions of a buffer. But it can be frustrating to have selected the wrong portion and need to start your selection over. Many times I’ve had to hit <Esc> and restart a visual selection because I realized my selection didn’t start at the right point. But this frustration can be easily remedied by making use of o:
- Pressing
owhile visually selecting moves the cursor to the opposite end of the selection.
Instead of pressing <Esc> and starting over, I can press o to move the cursor back to the beginning of the visual selection. From there, I can use the usual suspects to adjust the beginning of the visual selection. For example j or k, or <C-u>, or perhaps ?^3. If I want to get back to the bottom of the visual selection and select more, I can press o to bounce to the other end. This trick has remedied a frustration I’ve long had with using visual mode.
Check out the gif at the bottom of this message. In it, I incrementally select some text that I wish to move to the left. But I missed the first few lines, so I press o to move my cursor to the back of the selection, then press k to adjust the top boundary.
