Announcement

Collapse
No announcement yet.

[SOLVED] Strange key bindings in shell / vi

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [SOLVED] Strange key bindings in shell / vi

    I Just did a clean install of Lucid (which is much better than the upgrade path -- less headaches).

    Weird thing in the shell -- in vi in insert mode my arrow keys input letters
    up arrow: A
    down arrow: B
    right arrow: C
    left arrow: D

    They move the cursor in Command Mode though.

    Where do I set this behaviour?


    Code:
    A
    A
    Here's what happens when I hit the up arrow twice in insert mode
    B
    and this is what happens when I hit the down arrow
    ~
    Dont pretend you havent noticed my cardboard box, Julia, because I know you have!

    #2
    Re: Strange key bindings in shell / vi

    Yup. You have to return to Command mode (hit Esc) before you can navigate the file using the arrow keys.
    Using Kubuntu Linux since March 23, 2007
    "It is a capital mistake to theorize before one has data." - Sherlock Holmes

    Comment


      #3
      Re: Strange key bindings in shell / vi

      Originally posted by Snowhog
      Yup. You have to return to Command mode (hit Esc) before you can navigate the file using the arrow keys.
      Hmmmm.... didn't used to be. Must be a setting somewhere.
      Dont pretend you havent noticed my cardboard box, Julia, because I know you have!

      Comment


        #4
        Re: Strange key bindings in shell / vi

        It was always that way with vi on my installs. On Lucid, I'm running Vim instead. It's a more user friendly enhancement of vi.
        Using Kubuntu Linux since March 23, 2007
        "It is a capital mistake to theorize before one has data." - Sherlock Holmes

        Comment


          #5
          Re: Strange key bindings in shell / vi

          Originally posted by Snowhog
          It was always that way with vi on my installs. On Lucid, I'm running Vim instead. It's a more user friendly enhancement of vi.
          This is a first for me. I have vi as a link to vim by default

          Code:
          which vi
          /usr/bin/vi
          
          ls -l /usr/bin/vi
          lrwxrwxrwx 1 root root 20 2010-05-15 18:59 /usr/bin/vi -> /etc/alternatives/vi
          
          vi --version
          VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Apr 16 2010 13:20:51)
          Dont pretend you havent noticed my cardboard box, Julia, because I know you have!

          Comment


            #6
            Re: Strange key bindings in shell / vi

            I've exactly the same output for each command you gave. I started 'vi' (which runs vim) and my normal arrow-keys behaved as you'd expect - up/down/left/right. No problems.
            Using Kubuntu Linux since March 23, 2007
            "It is a capital mistake to theorize before one has data." - Sherlock Holmes

            Comment


              #7
              Re: Strange key bindings in shell / vi

              Originally posted by Snowhog
              I've exactly the same output for each command you gave. I started 'vi' (which runs vim) and my normal arrow-keys behaved as you'd expect - up/down/left/right. No problems.
              Fixed it!
              make a new .vimrc in your home directory
              add the following line

              Code:
              set nocompatible
              Arrow keys work as arrow keys now in both modes.

              I also found this: http://vim.wikia.com/wiki/Fix_arrow_...n_remote_shell

              My .vimrc is

              Code:
              set nocompatible
              set autoindent
              set smartindent
              set showmatch
              set vb t_vb=
              set ruler
              set nohls
              set incsearch
              set virtualedit=all
              set softtabstop=4
              set shiftwidth=4
              set pastetoggle=<F11>
              I used to have set syntax on as well but I get an error now...I guess something else changed
              Dont pretend you havent noticed my cardboard box, Julia, because I know you have!

              Comment


                #8
                Re: Strange key bindings in shell / vi

                Originally posted by devnulljp
                Fixed it!
                make a new .vimrc in your home directory
                add the following line

                Code:
                set nocompatible
                Interesting. Here, I have no such file (.vimrc), although I do have:
                /etc/vim/vimrc
                /etc/vim/vimrc.tiny
                /usr/share/vim/vimrc
                /usr/share/vim/vimrc.tiny
                and as stated, my arrow keys behave as they are supposed to.
                Using Kubuntu Linux since March 23, 2007
                "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                Comment


                  #9
                  Re: Strange key bindings in shell / vi

                  Originally posted by Snowhog
                  Originally posted by devnulljp
                  Fixed it!
                  make a new .vimrc in your home directory
                  add the following line

                  Code:
                  set nocompatible
                  Interesting. Here, I have no such file (.vimrc), although I do have:
                  /etc/vim/vimrc
                  /etc/vim/vimrc.tiny
                  /usr/share/vim/vimrc
                  /usr/share/vim/vimrc.tiny
                  and as stated, my arrow keys behave as they are supposed to.
                  It's not there by default, so just make a new one and add that line to it.
                  Dont pretend you havent noticed my cardboard box, Julia, because I know you have!

                  Comment


                    #10
                    Re: Strange key bindings in shell / vi

                    Originally posted by devnulljp
                    It's not there by default, so just make a new one and add that line to it.
                    But I don't need it. My arrow keys work they way they are supposed to.
                    Using Kubuntu Linux since March 23, 2007
                    "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                    Comment


                      #11
                      Re: [SOLVED] Strange key bindings in shell / vi

                      Okay, here, in my Vim install, is where the 'compatible' issue is found:
                      paul@mybrainonlinux:~$ cat /etc/vim/vimrc
                      " All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
                      " /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
                      " you can find below. If you wish to change any of those settings, you should
                      " do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
                      " everytime an upgrade of the vim packages is performed. It is recommended to
                      " make changes after sourcing debian.vim since it alters the value of the
                      " 'compatible' option.

                      " This line should not be removed as it ensures that various options are
                      " properly set to work with the Vim-related packages available in Debian.
                      runtime! debian.vim

                      " Uncomment the next line to make Vim more Vi-compatible
                      " NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
                      " options, so any other options should be set AFTER setting 'compatible'.
                      "set compatible

                      But again, note that mine is still commented here, and my arrow keys work normally.
                      Using Kubuntu Linux since March 23, 2007
                      "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                      Comment


                        #12
                        Re: [SOLVED] Strange key bindings in shell / vi

                        One thing that can make a difference between compatible/nocompatible mode is whether you're actually running /usr/bin/vim.tiny (provided by 'vim-tiny' package) or /usr/bin/vim.basic (provided by 'vim' package).

                        vim.tiny defaults to "compatible" mode (via /etc/vim/vimrc.tiny) while vim.basic defaults to "nocompatible".

                        So you can check whether you have 'vim' package installed (It's possible to have both vim and vim-tiny installed), and check your /etc/alternatives/vi and /etc/alternatives/vim links. You can modify these with 'update-alternatives' command, example:
                        Code:
                        sudo update-alternatives --config vi

                        Comment


                          #13
                          Re: [SOLVED] Strange key bindings in shell / vi

                          paul@mybrainonlinux:~$ update-alternatives --list vi
                          /usr/bin/vim.tiny
                          Using Kubuntu Linux since March 23, 2007
                          "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                          Comment

                          Working...
                          X