I want to select or highlight a block in emacs without using mouse but doing it from the keyboard like vim's visual mode. What is the easiest way to do this from a keyboard?
You can select blocks of text in Emacs just as you would in most other environments. You could, for example, drag your mouse over a region. You could also hold down the Shift key and use arrow keys. But Emacs also has a number of commands that let you work in larger semantic units.
Alternatively, if you are running Emacs in its own window (and not within an "xterm" window) as part of an X Window session, you can select the region simply by using the mouse. Click the mouse's left button at the start of the area to be selected, and drag the mouse to the end of the area.
C-x h will select the entire buffer. You can search for help within Emacs using the built-in help system.
Place the cursor on either side of the word, then hold the shift key down and hold the alt/option key down, and then use the left or right arrow.
If I understand the question correctly, it is not about rectangular regions originally.
C-Spc
puts a mark at the current position.
Wherever your cursor is afterwards, the text between the last mark and the current position is "selected" (you can highlight this by activating transient-mark-mode
, but this will also mean that marks have to be deleted when you don't want highlight).
You can operate on that region with commands like:
C-w
. . Kill region. This deletes and puts the region into the kill ring.C-y
. . Yank. This inserts the last snippet from the kill ring.M-y
. . Cycle kill ring. Immediately after C-y
, this replaces the yanked part by the other snippets in the kill ring.M-w
. . Save region into kill ring. Like C-w
, but doesn't delete.
This is just the basic usage. Marks have other uses, too. I recommend the tutorial (C-h t
).
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