Search code examples
vimneovim

Vim Visual Mode cursor movement that ignores underlying whitespace


Is there a mode, or alternatively, is it possible to configure vim/nvim to allow the cursor to be placed at any location regardless of if said location has whitespace, text, or nothing at all ?

Analogy here would be that this mode I'm suggesting is like a paint canvas where you can click or use visual mode to type hjkl anywhere on the 'canvas' (the document).

It wouldn't modify unless you type there of course, in which case the extra whitespace would have to be added to meet your cursor ie- if in Visual Mode you navigated to the top right of your document and then hit Insert Mode its at that moment I assume the plugin or hack here would have to do some magic to edit the document whitespace to fill in the gap from nearest existing whitespace to where your cursor is.


Solution

  • See :help 'virtualedit' and section 25.5 'Editing tables' in :help usr_25.txt

    You can put this in your .vimrc:

    " allow cursor to be positioned where there are no chars
    set virtualedit=all