Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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 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:

share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer
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. – Trendfischer Nov 8 '12 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 '12 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??? – Trendfischer Nov 9 '12 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 '12 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 ;-) – Trendfischer Nov 9 '12 at 15:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .