What is the best way to check in a vimscript which visual mode is currently active (visual or visual block)?
I've read about mode()
but I can't make it work.echo mode()
doesn't work for meif mode() == "v"
doesn't work for me as well.
vi (visual editor) is included with all (mt) Media Temple services. vi is a full screen editor and has two modes of operation. Command Mode - every character entered is a command. This is the default mode when you start vi. Insert Mode - this mode allows you to edit.
If you're in character-wise visual mode, pressing v will exit visual mode. If you're in block-wise visual mode, pressing ctrl-v will exit visual mode.
Press the v key to enter visual character mode. The word VISUAL will appear at the bottom of the screen. Use the Arrow keys to highlight the desired text. You can use other navigation commands, such as w to highlight to the beginning of the next word or $ to include the rest of the line.
Look at the help for mode()
. The relevant part:
v Visual by character V Visual by line CTRL-V Visual blockwise
You need to be checking mode() == "\<C-V>"
(literal ^V
character), not mode() == "v"
, to check for blockwise visual mode.
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