How to keep Vim's visual mode selection while scrolling with Ctrl-F?

3

When I select text in Vim's visual mode, scrolling with Ctrl-F cancels the selection. How can I keep the selection while scrolling (with Ctrl-F)?

Micha Wiedenmann

Posted 2015-12-07T10:41:46.913

Reputation: 171

When I press Ctrl+f in visual mode, it doesn't cancel the selection. It continues to select additional lines. Your plugin might have changed default settings. Try starting vim with vim -u NONE filename. It should work – SibiCoder – 2016-04-25T08:19:02.633

Answers

2

This happens on Windows with the default configuration, which calls :behave mswin, which in turn sets

keymodel=startsel,stopsel

The stopsel tells Vim to stop the selection if the cursor keys, End, Home, PageUp, PageDown are pressed. For some reason Ctrl-F seems to trigger PageDown.

To change this behavior, you can remove stopsel from the keymodel setting:

:e $HOME/_gvimrc

and add the following:

" Prevent CTRL-F to abort the selection (in visual mode)
" This is caused by $VIM/_vimrc ':behave mswin' which sets 'keymodel' to
" include 'stopsel' which means that non-shifted special keys stop selection.
set keymodel=startsel

References

Micha Wiedenmann

Posted 2015-12-07T10:41:46.913

Reputation: 171