2

Problem Statement

I have recently run into an issue on one of my servers where when I start typing from insert mode I always go to the second column of my current line.

Example

filters     = [
    {
 .gniyonna repus si sih       T
        'Name': 'tag:VPC',
        'Values': [
            'Staging'
        ]
    },
    {
        'Name': 'instance-state-name',
        'Values': [
            'running'
        ]
    }
]

Expected output

filters     = [
    {
        This is super annoying.   # This would not be annoying
        'Name': 'tag:VPC',
        'Values': [
            'Staging'
        ]
    },
    {
        'Name': 'instance-state-name',
        'Values': [
            'running'
        ]
    }
]

When this started

This started when I was trying to save some time and pasted a script (python) from my workstation in paste (and insert) mode vice SCPing the script or cloning it from my repo like I should have done.

If curious this was the contents of the script that I copied from my workstation:

https://github.com/ScriptMyJob/Lambda_ansible/blob/master/Resources/ec2_inventory.py

Question

Does anyone have any idea what mode I am in and how I would correct it?

Thanks in advance for any help.

2
  • What do you mean by "vice" in "vice SCPing"? Commented Jan 13, 2018 at 0:15
  • I could not reproduce your super-annoying-yet-funny-to-me issue while in Paste and Insert mode. Could someone else have accessed your machine and changed your vim config files or plugins between pasting the script and the emergence of the issue? Seems like a .vimrc bad coworker joke. x) Commented Jan 13, 2018 at 0:26

1 Answer 1

1

Your problem:

You seem to have the revins option set. From vim :help revins:

                *'revins'* *'ri'* *'norevins'* *'nori'*
'revins' 'ri'       boolean (default off)
            global
            {not in Vi}
            {only available when compiled with the |+rightleft|
            feature}
    Inserting characters in Insert mode will work backwards.  See "typing
    backwards" |ins-reverse|.  This option can be toggled with the CTRL-_
    command in Insert mode, when 'allowrevins' is set.
    NOTE: This option is reset when 'compatible' or 'paste' is set.

And from :help ins-reverse:

o  Typing backwards                 *ins-reverse*
   ----------------
   In lieu of using full-fledged the 'rightleft' option, one can opt for
   reverse insertion.  When the 'revins' (reverse insert) option is set,
   inserting happens backwards.  This can be used to type right-to-left
   text.  When inserting characters the cursor is not moved and the text
   moves rightwards.  A <BS> deletes the character under the cursor.
   CTRL-W and CTRL-U also work in the opposite direction.  <BS>, CTRL-W
   and CTRL-U do not stop at the start of insert or end of line, no matter
   how the 'backspace' option is set.

   There is no reverse replace mode (yet).

   If the 'showmode' option is set, "-- REVERSE INSERT --" will be shown
   in the status line when reverse Insert mode is active.

It's likely a joke someone made on you (or very bad luck when pasting while in normal mode) by remapping i in Normal mode. It could be adding something like nnoremap i :set revins<CR>i in your .vimrc or another vim config file that is sourced when vim is started. See :scriptnames to see which files got sourced at vim startup.

Solution:

Only for current session

Simply run the command :set norevins in Normal mode. Then check your mappings with :map. If you see a mapping like n i * :set revins<CR>i, that's the culprit! Then simply run :nunmap i, which will unmap i in Normal mode. Remember:

:nunmap can also be used outside of a monastery.

Now in Normal mode, i should not set the revins option.

For all new vim sessions:

I'd advise grep-ing "revins" in your .vimrc, your .vim directory, and loaded scripts (see :scriptnames) in case it's a coworker's joke. :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.