I have to host an application, which has mixed charsets in the source code. I cannot change this. If I open one of these files in vim, I have to use the following Ex-Command (fileformat oder fileencoding does not help):

:e ++bad=keep myfile

Since I often forget telling vim to keep the bad characters, I have to correct the replaced "?" or have to do my changes again.

My Question: Does anybody knows a way to change the default behavior from ++bad=? to ++bad=keep in the .vimrc?

I could not find an hint in the documentation: http://vimdoc.sourceforge.net/htmldoc/editing.html#++bad

1 Answer 1


I don't know an option that does that. But you could create a specific mapping with something like that:

autocmd BufNewFile,BufRead /path/to/project/**/* nnoremap <leader>e :e ++bad=keep <-- space at the end

and commit it to memory.

  • Mapping a key to open the file with ++bad=keep does not really help. The point is, that I often forget to use it, so it does not help to simplify its usage. Nov 8, 2012 at 8:18
  • The "commit to memory" part is important. Since there's no option to set to let the system do that for you it's up to you to force yourself to do what needs to be done. A short mapping may be easier in that respect.
    – romainl
    Nov 8, 2012 at 8:25
  • Other editors like gedit or geany do not have the problem, they keep the characters on a change all right. I cannot really believe, that there is no global option to stop this odd behavior in VIM??? Nov 9, 2012 at 9:51
  • Nothing is stopping you from using Gedit or Geany instead of Vim if this feature is important to you. Vim is not the absolute answer to every problem. 42 is.
    – romainl
    Nov 9, 2012 at 10:26
  • I just switched from geany to vim a few month ago and happy with it, no real intention for switching back. But where I get this 42-Editor ;-) Nov 9, 2012 at 15:13

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.