I'm trying to apply the Shift-v keymap in a vimscript, but not sure how. I tried using <s-v> and Shift-v without success.

  • Isn't that just a capital V? nnoremap V :echo "Hello World!"<CR> – filbranden Sep 7 '20 at 6:55
  • tried using V in a function but it didn't do anything...offtopic but trying something like normal! gv does work though. – Nordine Lotfi Sep 7 '20 at 6:56
  • Question is somewhat unclear though... What does the "in a function" part mean? How does that relate to mappings? – filbranden Sep 7 '20 at 6:56
  • my bad, didn't meant to use the key-binding tag (it has no relation to keymapping, which the question illustrate better) – Nordine Lotfi Sep 7 '20 at 6:58
  • 1
    How about normal! V to start visual line selection? Is that what you're looking for? – filbranden Sep 7 '20 at 6:58

Shift+v simply produces an uppercase V, so that's what you typically pass to Vim.

Whether it is to create a mapping for that keystroke:

:nnoremap V :echo "Hello World!"<CR>

Or to use :normal! to simulate that keystroke to start a visual line selection:

:normal! V

The <S- prefix does exist, but it's generally only used with special non-alphanumeric keys. For example, <S-Tab>, <S-Left> or <S-F1> (and note that Vim is not always able to recognize all these special keystrokes, it often depends on which terminal it's running on.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.