Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to write a plugin for Vim using Tcl as the backend language. I have written and tested most of the code and it seems to work fine except for one hurdle I can't seem to get over: encoding.

I wonder if someone here is willing to take a test.

Create ~/.vim/plugin/tcltest.tcl with these lines:

proc tcl.test   {}  {
    array set CURSOR [[set ::vim::current(window)] cursor]
    lassign "$CURSOR(row) $CURSOR(column)" CR CC
    set bufferCommand [set ::vim::current(buffer)]

    set string "já não bênção"
    puts $string
    $bufferCommand set $CR $string

Then add these lines to ~/.vimrc:

if has("tcl")
    tclfile ~/.vim/plugin/tcltest.tcl
inoremap  ?   ^[:tcl tcl.test<CR>

Now relaunch Vim with a new document, go into Insert mode and press '?'

Two things should happen:

1) the string "já não bênção" should be displayed in the message area

2) the string "já não bênção" should be inserted into the buffer

It will look fine in the message area, but it will be all garbled in the buffer because of the accented characters.

There is an 'encoding' command in Tcl and I have tried ALL possible encodings in a foreach loop, but none of them works.

I am convinced that this is a bug, because the string should at least be the same in the buffer and the message area. Even if I am doing something wrong with my Tcl code, the mistake should be reflected in both places.

Can someone please confirm (or not) this and report Vim version and OS/platform?

share|improve this question
Seems to work fine here (manually loaded the tclfile and added the mapping). Debian unstable, console, vim 7.3 patches 1-923 Huge. – Etan Reisner Jul 10 '13 at 19:31
What encoding settings do you have set in vim? What exactly does 'all garbled' mean? – Etan Reisner Jul 10 '13 at 19:31
encoding=latin1, fileencoding= All Garbled means the accented characters become all messy, obviously set to wrong encoding. – movingtype Jul 10 '13 at 20:01
It seems to work for me here when I run with that encoding set up as well so I'm not sure what you are seeing exactly but are those characters even legal latin1 characters? Should this be expected to work at all? – Etan Reisner Jul 10 '13 at 21:36
Yes, they're legal, but not the correct ones. "já não bênção" becomes "já não bênção". Why wouldn't it be expected to work??? Why isn't the output even the same in the message area and text buffer? They should at least be the same. – movingtype Jul 10 '13 at 21:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.