this thing drives me crazy, and I am unable to find a solution...

I am logging in to a FreeBSD machine via ssh using MobaXterm. Every time I open a text file with vim, it replaces the first character of the file with 'g'. It is not just garbling the display, when I try to quit vim, it warns me that the file has been changed, and after writing the file the 'g' is in there of course.

The only thing I was able to figure out that this only happens when TERM is set to an xterm variant (xterm, xterm-color, etc.). It does not happen when using other editors (nano or vi).

Could anyone suggest a solution or point me to the right direction what should I check or reconfigure?


The output of :scriptnames

  1: /usr/local/etc/vim/vimrc
  2: /usr/local/share/vim/vim74/syntax/syntax.vim
  3: /usr/local/share/vim/vim74/syntax/synload.vim
  4: /usr/local/share/vim/vim74/syntax/syncolor.vim
  5: /usr/local/share/vim/vim74/filetype.vim
  6: /usr/local/share/vim/vim74/plugin/getscriptPlugin.vim
  7: /usr/local/share/vim/vim74/plugin/gzip.vim
  8: /usr/local/share/vim/vim74/plugin/logiPat.vim
  9: /usr/local/share/vim/vim74/plugin/matchparen.vim
 10: /usr/local/share/vim/vim74/plugin/netrwPlugin.vim
 11: /usr/local/share/vim/vim74/plugin/rrhelper.vim
 12: /usr/local/share/vim/vim74/plugin/spellfile.vim
 13: /usr/local/share/vim/vim74/plugin/tarPlugin.vim
 14: /usr/local/share/vim/vim74/plugin/tohtml.vim
 15: /usr/local/share/vim/vim74/plugin/vimballPlugin.vim
 16: /usr/local/share/vim/vim74/plugin/zipPlugin.vim

I don't have a .vimrc file in my home directory, the one in /usr/local/etc/vim is the unmodified default file that came with the vim package:

if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
        set fileencodings=ucs-bom,utf-8,latin1

let g:is_posix = 1
set nocompatible
set bs=indent,eol,start
set history=50
set ruler

if &t_Co > 2 || has("gui_running")
        syntax on
        set hlsearch

if has("autocmd")
        augroup freebsd
        if $PORTSDIR != ""
                autocmd BufNewFile $PORTSDIR/*/*/Makefile 0r $PORTSDIR/Templates/Makefile
                autocmd BufNewFile /usr/ports/*/*/Makefile 0r /usr/ports/Templates/Makefile

It happens when opening text or binary files. The issue seems to be related to MobaXterm however; it happens only when I connect with MobaXterm. Vim works normally when I use putty or the physical console ($TERM is xterm in both cases).

  • Does that happen with all file types you open with vim? Please post your vimrc and which plugins you load on start.
    – ap0
    Aug 27, 2015 at 12:19
  • Which version of Vim are you using? Aug 27, 2015 at 18:49
  • Sorry for the missing version number, it was 7.4.752. Since then I have upgraded to 7.4.826, but it did not fix the issue. 826 is the latest FreeBSD port available, but I haven't seen any fixes related to this in the README between 826 and the current version (841). As this seems to be an issue with MobaXterm and not with vim, I think I'll stick with putty for the moment. Anyway, thanks for the respnonses! Aug 27, 2015 at 19:11

3 Answers 3


I believe this is a bug, that has recently been fixed. Please update your Vim.

Oh and in case of the mobaxterm, this also seems to be a bug of the mobaxterm

  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. Aug 27, 2015 at 18:34
  • As there were no specific version information, I couldn't be more precise. Also this is more suited for vim-dev ml rather then superuser. Aug 27, 2015 at 18:46
  • @ChristianBrabandt - You should seek the clarification from the author then before you submit an answer. You believe this to be a bug, prove it was a bug, and show when it was fixed. The current revision isn't all that helpful.
    – Ramhound
    Aug 27, 2015 at 19:02
  • @Ramhound. Thanks. I provide enough patches that I know. Thanks for telling me Aug 27, 2015 at 19:09
  • See my comment under the question about version numbers. I could not figure out where the root cause of this could be: a vim issue, a bug in mobaxterm or a freebsd configuration problem. I'll test the issue on a linux box tomorrow. I'll send feedback to the vim-dev list if I find out something vim-related. Thanks for trying to help! Aug 27, 2015 at 19:19

Add this to your ~/.vimrc file:

set background=dark


I meet the same problem. I don't have the solution to fix it. But I do have a workaround to avoid it.

You can install 'tmux' and use vim on tmux, the 'g' issue would be gone.

Your Answer

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

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