13

My terminal emulator is configured for Unicode character encoding and my .vimrc contains the line

set encoding=utf-8

but when I try pasting the word "café" into vim, it comes out as "café".

I can make an "é" in vim by typing Ctrl-vu followed by the 4-character code point (00e9) but I'd like the ability to paste it in.

sferik
  • 1,795
  • 2
  • 15
  • 22
  • 3
    Sounds like it isn't really UTF-8 – Pekka Nov 15 '10 at 15:13
  • 1
    I agree with Pekka; details of your system might be relevant here. I can paste things like that fine. – Cascabel Nov 15 '10 at 15:15
  • 1
    can you paste it into the same terminal without running vim, i.e. does it show up correctly on the (bash) prompt? – catchmeifyoutry Nov 15 '10 at 15:15
  • Yes, I can paste characters correctly into my shell (bash) and other unix utilities. I tried deleting my .vimrc to see if that fixes the problem, but it doesn't. My full .vimrc file is online here: https://github.com/sferik/dotfiles/raw/master/vimrc – sferik Nov 16 '10 at 01:50
  • System details: MacBook Pro running Mac OS X 10.6.5 with Xcode 3.2.4. I'm using the built-in Terminal.app program. What else would you like to know? – sferik Nov 16 '10 at 01:52

4 Answers4

14

The solution was to uncheck the "Escape non-ASCII input" checkbox in the Advanced tab of the Terminal.app settings.

sferik
  • 1,795
  • 2
  • 15
  • 22
3

Instead of copying the character from the clipboard and pasting it into the text editor, you can add it to the file using vim's digraph feature.

So, with default settings, using your example, you could enter insert mode, then hit Control-k, and type e'. The result will be é.

You can see the list of defined digraphs by running

:digraphs

and general help by running

:help digraph

which also explains how to customize your mappings.

If you are truly set on pasting the characters in, Shift-Insert has always worked for me.

Michael
  • 1,306
  • 1
  • 12
  • 30
2

How to type a non ASCII code into vi

You'll have to know what your encoding is to enter the proper codes, I assume you left VI at the default.

In VI, go into insert mode, while in insert mode, press

Ctrl-v 172

That should insert the Logical Not (sideways and inverted L) character defined here:

http://www.htmlhelp.com/reference/charset/iso160-191.html

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
1
  1. From where are you trying to paste it? If it is opera, then since opera-10.5* paste is broken in both directions. Before pasting anything you need to use xclip -o|xclip -i workaround (add -sel clip for clipboard).
  2. What command do you use?
ZyX
  • 52,536
  • 7
  • 114
  • 135