5

Whenever I type an accented character in vim, like for example: é it places an extra space like so é<space>.

Small gif animation that illustrates the problem: Link here. Notice that in the screen recording I am at no point pressing the space bar and yet they appear.

It's the exact same problem as described in this SO question and in Super user question too, but the solution proposed for both - set encoding=utf-8 - is not working for me. I've placed that in both the .vimrc and in a running session and none worked.

In MacVim, which set encoding? also outputs encoding=utf-8, this issue doesn't happen.

I installed vim with brew, here's the info command of it:

vim: stable 7.4.488, HEAD
http://www.vim.org/
Conflicts with: ex-vi
/usr/local/Cellar/vim/7.4.488 (1600 files, 26M) *
  Built from source with: --override-system-vi
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/vim.rb
==> Dependencies
Optional: lua ✔, luajit ✔
==> Options
--disable-nls
    Build vim without National Language Support (translated messages, keymaps)
--override-system-vi
    Override system vi
--with-client-server
    Enable client/server mode
--with-lua
    Build vim with lua support
--with-luajit
    Build with luajit support
--with-mzscheme
    Build vim with mzscheme support
--with-python3
    Build vim with python3 instead of python[2] support
--with-tcl
    Build vim with tcl support
--without-perl
    Build vim without perl support
--without-python
    Build vim without python support
--without-ruby
    Build vim without ruby support
--HEAD
    Install HEAD version

And :version info here:

:version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan  5 2015 21:44:59)
MacOS X (unix) version
Included patches: 1-258
Compiled by Homebrew
Huge version with MacVim GUI.  Features included (+) or not (-):
+acl             +cmdline_info    +emacs_tags      -gettext         +lua             +mouse_urxvt     +profile         +statusline      +transparency    -X11
+arabic          +comments        +eval            -hangul_input    +menu            +mouse_xterm     +python          -sun_workshop    +user_commands   -xfontset
+autocmd         +conceal         +ex_extra        +iconv           +mksession       +multi_byte      -python3         +syntax          +vertsplit       +xim
+balloon_eval    +cryptv          +extra_search    +insert_expand   +modify_fname    +multi_lang      +quickfix        +tag_binary      +virtualedit     -xsmp
+browse          +cscope          +farsi           +jumplist        +mouse           -mzscheme        +reltime         +tag_old_static  +visual          -xterm_clipboard
++builtin_terms  +cursorbind      +file_in_path    +keymap          +mouseshape      +netbeans_intg   +rightleft       -tag_any_white   +visualextra     -xterm_save
+byte_offset     +cursorshape     +find_in_path    +langmap         +mouse_dec       +odbeditor       +ruby            +tcl             +viminfo         -xpm
+cindent         +dialog_con_gui  +float           +libcall         -mouse_gpm       +path_extra      +scrollbind      +terminfo        +vreplace
+clientserver    +diff            +folding         +linebreak       -mouse_jsbterm   +perl            +signs           +termresponse    +wildignore
+clipboard       +digraphs        -footer          +lispindent      +mouse_netterm   +persistent_undo +smartindent     +textobjects     +wildmenu
+cmdline_compl   +dnd             +fork()          +listcmds        +mouse_sgr       +postscript      -sniff           +title           +windows
+cmdline_hist    -ebcdic          +fullscreen      +localmap        -mouse_sysmouse  +printer         +startuptime     +toolbar         +writebackup
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -DMACOS_X_UNIX  -I/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Ve
rsions/2.7/include/python2.7 -I/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/include/python2.7 -fno-strict-aliasing -fno-common -dynamic -I/usr/local/inclu
de -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1     -I/System/Library/Frameworks/Tcl.framework/Headers  -D
_REENTRANT=1  -D_THREAD_SAFE=1  -D_DARWIN_C_SOURCE=1
Linking: clang   -L. -L/usr/local/lib -L. -L/usr/local/lib -L/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config -lpython2.7 -framework Core
Foundation -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon       -lm  -lncurses -liconv -framework Cocoa  -pagezero_size 10000 -image_base 100000000 -L/usr/local/lib -llu
ajit-5.1 -fstack-protector -L/usr/local/lib  -L/System/Library/Perl/5.16/darwin-thread-multi-2level/CORE -lperl -framework Python  -F/System/Library/Frameworks -framework Tcl -frame
work CoreFoundation -framework Ruby

And my locale:

LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL="en_US.UTF-8"

Any ideas? Thanks.

Community
  • 1
  • 1
nunos
  • 20,479
  • 50
  • 119
  • 154
  • You know you can run MacVim *in* your shell with `$ mvim -v`, right? – romainl Feb 24 '15 at 22:36
  • @romainl hm.. I've tried that and still have the same issue. Any other ideas? Thanks! – nunos Feb 24 '15 at 23:06
  • does this also happen with new files created on your local filesystem? I made the experience, that files from other sources (like windows) can cause troubles for vim, despite the fact that encoding is set. because vim tries to write in utf-8 encoding to a file which originally is latin-1. if this is the fact, try to convert the file with `iconv -f latin-1 -t utf-8` – syss Feb 25 '15 at 14:40
  • @syss thanks for your replied. I double checked that and no, that is not the case. For files created in my filsystem and inside vim even the issue still occurs. Any other ideas? Thanks! – nunos Feb 25 '15 at 18:28
  • Can you post `:version`? – svlasov Feb 27 '15 at 10:59
  • @svlasov updated answer with that – nunos Feb 27 '15 at 11:49
  • What's the locale in your terminal? – Christian Brabandt Feb 27 '15 at 13:31
  • I have it set all to `en_US.UTF-8` normally. I've tried with `pt_PT.UTF-8` but the same thing happens. – nunos Feb 27 '15 at 16:13
  • en_US.UTF-8 seem to be fine. Can you check the output of `$ echo $TERM` ? Also check the contents of your _~/.inputrc_ . – Luís Bianchin Mar 02 '15 at 21:17
  • Check also this answer: http://stackoverflow.com/a/4606636/1046584 – Luís Bianchin Mar 02 '15 at 21:36
  • What exactly are you typing to insert the `é`? I've tried to insert it using (not on Mac but Linux admittedly) by typing `Ctrl-shift-u 00e9 ` and I don't have the same problem – texasflood Mar 02 '15 at 23:19
  • Can you post your vimrc? – FDinoff Mar 03 '15 at 21:03
  • Are you using `terminal.app`? Have you tried mucking about with its locale/encoding settings? Trying a different terminal might be worthwhile too. Do accented characters display properly on the shell prompt? – Ulfalizer Mar 03 '15 at 21:20
  • (Moving "answer" to comment.) This is a stretch, but you could check whether your accented characters are inserted using combining characters too, in case that's tripping something up. One easy way would be to `:set delcombine` and see if you can delete the accent separately. – Ulfalizer Mar 03 '15 at 21:52
  • If I'm understanding correctly, you had only run `:set encoding?` in GUI MacVim. What does it say in terminal Vim/MacVim? – Ulfalizer Mar 03 '15 at 21:53

1 Answers1

4

None of the suggestions of the comments worked for me, so I kept on digging on the issue myself. In the end it was just a matter of unchecking an iTerm setting.

iterm settings

nunos
  • 20,479
  • 50
  • 119
  • 154