5

This also happens when copying and pasting. I am attempting to edit Go code and typing or copying and pasting "package main" comes out as "pkage main". No idea why I can't type a c. Pressing delete backspace prints out a ^? and pressing delete actually deletes a character. I tried restarting it but I have no idea how else to troubleshoot this and I could find nothing online.

11

Possible Cause 1:

If c works normally everywhere such that this problem only affects Vim, it could be that there may be an abbreviation or mapping set up for c. Examine your .vimrc file(s).

I just temporarily turned my c into backspace in Vim in the normal, command, normal and insert modes:

:map c ^?
:nmap c ^?
:imap c ^?

(Where ^? denotes the result of typing Ctrl-VBackspace.)

Possible Cause 2:

You have c as the erase character in your TTY. That is to say, as if the following command had been executed:

stty erase c

However, this would also affect other programs and shells. Try

stty sane

in your shell to reset the TTY parameters to some reasonable default settings. This is a useful command to remember; it comes in handy when some visual program unexpectedly dies, leaving the TTY settings in an inappropriate state.

  • +1 for including the stty sane command. Well worth remembering. The number of times I had to kill a terminal window because something got corrupted... – Floris Dec 21 '15 at 14:45
2

Sounds like something garbled in the paste process.

When you paste to any other editor, does it work or just the same? If it is the same, then perhaps the source was already garbled to begin with.

If other editors paste fine, then, try the clipboard paste shortcut:

"+++p

If you are copying from the other app using merely selecting with your mouse, you should use instead:

"+*+p

If you still find oddities, try:

  1. :set paste to enter vim's paste mode.
  2. then try the above paste shortcuts
  3. When you want to turn off paste mode for any reason just :set nopaste.
  • I don't think it is a paste issue. Just pressing the "c" key results in deleting the most recent character. Typing func goes like, f, fu, fun, fu. Also pasting into cat >example has the exact same results. Pasting into the shell however works just fine. – I'm a noob Dec 21 '15 at 2:17
  • vim's paste mode has the same problem, along with the keyboard shortcuts. – I'm a noob Dec 21 '15 at 2:23
  • In that case, on command prompt, when you run lsb_release -a there should be multi-line system summary info, and vim --version should also be a multi-line response with version details. Would you be able to copy paste these two outputs and update the question with this info? Thanks – clarity123 Dec 21 '15 at 2:42
  • Kaz answered it for me but thanks for the help! – I'm a noob Dec 21 '15 at 5:32
  • No problem, and welcome to the world of Linux! – clarity123 Dec 22 '15 at 2:58
0

Copying and pasting in the console works in the way that the text is inserted char by char, and Vim interpretes each char to mean something.

When using Vim, make sure you're in --INSERT-- mode, and not command mode. In Command mode, a 'c' means change, and for example, if you type ce, Vim'll delete till the end of the word and enter Insert mode.

'^' stands for Command. ^C means Ctrl+C. That's the console, not the Vim editor itself. You'll get a similar character If you press Ctrl-(something) or the Escape key.

All the standard navigation keys(such as Home, Delete, PgUp/PgDn, arrow keys), are included in modern Vi as a backup. It's for users who prefer not to use/find it hard to use x or d or the hjkl scroll keys.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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