Check Visual mode

mode, vim

Solution

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.

Problem

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 me `if mode() == "v"` doesn't work for me as well.

Original source

Related problems