Junkai
Junkai

Reputation: 71

Can I only use normal mode and insert mode in Vim?

I don't need other mode except this two, so I don't want to switch to Visual Mode automatically when I highlight some text, or a variety of other automatic mode switching.

Just start and stay in Insert Mode, switch to Normal Mode only when I press <Esc>, after some action, press i/a/I/A... to go back to Insert Mode.

Other features I will use other tools to achieve.

Thanks for help.


Edit:

This should be what I actually want, it seems I asked a wrong question. VSCodeVim issue

Upvotes: 2

Views: 314

Answers (2)

Ingo Karkat
Ingo Karkat

Reputation: 172590

There's only a limited set of commands that changes modes. You can neutralize them, e.g.:

" No visual mode.
:nnoremap v <Nop>
:nnoremap V <Nop>
:nnoremap <C-v> <Nop>

" No command-line mode.
:nnoremap : <Nop>
...

And additionally :set mouse=, as mentioned in @windyjonas answer.

But... why?

I don't understand the motivation for this. For inexperienced users, a non-modal editor (or :help easy mode) would be much better than forcing the steep learning curve of Vim onto them. Other users probably don't like the limitations you force on them.

If this is for security (e.g. to avoid breaking out of normal editing by :sourceing plugins, :call system(), etc.), it will be hard to find and close all loopholes. There are better ways to address this (see sudoedit).

Upvotes: 6

windyjonas
windyjonas

Reputation: 2322

Add set mouse-=a to your ~/.vimrc file.

Upvotes: 5

Related Questions