1

I use vi and when I am in an insert mode, it will print ^? instead of actually deleting the text.

I referred to this vim backspace leaves ^? but it does not solve my problem.

I created the .vimrc file in /u/myname dir.
Does .vimrc needs to be in a certain location?

In .vimrc, I have

set backspace=2
set backspace=indent,eol,start

What needs to be in .vimrc file?

Community
  • 1
  • 1
ealeon
  • 12,074
  • 24
  • 92
  • 173
  • Your `.vimrc` should be in your home folder, i.e. `/home/ealeon/.vimrc` (or `~/.vimrc` for short). I'm not sure what `/u/myname` means. Also, is there any reason you use Vi, and not Vim? – timss Jun 10 '13 at 15:09
  • @timss its a shared server so each of us has /u/ourname dir – ealeon Jun 10 '13 at 15:10
  • just used to using vi instead of vim. i dont really see the difference between the two. but do you know what needs to be in .vimrc file? – ealeon Jun 10 '13 at 15:11
  • I can only talk for Vim, but take a look at [this answer](http://stackoverflow.com/questions/3495124/not-reading-vimrc) to check if your `.vimrc` is being read (strace is interesting). Maybe a simpler solution would be to add `let test_vimrc=1` in your `.vimrc` and do `:echo test_vimrc` to see if it exists. Not sure if Vi even uses vimrc, I don't have a system that doesn't have Vim (and it seems to override my Vi). – timss Jun 10 '13 at 15:18
  • There are quite the number of differences between the two, especially when it comes to configuration. Read more about it [here](http://stackoverflow.com/questions/1159206/difference-between-vi-vim) and [here](https://en.wikipedia.org/wiki/Vim_(text_editor)#Features_and_improvements_over_vi). – timss Jun 10 '13 at 15:19
  • If you are using vi the commands should be in `~/.exrc` not `~/.vimrc` – FDinoff Jun 10 '13 at 15:19
  • @FDinoff okay could you elaborate further? what exactly needs to be in ~/.exrc? I suppose i am treating vi/vim as the same thing which appears to be not correct. – ealeon Jun 10 '13 at 15:22
  • @timss okay i will read them – ealeon Jun 10 '13 at 15:22
  • @FDinoff I vim the file that i wanted to change and it still creates ^? when press backspace after manipulating .vimrc file – ealeon Jun 10 '13 at 15:25
  • @ealeon can you try running `:fixdel` before trying the backspace? (Note this isn't in vi. Are you actually running vi or vim) (Some systems symlink vi to vim) – FDinoff Jun 10 '13 at 15:31
  • @FDinoff yes it works after running :fixdel is that the only solution to this? do i have to run that everytime? – ealeon Jun 10 '13 at 15:48
  • @ealeon put `fixbuf` in your `.vimrc`. It will run everytime you open vim – FDinoff Jun 10 '13 at 15:59
  • 1
    @FDinoff thank you. it works now. and you meant fixdel :) – ealeon Jun 10 '13 at 16:05

1 Answers1

6

Try some of the following fixes. This is from the :fixdel help.

                            *:fix* *:fixdel*
:fix[del]       Set the value of 't_kD':
                't_kb' is     't_kD' becomes    
                  CTRL-?    CTRL-H
                not CTRL-?  CTRL-?

            (CTRL-? is 0177 octal, 0x7f hex) {not in Vi}

            If your delete key terminal code is wrong, but the
            code for backspace is alright, you can put this in
            your .vimrc:
                :fixdel
            This works no matter what the actual code for
            backspace is.

            If the backspace key terminal code is wrong you can
            use this:
                :if &term == "termname"
                :  set t_kb=^V<BS>
                :  fixdel
                :endif
            Where "^V" is CTRL-V and "<BS>" is the backspace key
            (don't type four characters!).  Replace "termname"
            with your terminal name.

            If your <Delete> key sends a strange key sequence (not
            CTRL-? or CTRL-H) you cannot use ":fixdel".  Then use:
                :if &term == "termname"
                :  set t_kD=^V<Delete>
                :endif
            Where "^V" is CTRL-V and "<Delete>" is the delete key
            (don't type eight characters!).  Replace "termname"
            with your terminal name.


                            *Linux-backspace*
            Note about Linux: By default the backspace key
            produces CTRL-?, which is wrong.  You can fix it by
            putting this line in your rc.local:
                echo "keycode 14 = BackSpace" | loadkeys


                            *NetBSD-backspace*
            Note about NetBSD: If your backspace doesn't produce
            the right code, try this:
                xmodmap -e "keycode 22 = BackSpace"
            If this works, add this in your .Xmodmap file:
                keysym 22 = BackSpace
            You need to restart for this to take effect.

If this works just add fixdel to your vimrc.

FDinoff
  • 30,689
  • 5
  • 75
  • 96