Learning that Vim has insert mode keystrokes that do special things
I use Vim a fair bit, but most of the time I'm merely doing ordinary text entry, predominantly in insert mode. At the same time, I am not the world's best typist (my Delete key gets a good workout). One of my long-standing Vim experiences is that I will be typing along, happily entering text, and then I will do something and suddenly I will have a jumble of unwanted text and text changes.
(This is different from the classical Vi experience where you fumble what you're typing in command mode and all sorts of things happen.)
For a long time, I assumed that I had probably accidentally escaped into command mode and triggered the classical Vi mistake of typing random things in command mode. However, recently I was reading A Vim Guide for Adept Users (one of my hobbies is reading Vim guides), and hit the section on Useful Keystrokes in Insert Mode. A little light went on in my mind.
I've always known that Vim responds to some control keys and key sequences in insert mode, and in fact one of the ways I'm using Vim instead of Vi is that I want Delete in insert mode to back up past the start of the line. However, I hadn't previously known that Vim had such a significant collection of text modification keystrokes in insert mode. The two keystrokes that seem most likely to be responsible for various of my mistakes are Ctrl-a (which will insert various amounts of text) and Ctrl-@ (which inserts text and then escapes to command mode on the spot, where my continued typing will cause even more damage). Ctrl-a is relatively easy to hit, too.
PS: My unintended text alteration adventures are probably not helped
by my habit of escaping to command mode periodically to do various
fidgets, like writing the file or reflowing the paragraph. Command
mode has all sorts of dangerous characters that can cause lots of
havoc, including '
.' and the number keys, and there are a number
of ways to accidentally start entering a multi-character sequence
that will trap and reinterpret the rest of what you think you're
typing as commands.
Comments on this page:Written on 13 August 2021.