4

I use vim for editing everything. Occasionally while I have vim open someone else will want to write something for me. (My coworkers explaining code, friends helping me write something/leaving notes for me, etc.) As I'm sure you all know, vim isn't exactly, uhm Intuitive to people who have never used it before.

As soon as they start typing, I watch the visible panic on their face as they realize my text editor is the text editing equivalent of the sonic screwdriver. They have no idea what's happening, and it's flashing, my text is deleted and they've accidentally opened 2 help buffers and the command line history.

Can I make vim act like every other boring text editor for a little while? I know about vim's easy mode:

                            *-y* *easy*
-y      Easy mode.  Implied for |evim| and |eview|.  Starts with
        'insertmode' set and behaves like a click-and-type editor.
        This sources the script $VIMRUNTIME/evim.vim.  Mappings are
        set up to work like most click-and-type editors, see
        |evim-keys|.  The GUI is started when available.
        {not in Vi}

But this doesn't help me because it's only a startup option. I'd love to have a way to keep all my old files open, press a key-combination, and have all vim-like bindings disappear until I press it a second time.

Is there any existing plugin for this? If not, what settings/features should I look into if I were to write my own?

3
  • 2
    It looks like you could start from evim.vim and mswin.vim. If it may help you, I have a very old (vim 5.4 era, IIRC) and clumsy plugin able to toggle the activation state of mappings and other things it may be a starting point: github.com/LucHermitte/lh-misc/blob/master/plugin/Triggers.vim Jan 12, 2017 at 18:51
  • 2
    Could you not just put it in insert mode? As long as they don't press escape it'll behave like notepad for anything they would need for a short editing session.
    – Tumbler41
    Jan 12, 2017 at 20:16
  • :!nano % should do it.
    – Antony
    Jan 15, 2017 at 16:02

1 Answer 1

3

If if has to be the same editor, I would go with :set insertmode. This basically switches to the mentioned easy mode, even <Esc> won't do harm. Leave again with <C-O>:set noinsertmode<CR>.

However, I would instead allow your colleague to open the text file in a different editor of his choosing. Just :write any unpersisted changes, and open it elsewhere in parallel. Settings like :set autoread make this even more comfortable.

I personally often edit / browse the same files in GVIM and an IDE (IntelliJ IDEA). You could even facilitate this with a custom :OpenWith command within Vim. In a graphical environment, it's easy to open another editor; it's only clumsy if you only have a single SSH terminal connection; you'd block your Vim unless you open another connection or use a terminal multiplexer like screen or tmux.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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