Hitting arrow keys adds characters in vi editor











up vote
149
down vote

favorite
52












When I tried to use arrow keys in insert mode in vi editor the following characters are being inserted in the editor:




  • for I get B,

  • for I get A,

  • for I get D,

  • for I get C.


Please help me in resolve this problem.










share|improve this question




















  • 2




    I had a good laugh reading the title ;) I'm sure there is an XKCD for the spooky feeling that comes (to novice users) when arrow key prints letters.
    – vvy
    Jun 11 '15 at 14:31

















up vote
149
down vote

favorite
52












When I tried to use arrow keys in insert mode in vi editor the following characters are being inserted in the editor:




  • for I get B,

  • for I get A,

  • for I get D,

  • for I get C.


Please help me in resolve this problem.










share|improve this question




















  • 2




    I had a good laugh reading the title ;) I'm sure there is an XKCD for the spooky feeling that comes (to novice users) when arrow key prints letters.
    – vvy
    Jun 11 '15 at 14:31















up vote
149
down vote

favorite
52









up vote
149
down vote

favorite
52






52





When I tried to use arrow keys in insert mode in vi editor the following characters are being inserted in the editor:




  • for I get B,

  • for I get A,

  • for I get D,

  • for I get C.


Please help me in resolve this problem.










share|improve this question















When I tried to use arrow keys in insert mode in vi editor the following characters are being inserted in the editor:




  • for I get B,

  • for I get A,

  • for I get D,

  • for I get C.


Please help me in resolve this problem.







text-editor vi






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 5 '13 at 7:54









Andrea Corbellini

11.9k24463




11.9k24463










asked Oct 5 '13 at 5:04









bvb

846274




846274








  • 2




    I had a good laugh reading the title ;) I'm sure there is an XKCD for the spooky feeling that comes (to novice users) when arrow key prints letters.
    – vvy
    Jun 11 '15 at 14:31
















  • 2




    I had a good laugh reading the title ;) I'm sure there is an XKCD for the spooky feeling that comes (to novice users) when arrow key prints letters.
    – vvy
    Jun 11 '15 at 14:31










2




2




I had a good laugh reading the title ;) I'm sure there is an XKCD for the spooky feeling that comes (to novice users) when arrow key prints letters.
– vvy
Jun 11 '15 at 14:31






I had a good laugh reading the title ;) I'm sure there is an XKCD for the spooky feeling that comes (to novice users) when arrow key prints letters.
– vvy
Jun 11 '15 at 14:31












12 Answers
12






active

oldest

votes

















up vote
191
down vote













If you don't already have a .vimrc file in your home directory, create one using this:



vim ~/.vimrc


Add this line to the top of the file:



set nocompatible


Save the file and this should fix the problem for you. :)






share|improve this answer























  • I had to create a .exrc file for vi, but set nocompatible worked great.
    – tgun926
    Jan 30 '15 at 23:38






  • 17




    There is a trick if you use vi instead of vim, you have to do the same configuration but in the ~/.exrc file.
    – tzi
    Jul 22 '15 at 14:47






  • 13




    Worked. But why this fix is required? Why by default it does not handle arrows?
    – Mohit
    Jan 23 '16 at 12:41






  • 5




    By default, vi/vim is programmed to replace arrow keys with the keys h, j, k, l. This is done so you dont have to move from the major key area of the keyboard.
    – Gaurav Manchanda
    Jan 24 '16 at 19:34






  • 7




    next problem is backspace, solution: askubuntu.com/questions/296385/…
    – daVe
    Sep 27 '16 at 13:15


















up vote
56
down vote













Install vim -> This will fix the problem.



sudo apt-get install vim


There are many good vim/vi tutorials on youtube, or the web generally.
For your problem, see here



Then continue to open files as usual:



vi desired-file





share|improve this answer























  • worked for me -- though not sure why this is different from the vim I was launching previously
    – Amos Folarin
    Jan 9 '17 at 13:49






  • 4




    This should be the accepted answer (but seems like no one is accepting). it's the simplest/cleanest way to get vim fully 'modernized' to a computer console (instead of tty/ANSI era terminals.
    – Lockszmith
    Aug 1 '17 at 1:15










  • yes I agree with you Lockzsmith, this should'v been the accepted answer
    – niccolo m.
    Sep 28 '17 at 23:12










  • This worked for me. I'm surprised that raspian comes with the version of vi/vim that it does... although all the tutorials for it tell you to use nano, which it's hard to argue that vim is really better than it. Probably the only reason I use vim rather than nano is because vim is always on every machine and it seems like a 50/50 chance whether nano is.
    – ArtOfWarfare
    Jan 20 at 17:15


















up vote
26
down vote













With vi, when clicking on i you activate the command to Insert text.

This command allows you to insert text in your file.

And right, when clicking :




  • on it will insert a "A",


  • on it will insert a "B",


  • ...



Till you deactivate this command.

To deactivate a command in vi : just click on Esc

And then you will get back normal use of your arrow keys:





  • to go up,


  • to go down,

  • ...




FYI, here are some vi commands:
From this source.



:xReturn quit vi, writing out modified file to file named in original invocation
:wqReturn quit vi, writing out modified file to file named in original invocation
:qReturn quit (or exit) vi
:q!Return quit vi even though latest changes have not been saved for this vi call



move cursor down one line
move cursor up one line
move cursor left one character
move cursor right one character



u undo whatever you just did; a simple toggle
. redo whatever you just did



i insert text before cursor, until Esc hit
I insert text at beginning of current line, until Esc hit
a append text after cursor, until Esc hit
A append text to end of current line, until Esc hit
o open and put text in a new line below current line, until Esc hit
O open and put text in a new line above current line, until Esc hit



r replace single character under cursor (no Esc needed)
cw change the current word with new text,starting with the character under cursor, until Esc hit
x delete single character under cursor
Nx delete N characters, starting with character under cursor
dw delete the single word beginning with character under cursor
C change (replace) the characters in the current line, until Esc hit
D delete the remainder of the line, starting with current cursor position



dd delete entire current line
Ndd delete N lines, beginning with the current line; e.g., 5dd deletes 5 lines
yy copy (yank, cut) the current line into the buffer
Nyy copy (yank, cut) the next N lines, including the current line, into the buffer
p paste the line(s) in the buffer into the text after the current line



0 (zero) move cursor to start of current line (the one with the cursor)
$ move cursor to end of current line
w move cursor to beginning of next word
b move cursor back to beginning of preceding word
:0Return or 1G move cursor to first line in file
:nReturn or nG move cursor to line n
:$Return or G move cursor to last line in file



/string search forward for occurrence of string in text
?string search backward for occurrence of string in text
n move to next occurrence of search string
N move to next occurrence of search string in opposite direction






share|improve this answer



















  • 23




    Arrow key down inserting "B" is not an expected behavior. Arrow keys should be moving cursors up and down/ left and right regardless of the insert mode.
    – James Wong
    Sep 6 '15 at 7:49






  • 2




    @JamesWong Actually, it is expected behavior, as that is how Vi was originally programmed. VIM, (unofficially) the successor to Vi, is in Vi-compatible mode by default, which includes this behavior for the arrow keys. So the word "should" here is merely subjective, as VIM is actually doing what it was purposefully programmed to do.
    – villapx
    Dec 1 '16 at 15:30










  • @villapx - No, it isn't expected behavior. Expected behavior is defined by what your typical user expects. The typical person using vi/vim is using it because that's what's installed on a server that they need to quickly configure and they won't be doing enough to bother with installing something else. Few actually choose to use vim when given an option, and fewer actually know all these features or quirks. The typical user expects arrows to move the cursor - that is the expected behavior. Anything else is unexpected behavior, and should be written up as a bug for how unexpected it is.
    – ArtOfWarfare
    Jan 20 at 17:13










  • @ArtOfWarfare You're free to define "expected" however you choose. I'm defining it as what's expected by the author of the code, as they were quite clear in the VIM manual how this is supposed to behave...from :help compatible: "By default this option is on and the Vi defaults are used for the options. This default was chosen for those people who want to use Vim just like Vi, and don't even (want to) know about the 'compatible' option."
    – villapx
    Jan 22 at 20:43










  • @ArtOfWarfare Basically, the VIM author clearly had a specific audience in mind when writing this portion of the code, and just because that audience is different from what your audience would be, doesn't mean it's a bug. You can file it as a bug if you wish, but be prepared to be berated by VIM fundamentalists (and really anyone who respects the 'manual', a la RTFM aficionados).
    – villapx
    Jan 22 at 20:45


















up vote
16
down vote













To disable printing letters on pressing arrows in edit mode you can do following



vi $HOME/.exrc 


(create file if it does not exist) and then add line set nocompatible to it and save.






share|improve this answer

















  • 2




    This should be the accepted answer. Thank you!
    – eis
    Nov 18 '15 at 10:10










  • I put that in .vimrc. Why do you put it in .exrc?
    – pauljohn32
    Mar 19 '17 at 2:54










  • Vim sources both - see output of :version for load order (also :h .exrc or :h init). I suppose someone might want a setting to apply in both vi and vim, or could be sheer force of habit.
    – William Robertson
    May 27 '17 at 8:46


















up vote
11
down vote













There are three modes in vi editor namely:




  • command mode

  • input mode

  • default mode.


When youu open a file, you are in default mode. Now if you want to go to a specific position in your text, just use arrow keys or use h, j, k, l keys. Note that this would work only when you have not pressed i (or any other input mode entering command like a, A, I).



The reason for 'B' may be because the arrow keys in input mode don't function as arrow keys, so just press Esc to go into default mode any time. When to shift to input mode press i or a, and to navigate just press i key and use arrow keys or h, j, k, l.






share|improve this answer






























    up vote
    6
    down vote













    I had the exact same Problem but not only on my local machine but also on connections via putty on a sles machine in a Win7 VM over a citrix receiver. Both the local host and the remote hosts show after a reinstall of Ubuntu had the exact same problem.



    After finding out that



    $ localectl list-keymaps 
    Couldn't find any console keymaps.


    Causes this strange VI behaviour I installed the package console-data which solves the issue!



    sudo apt-get install console-data





    share|improve this answer






























      up vote
      3
      down vote













      All the explanations given are a bit bizarre. I have vi but not vim installed.



      Checking alternatives: /etc/alternatives/vi → /usr/bin/vim.tiny



      So vi is vim.tiny, and it uses /etc/vim/vimrc.tiny.



      And in vimrc.tiny you find the following line:



      set compatible


      Which is almost the only thing in this file. Note that in /etc/vim/vimrc it is using nocompatible.



      So either install vim, or change the vimrc.tiny file, or create your own ~/.vimrc which should contain the line:



      set nocompatible





      share|improve this answer



















      • 1




        I'm not sure what's so bizarre. You end up suggesting 1. install Vim - askubuntu.com/a/220072/158442, 2. creating ~/.vimrc and setting nocompatible: askubuntu.com/a/353944/158442, or 3. editing a system file. Only the suggestion to edit /etc/vim/vimrc.tiny is new, and yet you call answers bizarre while suggesting the same thing as them.
        – muru
        Jan 11 '17 at 2:27




















      up vote
      2
      down vote













      Note:



      There is good information in the other posts but none of the posts tried to explain why this behavior happened. Many people are bound to stumble on this in the future. Also, could you mark this question as resolved since any of the previous posts likely assisted you?





      Here is an explanation:



      Vi is an editor that's been around a long while, with roots back to the Unix systems. It's a good tool but it has been iterated on and now there is better. Vim was written later and is that iteration. People commonly refer to vi as 'vim-minimal' and to vim is an "improved" version of vi. You can think of it like this: vi is the core and vim expands on it.



      Likely how you discovered the behavior:



      In order for you to have discovered this problem, you pressed "i" to enter into insert mode and then used your arrow keys to navigate the correct line and edit point. This is what caused your unexpected char issue.



      Solution 1 or 2



      1) vi someFile While using vi, first move to the edit point, then enter into insert mode.



      2) vim someFile Simply use vim from the start.



      I cannot stress enough to read the manual (man pages) or to use -h for help. Once you adjust to the patterns in the shell, man pages become your best friend. Example: man vi or man vim





      Validate that Vim is installed.



      Open a console window and execute:



      dpkg --list | grep vim



      If you get something similar to this, then you can just start using vim.



      ~ $ dpkg --list | grep vim
      ii vim 2:7.4.052-1ubuntu3 amd64 Vi IMproved - enhanced vi editor
      ii vim-common 2:7.4.052-1ubuntu3 amd64 Vi IMproved - Common files
      ii vim-runtime 2:7.4.052-1ubuntu3 all Vi IMproved - Runtime files
      ii vim-tiny 2:7.4.052-1ubuntu3 amd64 Vi IMproved - enhanced vi editor - compact version


      If the command prompt returns with nothing, then vim is is not installed. Use the below examples to update your repositories and then install vim.



      sudo apt-get update
      sudo apt-get install vim


      On the off chance that you use vi or vim only when searching on the internet how to fix something and you happen to forget to type vim, there is one way that you can fix it for the future. I caution you to pay attention. You can use an alias to overwrite vi with a reference to vim so that no matter what you type in the infrequent future, you get vim without that "oops!" moment. You can always delete an alias later.



      Type vim .bashrc. Move down to the empty line with only a ~ (or to any other line that starts with alias (so they're grouped together) and then press the i key to enter -insert- mode. On its own separate line, enter the following:



      alias vi='vim'


      Press Esc and then type :wq. Now you need to reload the file. Type source .bashrc Any other shell that opens after you have made these edits will automatically load the .bashrc file.






      share|improve this answer




























        up vote
        1
        down vote













        The traditional vi editor doesn't recognize the arrow keys (...afair). There are two solutions:




        1. use vim instead of vi

        2. use h, j, k and l to navigate (you can't navigate while editing on the traditional vi btw.)






        share|improve this answer





















        • This isn't true. Look for terminfo/termcap and libcurses based apps. I use vi since 1990 in Xenix, SCO Unix, AIX, old hpux, and others, and pure-vi from 80s already have support to terminfo/termcap mappings.
          – Luciano
          Dec 14 '15 at 11:42










        • @james-wong well then I should rephrase my answer. To "pure vi under Ubuntu doesn't..."
          – MadMike
          Dec 14 '15 at 14:52










        • ... and this was meant as a comment to @luciano
          – MadMike
          Dec 14 '15 at 14:53


















        up vote
        1
        down vote













        This can also be due to the TERM variable; set it for example like this:



         export TERM=xterm





        share|improve this answer























        • This solved the problem for me where the other answers didn't. Thanks!
          – greg
          Jul 20 at 10:33


















        up vote
        1
        down vote













        On some systems, the nocompatible option is not available, or it may not fix the problem if a plugin breaks arrow key functionality. Here's a workaround...



        Edit the .exrc file to include the following lines:



        map! ^[OA ^[ka
        map! ^[OB ^[ja
        map! ^[OC ^[la
        map! ^[OD ^[ha


        Or, if the problem only exists in normal mode, you can change to nmap and skip the following a, as follows:



        nmap! ^[OA ^[k


        and so on.



        Here's the key combinations needed to produce them (showing first one only):



        map! <CTRL-V><Up-Arrow> <CTRL-V><ESC>ka


        This escapes edit mode, moves in the wanted direction, and reenters edit mode. This is needed to overcome Vi reading the escape sequence as a sequence of literal <ESC><O><A>, etc.



        Source: https://hea-www.harvard.edu/~fine/Tech/vi.html






        share|improve this answer






























          up vote
          0
          down vote













          For VI create or edit the file "~/.exrc" or VIM create or edit the file "~/.vimrc" set or add in the line.



          set nocompatible


          At the time of this writing there are commends on the second most voted item that are wondering why their entry was not accepted. The reason is there are hosts that do not allow installing other editors. Even then vim sometimes has the same effects, so there is a bunch of usable info from the top two entries. I cannot comment however hopefully this clears up reasons why neither one is 100% correct 100% of the time.






          share|improve this answer





















            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f353911%2fhitting-arrow-keys-adds-characters-in-vi-editor%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            12 Answers
            12






            active

            oldest

            votes








            12 Answers
            12






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            191
            down vote













            If you don't already have a .vimrc file in your home directory, create one using this:



            vim ~/.vimrc


            Add this line to the top of the file:



            set nocompatible


            Save the file and this should fix the problem for you. :)






            share|improve this answer























            • I had to create a .exrc file for vi, but set nocompatible worked great.
              – tgun926
              Jan 30 '15 at 23:38






            • 17




              There is a trick if you use vi instead of vim, you have to do the same configuration but in the ~/.exrc file.
              – tzi
              Jul 22 '15 at 14:47






            • 13




              Worked. But why this fix is required? Why by default it does not handle arrows?
              – Mohit
              Jan 23 '16 at 12:41






            • 5




              By default, vi/vim is programmed to replace arrow keys with the keys h, j, k, l. This is done so you dont have to move from the major key area of the keyboard.
              – Gaurav Manchanda
              Jan 24 '16 at 19:34






            • 7




              next problem is backspace, solution: askubuntu.com/questions/296385/…
              – daVe
              Sep 27 '16 at 13:15















            up vote
            191
            down vote













            If you don't already have a .vimrc file in your home directory, create one using this:



            vim ~/.vimrc


            Add this line to the top of the file:



            set nocompatible


            Save the file and this should fix the problem for you. :)






            share|improve this answer























            • I had to create a .exrc file for vi, but set nocompatible worked great.
              – tgun926
              Jan 30 '15 at 23:38






            • 17




              There is a trick if you use vi instead of vim, you have to do the same configuration but in the ~/.exrc file.
              – tzi
              Jul 22 '15 at 14:47






            • 13




              Worked. But why this fix is required? Why by default it does not handle arrows?
              – Mohit
              Jan 23 '16 at 12:41






            • 5




              By default, vi/vim is programmed to replace arrow keys with the keys h, j, k, l. This is done so you dont have to move from the major key area of the keyboard.
              – Gaurav Manchanda
              Jan 24 '16 at 19:34






            • 7




              next problem is backspace, solution: askubuntu.com/questions/296385/…
              – daVe
              Sep 27 '16 at 13:15













            up vote
            191
            down vote










            up vote
            191
            down vote









            If you don't already have a .vimrc file in your home directory, create one using this:



            vim ~/.vimrc


            Add this line to the top of the file:



            set nocompatible


            Save the file and this should fix the problem for you. :)






            share|improve this answer














            If you don't already have a .vimrc file in your home directory, create one using this:



            vim ~/.vimrc


            Add this line to the top of the file:



            set nocompatible


            Save the file and this should fix the problem for you. :)







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 19 '16 at 12:05









            muru

            135k19286486




            135k19286486










            answered Oct 5 '13 at 7:23









            Gaurav Manchanda

            2,011184




            2,011184












            • I had to create a .exrc file for vi, but set nocompatible worked great.
              – tgun926
              Jan 30 '15 at 23:38






            • 17




              There is a trick if you use vi instead of vim, you have to do the same configuration but in the ~/.exrc file.
              – tzi
              Jul 22 '15 at 14:47






            • 13




              Worked. But why this fix is required? Why by default it does not handle arrows?
              – Mohit
              Jan 23 '16 at 12:41






            • 5




              By default, vi/vim is programmed to replace arrow keys with the keys h, j, k, l. This is done so you dont have to move from the major key area of the keyboard.
              – Gaurav Manchanda
              Jan 24 '16 at 19:34






            • 7




              next problem is backspace, solution: askubuntu.com/questions/296385/…
              – daVe
              Sep 27 '16 at 13:15


















            • I had to create a .exrc file for vi, but set nocompatible worked great.
              – tgun926
              Jan 30 '15 at 23:38






            • 17




              There is a trick if you use vi instead of vim, you have to do the same configuration but in the ~/.exrc file.
              – tzi
              Jul 22 '15 at 14:47






            • 13




              Worked. But why this fix is required? Why by default it does not handle arrows?
              – Mohit
              Jan 23 '16 at 12:41






            • 5




              By default, vi/vim is programmed to replace arrow keys with the keys h, j, k, l. This is done so you dont have to move from the major key area of the keyboard.
              – Gaurav Manchanda
              Jan 24 '16 at 19:34






            • 7




              next problem is backspace, solution: askubuntu.com/questions/296385/…
              – daVe
              Sep 27 '16 at 13:15
















            I had to create a .exrc file for vi, but set nocompatible worked great.
            – tgun926
            Jan 30 '15 at 23:38




            I had to create a .exrc file for vi, but set nocompatible worked great.
            – tgun926
            Jan 30 '15 at 23:38




            17




            17




            There is a trick if you use vi instead of vim, you have to do the same configuration but in the ~/.exrc file.
            – tzi
            Jul 22 '15 at 14:47




            There is a trick if you use vi instead of vim, you have to do the same configuration but in the ~/.exrc file.
            – tzi
            Jul 22 '15 at 14:47




            13




            13




            Worked. But why this fix is required? Why by default it does not handle arrows?
            – Mohit
            Jan 23 '16 at 12:41




            Worked. But why this fix is required? Why by default it does not handle arrows?
            – Mohit
            Jan 23 '16 at 12:41




            5




            5




            By default, vi/vim is programmed to replace arrow keys with the keys h, j, k, l. This is done so you dont have to move from the major key area of the keyboard.
            – Gaurav Manchanda
            Jan 24 '16 at 19:34




            By default, vi/vim is programmed to replace arrow keys with the keys h, j, k, l. This is done so you dont have to move from the major key area of the keyboard.
            – Gaurav Manchanda
            Jan 24 '16 at 19:34




            7




            7




            next problem is backspace, solution: askubuntu.com/questions/296385/…
            – daVe
            Sep 27 '16 at 13:15




            next problem is backspace, solution: askubuntu.com/questions/296385/…
            – daVe
            Sep 27 '16 at 13:15












            up vote
            56
            down vote













            Install vim -> This will fix the problem.



            sudo apt-get install vim


            There are many good vim/vi tutorials on youtube, or the web generally.
            For your problem, see here



            Then continue to open files as usual:



            vi desired-file





            share|improve this answer























            • worked for me -- though not sure why this is different from the vim I was launching previously
              – Amos Folarin
              Jan 9 '17 at 13:49






            • 4




              This should be the accepted answer (but seems like no one is accepting). it's the simplest/cleanest way to get vim fully 'modernized' to a computer console (instead of tty/ANSI era terminals.
              – Lockszmith
              Aug 1 '17 at 1:15










            • yes I agree with you Lockzsmith, this should'v been the accepted answer
              – niccolo m.
              Sep 28 '17 at 23:12










            • This worked for me. I'm surprised that raspian comes with the version of vi/vim that it does... although all the tutorials for it tell you to use nano, which it's hard to argue that vim is really better than it. Probably the only reason I use vim rather than nano is because vim is always on every machine and it seems like a 50/50 chance whether nano is.
              – ArtOfWarfare
              Jan 20 at 17:15















            up vote
            56
            down vote













            Install vim -> This will fix the problem.



            sudo apt-get install vim


            There are many good vim/vi tutorials on youtube, or the web generally.
            For your problem, see here



            Then continue to open files as usual:



            vi desired-file





            share|improve this answer























            • worked for me -- though not sure why this is different from the vim I was launching previously
              – Amos Folarin
              Jan 9 '17 at 13:49






            • 4




              This should be the accepted answer (but seems like no one is accepting). it's the simplest/cleanest way to get vim fully 'modernized' to a computer console (instead of tty/ANSI era terminals.
              – Lockszmith
              Aug 1 '17 at 1:15










            • yes I agree with you Lockzsmith, this should'v been the accepted answer
              – niccolo m.
              Sep 28 '17 at 23:12










            • This worked for me. I'm surprised that raspian comes with the version of vi/vim that it does... although all the tutorials for it tell you to use nano, which it's hard to argue that vim is really better than it. Probably the only reason I use vim rather than nano is because vim is always on every machine and it seems like a 50/50 chance whether nano is.
              – ArtOfWarfare
              Jan 20 at 17:15













            up vote
            56
            down vote










            up vote
            56
            down vote









            Install vim -> This will fix the problem.



            sudo apt-get install vim


            There are many good vim/vi tutorials on youtube, or the web generally.
            For your problem, see here



            Then continue to open files as usual:



            vi desired-file





            share|improve this answer














            Install vim -> This will fix the problem.



            sudo apt-get install vim


            There are many good vim/vi tutorials on youtube, or the web generally.
            For your problem, see here



            Then continue to open files as usual:



            vi desired-file






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Aug 11 '17 at 4:36









            αғsнιη

            24k2294155




            24k2294155










            answered Nov 21 '12 at 8:03









            sthysel

            71846




            71846












            • worked for me -- though not sure why this is different from the vim I was launching previously
              – Amos Folarin
              Jan 9 '17 at 13:49






            • 4




              This should be the accepted answer (but seems like no one is accepting). it's the simplest/cleanest way to get vim fully 'modernized' to a computer console (instead of tty/ANSI era terminals.
              – Lockszmith
              Aug 1 '17 at 1:15










            • yes I agree with you Lockzsmith, this should'v been the accepted answer
              – niccolo m.
              Sep 28 '17 at 23:12










            • This worked for me. I'm surprised that raspian comes with the version of vi/vim that it does... although all the tutorials for it tell you to use nano, which it's hard to argue that vim is really better than it. Probably the only reason I use vim rather than nano is because vim is always on every machine and it seems like a 50/50 chance whether nano is.
              – ArtOfWarfare
              Jan 20 at 17:15


















            • worked for me -- though not sure why this is different from the vim I was launching previously
              – Amos Folarin
              Jan 9 '17 at 13:49






            • 4




              This should be the accepted answer (but seems like no one is accepting). it's the simplest/cleanest way to get vim fully 'modernized' to a computer console (instead of tty/ANSI era terminals.
              – Lockszmith
              Aug 1 '17 at 1:15










            • yes I agree with you Lockzsmith, this should'v been the accepted answer
              – niccolo m.
              Sep 28 '17 at 23:12










            • This worked for me. I'm surprised that raspian comes with the version of vi/vim that it does... although all the tutorials for it tell you to use nano, which it's hard to argue that vim is really better than it. Probably the only reason I use vim rather than nano is because vim is always on every machine and it seems like a 50/50 chance whether nano is.
              – ArtOfWarfare
              Jan 20 at 17:15
















            worked for me -- though not sure why this is different from the vim I was launching previously
            – Amos Folarin
            Jan 9 '17 at 13:49




            worked for me -- though not sure why this is different from the vim I was launching previously
            – Amos Folarin
            Jan 9 '17 at 13:49




            4




            4




            This should be the accepted answer (but seems like no one is accepting). it's the simplest/cleanest way to get vim fully 'modernized' to a computer console (instead of tty/ANSI era terminals.
            – Lockszmith
            Aug 1 '17 at 1:15




            This should be the accepted answer (but seems like no one is accepting). it's the simplest/cleanest way to get vim fully 'modernized' to a computer console (instead of tty/ANSI era terminals.
            – Lockszmith
            Aug 1 '17 at 1:15












            yes I agree with you Lockzsmith, this should'v been the accepted answer
            – niccolo m.
            Sep 28 '17 at 23:12




            yes I agree with you Lockzsmith, this should'v been the accepted answer
            – niccolo m.
            Sep 28 '17 at 23:12












            This worked for me. I'm surprised that raspian comes with the version of vi/vim that it does... although all the tutorials for it tell you to use nano, which it's hard to argue that vim is really better than it. Probably the only reason I use vim rather than nano is because vim is always on every machine and it seems like a 50/50 chance whether nano is.
            – ArtOfWarfare
            Jan 20 at 17:15




            This worked for me. I'm surprised that raspian comes with the version of vi/vim that it does... although all the tutorials for it tell you to use nano, which it's hard to argue that vim is really better than it. Probably the only reason I use vim rather than nano is because vim is always on every machine and it seems like a 50/50 chance whether nano is.
            – ArtOfWarfare
            Jan 20 at 17:15










            up vote
            26
            down vote













            With vi, when clicking on i you activate the command to Insert text.

            This command allows you to insert text in your file.

            And right, when clicking :




            • on it will insert a "A",


            • on it will insert a "B",


            • ...



            Till you deactivate this command.

            To deactivate a command in vi : just click on Esc

            And then you will get back normal use of your arrow keys:





            • to go up,


            • to go down,

            • ...




            FYI, here are some vi commands:
            From this source.



            :xReturn quit vi, writing out modified file to file named in original invocation
            :wqReturn quit vi, writing out modified file to file named in original invocation
            :qReturn quit (or exit) vi
            :q!Return quit vi even though latest changes have not been saved for this vi call



            move cursor down one line
            move cursor up one line
            move cursor left one character
            move cursor right one character



            u undo whatever you just did; a simple toggle
            . redo whatever you just did



            i insert text before cursor, until Esc hit
            I insert text at beginning of current line, until Esc hit
            a append text after cursor, until Esc hit
            A append text to end of current line, until Esc hit
            o open and put text in a new line below current line, until Esc hit
            O open and put text in a new line above current line, until Esc hit



            r replace single character under cursor (no Esc needed)
            cw change the current word with new text,starting with the character under cursor, until Esc hit
            x delete single character under cursor
            Nx delete N characters, starting with character under cursor
            dw delete the single word beginning with character under cursor
            C change (replace) the characters in the current line, until Esc hit
            D delete the remainder of the line, starting with current cursor position



            dd delete entire current line
            Ndd delete N lines, beginning with the current line; e.g., 5dd deletes 5 lines
            yy copy (yank, cut) the current line into the buffer
            Nyy copy (yank, cut) the next N lines, including the current line, into the buffer
            p paste the line(s) in the buffer into the text after the current line



            0 (zero) move cursor to start of current line (the one with the cursor)
            $ move cursor to end of current line
            w move cursor to beginning of next word
            b move cursor back to beginning of preceding word
            :0Return or 1G move cursor to first line in file
            :nReturn or nG move cursor to line n
            :$Return or G move cursor to last line in file



            /string search forward for occurrence of string in text
            ?string search backward for occurrence of string in text
            n move to next occurrence of search string
            N move to next occurrence of search string in opposite direction






            share|improve this answer



















            • 23




              Arrow key down inserting "B" is not an expected behavior. Arrow keys should be moving cursors up and down/ left and right regardless of the insert mode.
              – James Wong
              Sep 6 '15 at 7:49






            • 2




              @JamesWong Actually, it is expected behavior, as that is how Vi was originally programmed. VIM, (unofficially) the successor to Vi, is in Vi-compatible mode by default, which includes this behavior for the arrow keys. So the word "should" here is merely subjective, as VIM is actually doing what it was purposefully programmed to do.
              – villapx
              Dec 1 '16 at 15:30










            • @villapx - No, it isn't expected behavior. Expected behavior is defined by what your typical user expects. The typical person using vi/vim is using it because that's what's installed on a server that they need to quickly configure and they won't be doing enough to bother with installing something else. Few actually choose to use vim when given an option, and fewer actually know all these features or quirks. The typical user expects arrows to move the cursor - that is the expected behavior. Anything else is unexpected behavior, and should be written up as a bug for how unexpected it is.
              – ArtOfWarfare
              Jan 20 at 17:13










            • @ArtOfWarfare You're free to define "expected" however you choose. I'm defining it as what's expected by the author of the code, as they were quite clear in the VIM manual how this is supposed to behave...from :help compatible: "By default this option is on and the Vi defaults are used for the options. This default was chosen for those people who want to use Vim just like Vi, and don't even (want to) know about the 'compatible' option."
              – villapx
              Jan 22 at 20:43










            • @ArtOfWarfare Basically, the VIM author clearly had a specific audience in mind when writing this portion of the code, and just because that audience is different from what your audience would be, doesn't mean it's a bug. You can file it as a bug if you wish, but be prepared to be berated by VIM fundamentalists (and really anyone who respects the 'manual', a la RTFM aficionados).
              – villapx
              Jan 22 at 20:45















            up vote
            26
            down vote













            With vi, when clicking on i you activate the command to Insert text.

            This command allows you to insert text in your file.

            And right, when clicking :




            • on it will insert a "A",


            • on it will insert a "B",


            • ...



            Till you deactivate this command.

            To deactivate a command in vi : just click on Esc

            And then you will get back normal use of your arrow keys:





            • to go up,


            • to go down,

            • ...




            FYI, here are some vi commands:
            From this source.



            :xReturn quit vi, writing out modified file to file named in original invocation
            :wqReturn quit vi, writing out modified file to file named in original invocation
            :qReturn quit (or exit) vi
            :q!Return quit vi even though latest changes have not been saved for this vi call



            move cursor down one line
            move cursor up one line
            move cursor left one character
            move cursor right one character



            u undo whatever you just did; a simple toggle
            . redo whatever you just did



            i insert text before cursor, until Esc hit
            I insert text at beginning of current line, until Esc hit
            a append text after cursor, until Esc hit
            A append text to end of current line, until Esc hit
            o open and put text in a new line below current line, until Esc hit
            O open and put text in a new line above current line, until Esc hit



            r replace single character under cursor (no Esc needed)
            cw change the current word with new text,starting with the character under cursor, until Esc hit
            x delete single character under cursor
            Nx delete N characters, starting with character under cursor
            dw delete the single word beginning with character under cursor
            C change (replace) the characters in the current line, until Esc hit
            D delete the remainder of the line, starting with current cursor position



            dd delete entire current line
            Ndd delete N lines, beginning with the current line; e.g., 5dd deletes 5 lines
            yy copy (yank, cut) the current line into the buffer
            Nyy copy (yank, cut) the next N lines, including the current line, into the buffer
            p paste the line(s) in the buffer into the text after the current line



            0 (zero) move cursor to start of current line (the one with the cursor)
            $ move cursor to end of current line
            w move cursor to beginning of next word
            b move cursor back to beginning of preceding word
            :0Return or 1G move cursor to first line in file
            :nReturn or nG move cursor to line n
            :$Return or G move cursor to last line in file



            /string search forward for occurrence of string in text
            ?string search backward for occurrence of string in text
            n move to next occurrence of search string
            N move to next occurrence of search string in opposite direction






            share|improve this answer



















            • 23




              Arrow key down inserting "B" is not an expected behavior. Arrow keys should be moving cursors up and down/ left and right regardless of the insert mode.
              – James Wong
              Sep 6 '15 at 7:49






            • 2




              @JamesWong Actually, it is expected behavior, as that is how Vi was originally programmed. VIM, (unofficially) the successor to Vi, is in Vi-compatible mode by default, which includes this behavior for the arrow keys. So the word "should" here is merely subjective, as VIM is actually doing what it was purposefully programmed to do.
              – villapx
              Dec 1 '16 at 15:30










            • @villapx - No, it isn't expected behavior. Expected behavior is defined by what your typical user expects. The typical person using vi/vim is using it because that's what's installed on a server that they need to quickly configure and they won't be doing enough to bother with installing something else. Few actually choose to use vim when given an option, and fewer actually know all these features or quirks. The typical user expects arrows to move the cursor - that is the expected behavior. Anything else is unexpected behavior, and should be written up as a bug for how unexpected it is.
              – ArtOfWarfare
              Jan 20 at 17:13










            • @ArtOfWarfare You're free to define "expected" however you choose. I'm defining it as what's expected by the author of the code, as they were quite clear in the VIM manual how this is supposed to behave...from :help compatible: "By default this option is on and the Vi defaults are used for the options. This default was chosen for those people who want to use Vim just like Vi, and don't even (want to) know about the 'compatible' option."
              – villapx
              Jan 22 at 20:43










            • @ArtOfWarfare Basically, the VIM author clearly had a specific audience in mind when writing this portion of the code, and just because that audience is different from what your audience would be, doesn't mean it's a bug. You can file it as a bug if you wish, but be prepared to be berated by VIM fundamentalists (and really anyone who respects the 'manual', a la RTFM aficionados).
              – villapx
              Jan 22 at 20:45













            up vote
            26
            down vote










            up vote
            26
            down vote









            With vi, when clicking on i you activate the command to Insert text.

            This command allows you to insert text in your file.

            And right, when clicking :




            • on it will insert a "A",


            • on it will insert a "B",


            • ...



            Till you deactivate this command.

            To deactivate a command in vi : just click on Esc

            And then you will get back normal use of your arrow keys:





            • to go up,


            • to go down,

            • ...




            FYI, here are some vi commands:
            From this source.



            :xReturn quit vi, writing out modified file to file named in original invocation
            :wqReturn quit vi, writing out modified file to file named in original invocation
            :qReturn quit (or exit) vi
            :q!Return quit vi even though latest changes have not been saved for this vi call



            move cursor down one line
            move cursor up one line
            move cursor left one character
            move cursor right one character



            u undo whatever you just did; a simple toggle
            . redo whatever you just did



            i insert text before cursor, until Esc hit
            I insert text at beginning of current line, until Esc hit
            a append text after cursor, until Esc hit
            A append text to end of current line, until Esc hit
            o open and put text in a new line below current line, until Esc hit
            O open and put text in a new line above current line, until Esc hit



            r replace single character under cursor (no Esc needed)
            cw change the current word with new text,starting with the character under cursor, until Esc hit
            x delete single character under cursor
            Nx delete N characters, starting with character under cursor
            dw delete the single word beginning with character under cursor
            C change (replace) the characters in the current line, until Esc hit
            D delete the remainder of the line, starting with current cursor position



            dd delete entire current line
            Ndd delete N lines, beginning with the current line; e.g., 5dd deletes 5 lines
            yy copy (yank, cut) the current line into the buffer
            Nyy copy (yank, cut) the next N lines, including the current line, into the buffer
            p paste the line(s) in the buffer into the text after the current line



            0 (zero) move cursor to start of current line (the one with the cursor)
            $ move cursor to end of current line
            w move cursor to beginning of next word
            b move cursor back to beginning of preceding word
            :0Return or 1G move cursor to first line in file
            :nReturn or nG move cursor to line n
            :$Return or G move cursor to last line in file



            /string search forward for occurrence of string in text
            ?string search backward for occurrence of string in text
            n move to next occurrence of search string
            N move to next occurrence of search string in opposite direction






            share|improve this answer














            With vi, when clicking on i you activate the command to Insert text.

            This command allows you to insert text in your file.

            And right, when clicking :




            • on it will insert a "A",


            • on it will insert a "B",


            • ...



            Till you deactivate this command.

            To deactivate a command in vi : just click on Esc

            And then you will get back normal use of your arrow keys:





            • to go up,


            • to go down,

            • ...




            FYI, here are some vi commands:
            From this source.



            :xReturn quit vi, writing out modified file to file named in original invocation
            :wqReturn quit vi, writing out modified file to file named in original invocation
            :qReturn quit (or exit) vi
            :q!Return quit vi even though latest changes have not been saved for this vi call



            move cursor down one line
            move cursor up one line
            move cursor left one character
            move cursor right one character



            u undo whatever you just did; a simple toggle
            . redo whatever you just did



            i insert text before cursor, until Esc hit
            I insert text at beginning of current line, until Esc hit
            a append text after cursor, until Esc hit
            A append text to end of current line, until Esc hit
            o open and put text in a new line below current line, until Esc hit
            O open and put text in a new line above current line, until Esc hit



            r replace single character under cursor (no Esc needed)
            cw change the current word with new text,starting with the character under cursor, until Esc hit
            x delete single character under cursor
            Nx delete N characters, starting with character under cursor
            dw delete the single word beginning with character under cursor
            C change (replace) the characters in the current line, until Esc hit
            D delete the remainder of the line, starting with current cursor position



            dd delete entire current line
            Ndd delete N lines, beginning with the current line; e.g., 5dd deletes 5 lines
            yy copy (yank, cut) the current line into the buffer
            Nyy copy (yank, cut) the next N lines, including the current line, into the buffer
            p paste the line(s) in the buffer into the text after the current line



            0 (zero) move cursor to start of current line (the one with the cursor)
            $ move cursor to end of current line
            w move cursor to beginning of next word
            b move cursor back to beginning of preceding word
            :0Return or 1G move cursor to first line in file
            :nReturn or nG move cursor to line n
            :$Return or G move cursor to last line in file



            /string search forward for occurrence of string in text
            ?string search backward for occurrence of string in text
            n move to next occurrence of search string
            N move to next occurrence of search string in opposite direction







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Dec 6 '15 at 8:07

























            answered Oct 5 '13 at 6:52









            Boris

            3,27273356




            3,27273356








            • 23




              Arrow key down inserting "B" is not an expected behavior. Arrow keys should be moving cursors up and down/ left and right regardless of the insert mode.
              – James Wong
              Sep 6 '15 at 7:49






            • 2




              @JamesWong Actually, it is expected behavior, as that is how Vi was originally programmed. VIM, (unofficially) the successor to Vi, is in Vi-compatible mode by default, which includes this behavior for the arrow keys. So the word "should" here is merely subjective, as VIM is actually doing what it was purposefully programmed to do.
              – villapx
              Dec 1 '16 at 15:30










            • @villapx - No, it isn't expected behavior. Expected behavior is defined by what your typical user expects. The typical person using vi/vim is using it because that's what's installed on a server that they need to quickly configure and they won't be doing enough to bother with installing something else. Few actually choose to use vim when given an option, and fewer actually know all these features or quirks. The typical user expects arrows to move the cursor - that is the expected behavior. Anything else is unexpected behavior, and should be written up as a bug for how unexpected it is.
              – ArtOfWarfare
              Jan 20 at 17:13










            • @ArtOfWarfare You're free to define "expected" however you choose. I'm defining it as what's expected by the author of the code, as they were quite clear in the VIM manual how this is supposed to behave...from :help compatible: "By default this option is on and the Vi defaults are used for the options. This default was chosen for those people who want to use Vim just like Vi, and don't even (want to) know about the 'compatible' option."
              – villapx
              Jan 22 at 20:43










            • @ArtOfWarfare Basically, the VIM author clearly had a specific audience in mind when writing this portion of the code, and just because that audience is different from what your audience would be, doesn't mean it's a bug. You can file it as a bug if you wish, but be prepared to be berated by VIM fundamentalists (and really anyone who respects the 'manual', a la RTFM aficionados).
              – villapx
              Jan 22 at 20:45














            • 23




              Arrow key down inserting "B" is not an expected behavior. Arrow keys should be moving cursors up and down/ left and right regardless of the insert mode.
              – James Wong
              Sep 6 '15 at 7:49






            • 2




              @JamesWong Actually, it is expected behavior, as that is how Vi was originally programmed. VIM, (unofficially) the successor to Vi, is in Vi-compatible mode by default, which includes this behavior for the arrow keys. So the word "should" here is merely subjective, as VIM is actually doing what it was purposefully programmed to do.
              – villapx
              Dec 1 '16 at 15:30










            • @villapx - No, it isn't expected behavior. Expected behavior is defined by what your typical user expects. The typical person using vi/vim is using it because that's what's installed on a server that they need to quickly configure and they won't be doing enough to bother with installing something else. Few actually choose to use vim when given an option, and fewer actually know all these features or quirks. The typical user expects arrows to move the cursor - that is the expected behavior. Anything else is unexpected behavior, and should be written up as a bug for how unexpected it is.
              – ArtOfWarfare
              Jan 20 at 17:13










            • @ArtOfWarfare You're free to define "expected" however you choose. I'm defining it as what's expected by the author of the code, as they were quite clear in the VIM manual how this is supposed to behave...from :help compatible: "By default this option is on and the Vi defaults are used for the options. This default was chosen for those people who want to use Vim just like Vi, and don't even (want to) know about the 'compatible' option."
              – villapx
              Jan 22 at 20:43










            • @ArtOfWarfare Basically, the VIM author clearly had a specific audience in mind when writing this portion of the code, and just because that audience is different from what your audience would be, doesn't mean it's a bug. You can file it as a bug if you wish, but be prepared to be berated by VIM fundamentalists (and really anyone who respects the 'manual', a la RTFM aficionados).
              – villapx
              Jan 22 at 20:45








            23




            23




            Arrow key down inserting "B" is not an expected behavior. Arrow keys should be moving cursors up and down/ left and right regardless of the insert mode.
            – James Wong
            Sep 6 '15 at 7:49




            Arrow key down inserting "B" is not an expected behavior. Arrow keys should be moving cursors up and down/ left and right regardless of the insert mode.
            – James Wong
            Sep 6 '15 at 7:49




            2




            2




            @JamesWong Actually, it is expected behavior, as that is how Vi was originally programmed. VIM, (unofficially) the successor to Vi, is in Vi-compatible mode by default, which includes this behavior for the arrow keys. So the word "should" here is merely subjective, as VIM is actually doing what it was purposefully programmed to do.
            – villapx
            Dec 1 '16 at 15:30




            @JamesWong Actually, it is expected behavior, as that is how Vi was originally programmed. VIM, (unofficially) the successor to Vi, is in Vi-compatible mode by default, which includes this behavior for the arrow keys. So the word "should" here is merely subjective, as VIM is actually doing what it was purposefully programmed to do.
            – villapx
            Dec 1 '16 at 15:30












            @villapx - No, it isn't expected behavior. Expected behavior is defined by what your typical user expects. The typical person using vi/vim is using it because that's what's installed on a server that they need to quickly configure and they won't be doing enough to bother with installing something else. Few actually choose to use vim when given an option, and fewer actually know all these features or quirks. The typical user expects arrows to move the cursor - that is the expected behavior. Anything else is unexpected behavior, and should be written up as a bug for how unexpected it is.
            – ArtOfWarfare
            Jan 20 at 17:13




            @villapx - No, it isn't expected behavior. Expected behavior is defined by what your typical user expects. The typical person using vi/vim is using it because that's what's installed on a server that they need to quickly configure and they won't be doing enough to bother with installing something else. Few actually choose to use vim when given an option, and fewer actually know all these features or quirks. The typical user expects arrows to move the cursor - that is the expected behavior. Anything else is unexpected behavior, and should be written up as a bug for how unexpected it is.
            – ArtOfWarfare
            Jan 20 at 17:13












            @ArtOfWarfare You're free to define "expected" however you choose. I'm defining it as what's expected by the author of the code, as they were quite clear in the VIM manual how this is supposed to behave...from :help compatible: "By default this option is on and the Vi defaults are used for the options. This default was chosen for those people who want to use Vim just like Vi, and don't even (want to) know about the 'compatible' option."
            – villapx
            Jan 22 at 20:43




            @ArtOfWarfare You're free to define "expected" however you choose. I'm defining it as what's expected by the author of the code, as they were quite clear in the VIM manual how this is supposed to behave...from :help compatible: "By default this option is on and the Vi defaults are used for the options. This default was chosen for those people who want to use Vim just like Vi, and don't even (want to) know about the 'compatible' option."
            – villapx
            Jan 22 at 20:43












            @ArtOfWarfare Basically, the VIM author clearly had a specific audience in mind when writing this portion of the code, and just because that audience is different from what your audience would be, doesn't mean it's a bug. You can file it as a bug if you wish, but be prepared to be berated by VIM fundamentalists (and really anyone who respects the 'manual', a la RTFM aficionados).
            – villapx
            Jan 22 at 20:45




            @ArtOfWarfare Basically, the VIM author clearly had a specific audience in mind when writing this portion of the code, and just because that audience is different from what your audience would be, doesn't mean it's a bug. You can file it as a bug if you wish, but be prepared to be berated by VIM fundamentalists (and really anyone who respects the 'manual', a la RTFM aficionados).
            – villapx
            Jan 22 at 20:45










            up vote
            16
            down vote













            To disable printing letters on pressing arrows in edit mode you can do following



            vi $HOME/.exrc 


            (create file if it does not exist) and then add line set nocompatible to it and save.






            share|improve this answer

















            • 2




              This should be the accepted answer. Thank you!
              – eis
              Nov 18 '15 at 10:10










            • I put that in .vimrc. Why do you put it in .exrc?
              – pauljohn32
              Mar 19 '17 at 2:54










            • Vim sources both - see output of :version for load order (also :h .exrc or :h init). I suppose someone might want a setting to apply in both vi and vim, or could be sheer force of habit.
              – William Robertson
              May 27 '17 at 8:46















            up vote
            16
            down vote













            To disable printing letters on pressing arrows in edit mode you can do following



            vi $HOME/.exrc 


            (create file if it does not exist) and then add line set nocompatible to it and save.






            share|improve this answer

















            • 2




              This should be the accepted answer. Thank you!
              – eis
              Nov 18 '15 at 10:10










            • I put that in .vimrc. Why do you put it in .exrc?
              – pauljohn32
              Mar 19 '17 at 2:54










            • Vim sources both - see output of :version for load order (also :h .exrc or :h init). I suppose someone might want a setting to apply in both vi and vim, or could be sheer force of habit.
              – William Robertson
              May 27 '17 at 8:46













            up vote
            16
            down vote










            up vote
            16
            down vote









            To disable printing letters on pressing arrows in edit mode you can do following



            vi $HOME/.exrc 


            (create file if it does not exist) and then add line set nocompatible to it and save.






            share|improve this answer












            To disable printing letters on pressing arrows in edit mode you can do following



            vi $HOME/.exrc 


            (create file if it does not exist) and then add line set nocompatible to it and save.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Aug 8 '15 at 12:46









            Aniket Thakur

            2,30031621




            2,30031621








            • 2




              This should be the accepted answer. Thank you!
              – eis
              Nov 18 '15 at 10:10










            • I put that in .vimrc. Why do you put it in .exrc?
              – pauljohn32
              Mar 19 '17 at 2:54










            • Vim sources both - see output of :version for load order (also :h .exrc or :h init). I suppose someone might want a setting to apply in both vi and vim, or could be sheer force of habit.
              – William Robertson
              May 27 '17 at 8:46














            • 2




              This should be the accepted answer. Thank you!
              – eis
              Nov 18 '15 at 10:10










            • I put that in .vimrc. Why do you put it in .exrc?
              – pauljohn32
              Mar 19 '17 at 2:54










            • Vim sources both - see output of :version for load order (also :h .exrc or :h init). I suppose someone might want a setting to apply in both vi and vim, or could be sheer force of habit.
              – William Robertson
              May 27 '17 at 8:46








            2




            2




            This should be the accepted answer. Thank you!
            – eis
            Nov 18 '15 at 10:10




            This should be the accepted answer. Thank you!
            – eis
            Nov 18 '15 at 10:10












            I put that in .vimrc. Why do you put it in .exrc?
            – pauljohn32
            Mar 19 '17 at 2:54




            I put that in .vimrc. Why do you put it in .exrc?
            – pauljohn32
            Mar 19 '17 at 2:54












            Vim sources both - see output of :version for load order (also :h .exrc or :h init). I suppose someone might want a setting to apply in both vi and vim, or could be sheer force of habit.
            – William Robertson
            May 27 '17 at 8:46




            Vim sources both - see output of :version for load order (also :h .exrc or :h init). I suppose someone might want a setting to apply in both vi and vim, or could be sheer force of habit.
            – William Robertson
            May 27 '17 at 8:46










            up vote
            11
            down vote













            There are three modes in vi editor namely:




            • command mode

            • input mode

            • default mode.


            When youu open a file, you are in default mode. Now if you want to go to a specific position in your text, just use arrow keys or use h, j, k, l keys. Note that this would work only when you have not pressed i (or any other input mode entering command like a, A, I).



            The reason for 'B' may be because the arrow keys in input mode don't function as arrow keys, so just press Esc to go into default mode any time. When to shift to input mode press i or a, and to navigate just press i key and use arrow keys or h, j, k, l.






            share|improve this answer



























              up vote
              11
              down vote













              There are three modes in vi editor namely:




              • command mode

              • input mode

              • default mode.


              When youu open a file, you are in default mode. Now if you want to go to a specific position in your text, just use arrow keys or use h, j, k, l keys. Note that this would work only when you have not pressed i (or any other input mode entering command like a, A, I).



              The reason for 'B' may be because the arrow keys in input mode don't function as arrow keys, so just press Esc to go into default mode any time. When to shift to input mode press i or a, and to navigate just press i key and use arrow keys or h, j, k, l.






              share|improve this answer

























                up vote
                11
                down vote










                up vote
                11
                down vote









                There are three modes in vi editor namely:




                • command mode

                • input mode

                • default mode.


                When youu open a file, you are in default mode. Now if you want to go to a specific position in your text, just use arrow keys or use h, j, k, l keys. Note that this would work only when you have not pressed i (or any other input mode entering command like a, A, I).



                The reason for 'B' may be because the arrow keys in input mode don't function as arrow keys, so just press Esc to go into default mode any time. When to shift to input mode press i or a, and to navigate just press i key and use arrow keys or h, j, k, l.






                share|improve this answer














                There are three modes in vi editor namely:




                • command mode

                • input mode

                • default mode.


                When youu open a file, you are in default mode. Now if you want to go to a specific position in your text, just use arrow keys or use h, j, k, l keys. Note that this would work only when you have not pressed i (or any other input mode entering command like a, A, I).



                The reason for 'B' may be because the arrow keys in input mode don't function as arrow keys, so just press Esc to go into default mode any time. When to shift to input mode press i or a, and to navigate just press i key and use arrow keys or h, j, k, l.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Oct 5 '13 at 7:45









                Radu Rădeanu

                115k34244321




                115k34244321










                answered Nov 21 '12 at 7:14









                ps_cool

                13414




                13414






















                    up vote
                    6
                    down vote













                    I had the exact same Problem but not only on my local machine but also on connections via putty on a sles machine in a Win7 VM over a citrix receiver. Both the local host and the remote hosts show after a reinstall of Ubuntu had the exact same problem.



                    After finding out that



                    $ localectl list-keymaps 
                    Couldn't find any console keymaps.


                    Causes this strange VI behaviour I installed the package console-data which solves the issue!



                    sudo apt-get install console-data





                    share|improve this answer



























                      up vote
                      6
                      down vote













                      I had the exact same Problem but not only on my local machine but also on connections via putty on a sles machine in a Win7 VM over a citrix receiver. Both the local host and the remote hosts show after a reinstall of Ubuntu had the exact same problem.



                      After finding out that



                      $ localectl list-keymaps 
                      Couldn't find any console keymaps.


                      Causes this strange VI behaviour I installed the package console-data which solves the issue!



                      sudo apt-get install console-data





                      share|improve this answer

























                        up vote
                        6
                        down vote










                        up vote
                        6
                        down vote









                        I had the exact same Problem but not only on my local machine but also on connections via putty on a sles machine in a Win7 VM over a citrix receiver. Both the local host and the remote hosts show after a reinstall of Ubuntu had the exact same problem.



                        After finding out that



                        $ localectl list-keymaps 
                        Couldn't find any console keymaps.


                        Causes this strange VI behaviour I installed the package console-data which solves the issue!



                        sudo apt-get install console-data





                        share|improve this answer














                        I had the exact same Problem but not only on my local machine but also on connections via putty on a sles machine in a Win7 VM over a citrix receiver. Both the local host and the remote hosts show after a reinstall of Ubuntu had the exact same problem.



                        After finding out that



                        $ localectl list-keymaps 
                        Couldn't find any console keymaps.


                        Causes this strange VI behaviour I installed the package console-data which solves the issue!



                        sudo apt-get install console-data






                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Jan 19 '17 at 9:44









                        Zanna

                        49.2k13124234




                        49.2k13124234










                        answered Jan 18 '17 at 10:53









                        kitingChris

                        18317




                        18317






















                            up vote
                            3
                            down vote













                            All the explanations given are a bit bizarre. I have vi but not vim installed.



                            Checking alternatives: /etc/alternatives/vi &rightarrow; /usr/bin/vim.tiny



                            So vi is vim.tiny, and it uses /etc/vim/vimrc.tiny.



                            And in vimrc.tiny you find the following line:



                            set compatible


                            Which is almost the only thing in this file. Note that in /etc/vim/vimrc it is using nocompatible.



                            So either install vim, or change the vimrc.tiny file, or create your own ~/.vimrc which should contain the line:



                            set nocompatible





                            share|improve this answer



















                            • 1




                              I'm not sure what's so bizarre. You end up suggesting 1. install Vim - askubuntu.com/a/220072/158442, 2. creating ~/.vimrc and setting nocompatible: askubuntu.com/a/353944/158442, or 3. editing a system file. Only the suggestion to edit /etc/vim/vimrc.tiny is new, and yet you call answers bizarre while suggesting the same thing as them.
                              – muru
                              Jan 11 '17 at 2:27

















                            up vote
                            3
                            down vote













                            All the explanations given are a bit bizarre. I have vi but not vim installed.



                            Checking alternatives: /etc/alternatives/vi &rightarrow; /usr/bin/vim.tiny



                            So vi is vim.tiny, and it uses /etc/vim/vimrc.tiny.



                            And in vimrc.tiny you find the following line:



                            set compatible


                            Which is almost the only thing in this file. Note that in /etc/vim/vimrc it is using nocompatible.



                            So either install vim, or change the vimrc.tiny file, or create your own ~/.vimrc which should contain the line:



                            set nocompatible





                            share|improve this answer



















                            • 1




                              I'm not sure what's so bizarre. You end up suggesting 1. install Vim - askubuntu.com/a/220072/158442, 2. creating ~/.vimrc and setting nocompatible: askubuntu.com/a/353944/158442, or 3. editing a system file. Only the suggestion to edit /etc/vim/vimrc.tiny is new, and yet you call answers bizarre while suggesting the same thing as them.
                              – muru
                              Jan 11 '17 at 2:27















                            up vote
                            3
                            down vote










                            up vote
                            3
                            down vote









                            All the explanations given are a bit bizarre. I have vi but not vim installed.



                            Checking alternatives: /etc/alternatives/vi &rightarrow; /usr/bin/vim.tiny



                            So vi is vim.tiny, and it uses /etc/vim/vimrc.tiny.



                            And in vimrc.tiny you find the following line:



                            set compatible


                            Which is almost the only thing in this file. Note that in /etc/vim/vimrc it is using nocompatible.



                            So either install vim, or change the vimrc.tiny file, or create your own ~/.vimrc which should contain the line:



                            set nocompatible





                            share|improve this answer














                            All the explanations given are a bit bizarre. I have vi but not vim installed.



                            Checking alternatives: /etc/alternatives/vi &rightarrow; /usr/bin/vim.tiny



                            So vi is vim.tiny, and it uses /etc/vim/vimrc.tiny.



                            And in vimrc.tiny you find the following line:



                            set compatible


                            Which is almost the only thing in this file. Note that in /etc/vim/vimrc it is using nocompatible.



                            So either install vim, or change the vimrc.tiny file, or create your own ~/.vimrc which should contain the line:



                            set nocompatible






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Jan 10 '17 at 23:52









                            Eliah Kagan

                            81k20226364




                            81k20226364










                            answered Jan 10 '17 at 22:11









                            Gunstick

                            311




                            311








                            • 1




                              I'm not sure what's so bizarre. You end up suggesting 1. install Vim - askubuntu.com/a/220072/158442, 2. creating ~/.vimrc and setting nocompatible: askubuntu.com/a/353944/158442, or 3. editing a system file. Only the suggestion to edit /etc/vim/vimrc.tiny is new, and yet you call answers bizarre while suggesting the same thing as them.
                              – muru
                              Jan 11 '17 at 2:27
















                            • 1




                              I'm not sure what's so bizarre. You end up suggesting 1. install Vim - askubuntu.com/a/220072/158442, 2. creating ~/.vimrc and setting nocompatible: askubuntu.com/a/353944/158442, or 3. editing a system file. Only the suggestion to edit /etc/vim/vimrc.tiny is new, and yet you call answers bizarre while suggesting the same thing as them.
                              – muru
                              Jan 11 '17 at 2:27










                            1




                            1




                            I'm not sure what's so bizarre. You end up suggesting 1. install Vim - askubuntu.com/a/220072/158442, 2. creating ~/.vimrc and setting nocompatible: askubuntu.com/a/353944/158442, or 3. editing a system file. Only the suggestion to edit /etc/vim/vimrc.tiny is new, and yet you call answers bizarre while suggesting the same thing as them.
                            – muru
                            Jan 11 '17 at 2:27






                            I'm not sure what's so bizarre. You end up suggesting 1. install Vim - askubuntu.com/a/220072/158442, 2. creating ~/.vimrc and setting nocompatible: askubuntu.com/a/353944/158442, or 3. editing a system file. Only the suggestion to edit /etc/vim/vimrc.tiny is new, and yet you call answers bizarre while suggesting the same thing as them.
                            – muru
                            Jan 11 '17 at 2:27












                            up vote
                            2
                            down vote













                            Note:



                            There is good information in the other posts but none of the posts tried to explain why this behavior happened. Many people are bound to stumble on this in the future. Also, could you mark this question as resolved since any of the previous posts likely assisted you?





                            Here is an explanation:



                            Vi is an editor that's been around a long while, with roots back to the Unix systems. It's a good tool but it has been iterated on and now there is better. Vim was written later and is that iteration. People commonly refer to vi as 'vim-minimal' and to vim is an "improved" version of vi. You can think of it like this: vi is the core and vim expands on it.



                            Likely how you discovered the behavior:



                            In order for you to have discovered this problem, you pressed "i" to enter into insert mode and then used your arrow keys to navigate the correct line and edit point. This is what caused your unexpected char issue.



                            Solution 1 or 2



                            1) vi someFile While using vi, first move to the edit point, then enter into insert mode.



                            2) vim someFile Simply use vim from the start.



                            I cannot stress enough to read the manual (man pages) or to use -h for help. Once you adjust to the patterns in the shell, man pages become your best friend. Example: man vi or man vim





                            Validate that Vim is installed.



                            Open a console window and execute:



                            dpkg --list | grep vim



                            If you get something similar to this, then you can just start using vim.



                            ~ $ dpkg --list | grep vim
                            ii vim 2:7.4.052-1ubuntu3 amd64 Vi IMproved - enhanced vi editor
                            ii vim-common 2:7.4.052-1ubuntu3 amd64 Vi IMproved - Common files
                            ii vim-runtime 2:7.4.052-1ubuntu3 all Vi IMproved - Runtime files
                            ii vim-tiny 2:7.4.052-1ubuntu3 amd64 Vi IMproved - enhanced vi editor - compact version


                            If the command prompt returns with nothing, then vim is is not installed. Use the below examples to update your repositories and then install vim.



                            sudo apt-get update
                            sudo apt-get install vim


                            On the off chance that you use vi or vim only when searching on the internet how to fix something and you happen to forget to type vim, there is one way that you can fix it for the future. I caution you to pay attention. You can use an alias to overwrite vi with a reference to vim so that no matter what you type in the infrequent future, you get vim without that "oops!" moment. You can always delete an alias later.



                            Type vim .bashrc. Move down to the empty line with only a ~ (or to any other line that starts with alias (so they're grouped together) and then press the i key to enter -insert- mode. On its own separate line, enter the following:



                            alias vi='vim'


                            Press Esc and then type :wq. Now you need to reload the file. Type source .bashrc Any other shell that opens after you have made these edits will automatically load the .bashrc file.






                            share|improve this answer

























                              up vote
                              2
                              down vote













                              Note:



                              There is good information in the other posts but none of the posts tried to explain why this behavior happened. Many people are bound to stumble on this in the future. Also, could you mark this question as resolved since any of the previous posts likely assisted you?





                              Here is an explanation:



                              Vi is an editor that's been around a long while, with roots back to the Unix systems. It's a good tool but it has been iterated on and now there is better. Vim was written later and is that iteration. People commonly refer to vi as 'vim-minimal' and to vim is an "improved" version of vi. You can think of it like this: vi is the core and vim expands on it.



                              Likely how you discovered the behavior:



                              In order for you to have discovered this problem, you pressed "i" to enter into insert mode and then used your arrow keys to navigate the correct line and edit point. This is what caused your unexpected char issue.



                              Solution 1 or 2



                              1) vi someFile While using vi, first move to the edit point, then enter into insert mode.



                              2) vim someFile Simply use vim from the start.



                              I cannot stress enough to read the manual (man pages) or to use -h for help. Once you adjust to the patterns in the shell, man pages become your best friend. Example: man vi or man vim





                              Validate that Vim is installed.



                              Open a console window and execute:



                              dpkg --list | grep vim



                              If you get something similar to this, then you can just start using vim.



                              ~ $ dpkg --list | grep vim
                              ii vim 2:7.4.052-1ubuntu3 amd64 Vi IMproved - enhanced vi editor
                              ii vim-common 2:7.4.052-1ubuntu3 amd64 Vi IMproved - Common files
                              ii vim-runtime 2:7.4.052-1ubuntu3 all Vi IMproved - Runtime files
                              ii vim-tiny 2:7.4.052-1ubuntu3 amd64 Vi IMproved - enhanced vi editor - compact version


                              If the command prompt returns with nothing, then vim is is not installed. Use the below examples to update your repositories and then install vim.



                              sudo apt-get update
                              sudo apt-get install vim


                              On the off chance that you use vi or vim only when searching on the internet how to fix something and you happen to forget to type vim, there is one way that you can fix it for the future. I caution you to pay attention. You can use an alias to overwrite vi with a reference to vim so that no matter what you type in the infrequent future, you get vim without that "oops!" moment. You can always delete an alias later.



                              Type vim .bashrc. Move down to the empty line with only a ~ (or to any other line that starts with alias (so they're grouped together) and then press the i key to enter -insert- mode. On its own separate line, enter the following:



                              alias vi='vim'


                              Press Esc and then type :wq. Now you need to reload the file. Type source .bashrc Any other shell that opens after you have made these edits will automatically load the .bashrc file.






                              share|improve this answer























                                up vote
                                2
                                down vote










                                up vote
                                2
                                down vote









                                Note:



                                There is good information in the other posts but none of the posts tried to explain why this behavior happened. Many people are bound to stumble on this in the future. Also, could you mark this question as resolved since any of the previous posts likely assisted you?





                                Here is an explanation:



                                Vi is an editor that's been around a long while, with roots back to the Unix systems. It's a good tool but it has been iterated on and now there is better. Vim was written later and is that iteration. People commonly refer to vi as 'vim-minimal' and to vim is an "improved" version of vi. You can think of it like this: vi is the core and vim expands on it.



                                Likely how you discovered the behavior:



                                In order for you to have discovered this problem, you pressed "i" to enter into insert mode and then used your arrow keys to navigate the correct line and edit point. This is what caused your unexpected char issue.



                                Solution 1 or 2



                                1) vi someFile While using vi, first move to the edit point, then enter into insert mode.



                                2) vim someFile Simply use vim from the start.



                                I cannot stress enough to read the manual (man pages) or to use -h for help. Once you adjust to the patterns in the shell, man pages become your best friend. Example: man vi or man vim





                                Validate that Vim is installed.



                                Open a console window and execute:



                                dpkg --list | grep vim



                                If you get something similar to this, then you can just start using vim.



                                ~ $ dpkg --list | grep vim
                                ii vim 2:7.4.052-1ubuntu3 amd64 Vi IMproved - enhanced vi editor
                                ii vim-common 2:7.4.052-1ubuntu3 amd64 Vi IMproved - Common files
                                ii vim-runtime 2:7.4.052-1ubuntu3 all Vi IMproved - Runtime files
                                ii vim-tiny 2:7.4.052-1ubuntu3 amd64 Vi IMproved - enhanced vi editor - compact version


                                If the command prompt returns with nothing, then vim is is not installed. Use the below examples to update your repositories and then install vim.



                                sudo apt-get update
                                sudo apt-get install vim


                                On the off chance that you use vi or vim only when searching on the internet how to fix something and you happen to forget to type vim, there is one way that you can fix it for the future. I caution you to pay attention. You can use an alias to overwrite vi with a reference to vim so that no matter what you type in the infrequent future, you get vim without that "oops!" moment. You can always delete an alias later.



                                Type vim .bashrc. Move down to the empty line with only a ~ (or to any other line that starts with alias (so they're grouped together) and then press the i key to enter -insert- mode. On its own separate line, enter the following:



                                alias vi='vim'


                                Press Esc and then type :wq. Now you need to reload the file. Type source .bashrc Any other shell that opens after you have made these edits will automatically load the .bashrc file.






                                share|improve this answer












                                Note:



                                There is good information in the other posts but none of the posts tried to explain why this behavior happened. Many people are bound to stumble on this in the future. Also, could you mark this question as resolved since any of the previous posts likely assisted you?





                                Here is an explanation:



                                Vi is an editor that's been around a long while, with roots back to the Unix systems. It's a good tool but it has been iterated on and now there is better. Vim was written later and is that iteration. People commonly refer to vi as 'vim-minimal' and to vim is an "improved" version of vi. You can think of it like this: vi is the core and vim expands on it.



                                Likely how you discovered the behavior:



                                In order for you to have discovered this problem, you pressed "i" to enter into insert mode and then used your arrow keys to navigate the correct line and edit point. This is what caused your unexpected char issue.



                                Solution 1 or 2



                                1) vi someFile While using vi, first move to the edit point, then enter into insert mode.



                                2) vim someFile Simply use vim from the start.



                                I cannot stress enough to read the manual (man pages) or to use -h for help. Once you adjust to the patterns in the shell, man pages become your best friend. Example: man vi or man vim





                                Validate that Vim is installed.



                                Open a console window and execute:



                                dpkg --list | grep vim



                                If you get something similar to this, then you can just start using vim.



                                ~ $ dpkg --list | grep vim
                                ii vim 2:7.4.052-1ubuntu3 amd64 Vi IMproved - enhanced vi editor
                                ii vim-common 2:7.4.052-1ubuntu3 amd64 Vi IMproved - Common files
                                ii vim-runtime 2:7.4.052-1ubuntu3 all Vi IMproved - Runtime files
                                ii vim-tiny 2:7.4.052-1ubuntu3 amd64 Vi IMproved - enhanced vi editor - compact version


                                If the command prompt returns with nothing, then vim is is not installed. Use the below examples to update your repositories and then install vim.



                                sudo apt-get update
                                sudo apt-get install vim


                                On the off chance that you use vi or vim only when searching on the internet how to fix something and you happen to forget to type vim, there is one way that you can fix it for the future. I caution you to pay attention. You can use an alias to overwrite vi with a reference to vim so that no matter what you type in the infrequent future, you get vim without that "oops!" moment. You can always delete an alias later.



                                Type vim .bashrc. Move down to the empty line with only a ~ (or to any other line that starts with alias (so they're grouped together) and then press the i key to enter -insert- mode. On its own separate line, enter the following:



                                alias vi='vim'


                                Press Esc and then type :wq. Now you need to reload the file. Type source .bashrc Any other shell that opens after you have made these edits will automatically load the .bashrc file.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Oct 30 '16 at 4:20









                                D75

                                1026




                                1026






















                                    up vote
                                    1
                                    down vote













                                    The traditional vi editor doesn't recognize the arrow keys (...afair). There are two solutions:




                                    1. use vim instead of vi

                                    2. use h, j, k and l to navigate (you can't navigate while editing on the traditional vi btw.)






                                    share|improve this answer





















                                    • This isn't true. Look for terminfo/termcap and libcurses based apps. I use vi since 1990 in Xenix, SCO Unix, AIX, old hpux, and others, and pure-vi from 80s already have support to terminfo/termcap mappings.
                                      – Luciano
                                      Dec 14 '15 at 11:42










                                    • @james-wong well then I should rephrase my answer. To "pure vi under Ubuntu doesn't..."
                                      – MadMike
                                      Dec 14 '15 at 14:52










                                    • ... and this was meant as a comment to @luciano
                                      – MadMike
                                      Dec 14 '15 at 14:53















                                    up vote
                                    1
                                    down vote













                                    The traditional vi editor doesn't recognize the arrow keys (...afair). There are two solutions:




                                    1. use vim instead of vi

                                    2. use h, j, k and l to navigate (you can't navigate while editing on the traditional vi btw.)






                                    share|improve this answer





















                                    • This isn't true. Look for terminfo/termcap and libcurses based apps. I use vi since 1990 in Xenix, SCO Unix, AIX, old hpux, and others, and pure-vi from 80s already have support to terminfo/termcap mappings.
                                      – Luciano
                                      Dec 14 '15 at 11:42










                                    • @james-wong well then I should rephrase my answer. To "pure vi under Ubuntu doesn't..."
                                      – MadMike
                                      Dec 14 '15 at 14:52










                                    • ... and this was meant as a comment to @luciano
                                      – MadMike
                                      Dec 14 '15 at 14:53













                                    up vote
                                    1
                                    down vote










                                    up vote
                                    1
                                    down vote









                                    The traditional vi editor doesn't recognize the arrow keys (...afair). There are two solutions:




                                    1. use vim instead of vi

                                    2. use h, j, k and l to navigate (you can't navigate while editing on the traditional vi btw.)






                                    share|improve this answer












                                    The traditional vi editor doesn't recognize the arrow keys (...afair). There are two solutions:




                                    1. use vim instead of vi

                                    2. use h, j, k and l to navigate (you can't navigate while editing on the traditional vi btw.)







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Oct 5 '13 at 5:51









                                    MadMike

                                    3,77172244




                                    3,77172244












                                    • This isn't true. Look for terminfo/termcap and libcurses based apps. I use vi since 1990 in Xenix, SCO Unix, AIX, old hpux, and others, and pure-vi from 80s already have support to terminfo/termcap mappings.
                                      – Luciano
                                      Dec 14 '15 at 11:42










                                    • @james-wong well then I should rephrase my answer. To "pure vi under Ubuntu doesn't..."
                                      – MadMike
                                      Dec 14 '15 at 14:52










                                    • ... and this was meant as a comment to @luciano
                                      – MadMike
                                      Dec 14 '15 at 14:53


















                                    • This isn't true. Look for terminfo/termcap and libcurses based apps. I use vi since 1990 in Xenix, SCO Unix, AIX, old hpux, and others, and pure-vi from 80s already have support to terminfo/termcap mappings.
                                      – Luciano
                                      Dec 14 '15 at 11:42










                                    • @james-wong well then I should rephrase my answer. To "pure vi under Ubuntu doesn't..."
                                      – MadMike
                                      Dec 14 '15 at 14:52










                                    • ... and this was meant as a comment to @luciano
                                      – MadMike
                                      Dec 14 '15 at 14:53
















                                    This isn't true. Look for terminfo/termcap and libcurses based apps. I use vi since 1990 in Xenix, SCO Unix, AIX, old hpux, and others, and pure-vi from 80s already have support to terminfo/termcap mappings.
                                    – Luciano
                                    Dec 14 '15 at 11:42




                                    This isn't true. Look for terminfo/termcap and libcurses based apps. I use vi since 1990 in Xenix, SCO Unix, AIX, old hpux, and others, and pure-vi from 80s already have support to terminfo/termcap mappings.
                                    – Luciano
                                    Dec 14 '15 at 11:42












                                    @james-wong well then I should rephrase my answer. To "pure vi under Ubuntu doesn't..."
                                    – MadMike
                                    Dec 14 '15 at 14:52




                                    @james-wong well then I should rephrase my answer. To "pure vi under Ubuntu doesn't..."
                                    – MadMike
                                    Dec 14 '15 at 14:52












                                    ... and this was meant as a comment to @luciano
                                    – MadMike
                                    Dec 14 '15 at 14:53




                                    ... and this was meant as a comment to @luciano
                                    – MadMike
                                    Dec 14 '15 at 14:53










                                    up vote
                                    1
                                    down vote













                                    This can also be due to the TERM variable; set it for example like this:



                                     export TERM=xterm





                                    share|improve this answer























                                    • This solved the problem for me where the other answers didn't. Thanks!
                                      – greg
                                      Jul 20 at 10:33















                                    up vote
                                    1
                                    down vote













                                    This can also be due to the TERM variable; set it for example like this:



                                     export TERM=xterm





                                    share|improve this answer























                                    • This solved the problem for me where the other answers didn't. Thanks!
                                      – greg
                                      Jul 20 at 10:33













                                    up vote
                                    1
                                    down vote










                                    up vote
                                    1
                                    down vote









                                    This can also be due to the TERM variable; set it for example like this:



                                     export TERM=xterm





                                    share|improve this answer














                                    This can also be due to the TERM variable; set it for example like this:



                                     export TERM=xterm






                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited Aug 11 '17 at 4:38









                                    αғsнιη

                                    24k2294155




                                    24k2294155










                                    answered Jul 7 '17 at 13:54









                                    Jasper Nuyens

                                    111




                                    111












                                    • This solved the problem for me where the other answers didn't. Thanks!
                                      – greg
                                      Jul 20 at 10:33


















                                    • This solved the problem for me where the other answers didn't. Thanks!
                                      – greg
                                      Jul 20 at 10:33
















                                    This solved the problem for me where the other answers didn't. Thanks!
                                    – greg
                                    Jul 20 at 10:33




                                    This solved the problem for me where the other answers didn't. Thanks!
                                    – greg
                                    Jul 20 at 10:33










                                    up vote
                                    1
                                    down vote













                                    On some systems, the nocompatible option is not available, or it may not fix the problem if a plugin breaks arrow key functionality. Here's a workaround...



                                    Edit the .exrc file to include the following lines:



                                    map! ^[OA ^[ka
                                    map! ^[OB ^[ja
                                    map! ^[OC ^[la
                                    map! ^[OD ^[ha


                                    Or, if the problem only exists in normal mode, you can change to nmap and skip the following a, as follows:



                                    nmap! ^[OA ^[k


                                    and so on.



                                    Here's the key combinations needed to produce them (showing first one only):



                                    map! <CTRL-V><Up-Arrow> <CTRL-V><ESC>ka


                                    This escapes edit mode, moves in the wanted direction, and reenters edit mode. This is needed to overcome Vi reading the escape sequence as a sequence of literal <ESC><O><A>, etc.



                                    Source: https://hea-www.harvard.edu/~fine/Tech/vi.html






                                    share|improve this answer



























                                      up vote
                                      1
                                      down vote













                                      On some systems, the nocompatible option is not available, or it may not fix the problem if a plugin breaks arrow key functionality. Here's a workaround...



                                      Edit the .exrc file to include the following lines:



                                      map! ^[OA ^[ka
                                      map! ^[OB ^[ja
                                      map! ^[OC ^[la
                                      map! ^[OD ^[ha


                                      Or, if the problem only exists in normal mode, you can change to nmap and skip the following a, as follows:



                                      nmap! ^[OA ^[k


                                      and so on.



                                      Here's the key combinations needed to produce them (showing first one only):



                                      map! <CTRL-V><Up-Arrow> <CTRL-V><ESC>ka


                                      This escapes edit mode, moves in the wanted direction, and reenters edit mode. This is needed to overcome Vi reading the escape sequence as a sequence of literal <ESC><O><A>, etc.



                                      Source: https://hea-www.harvard.edu/~fine/Tech/vi.html






                                      share|improve this answer

























                                        up vote
                                        1
                                        down vote










                                        up vote
                                        1
                                        down vote









                                        On some systems, the nocompatible option is not available, or it may not fix the problem if a plugin breaks arrow key functionality. Here's a workaround...



                                        Edit the .exrc file to include the following lines:



                                        map! ^[OA ^[ka
                                        map! ^[OB ^[ja
                                        map! ^[OC ^[la
                                        map! ^[OD ^[ha


                                        Or, if the problem only exists in normal mode, you can change to nmap and skip the following a, as follows:



                                        nmap! ^[OA ^[k


                                        and so on.



                                        Here's the key combinations needed to produce them (showing first one only):



                                        map! <CTRL-V><Up-Arrow> <CTRL-V><ESC>ka


                                        This escapes edit mode, moves in the wanted direction, and reenters edit mode. This is needed to overcome Vi reading the escape sequence as a sequence of literal <ESC><O><A>, etc.



                                        Source: https://hea-www.harvard.edu/~fine/Tech/vi.html






                                        share|improve this answer














                                        On some systems, the nocompatible option is not available, or it may not fix the problem if a plugin breaks arrow key functionality. Here's a workaround...



                                        Edit the .exrc file to include the following lines:



                                        map! ^[OA ^[ka
                                        map! ^[OB ^[ja
                                        map! ^[OC ^[la
                                        map! ^[OD ^[ha


                                        Or, if the problem only exists in normal mode, you can change to nmap and skip the following a, as follows:



                                        nmap! ^[OA ^[k


                                        and so on.



                                        Here's the key combinations needed to produce them (showing first one only):



                                        map! <CTRL-V><Up-Arrow> <CTRL-V><ESC>ka


                                        This escapes edit mode, moves in the wanted direction, and reenters edit mode. This is needed to overcome Vi reading the escape sequence as a sequence of literal <ESC><O><A>, etc.



                                        Source: https://hea-www.harvard.edu/~fine/Tech/vi.html







                                        share|improve this answer














                                        share|improve this answer



                                        share|improve this answer








                                        edited May 2 at 21:46









                                        RAG

                                        34




                                        34










                                        answered Jun 8 '17 at 2:33









                                        Dominic Comtois

                                        1236




                                        1236






















                                            up vote
                                            0
                                            down vote













                                            For VI create or edit the file "~/.exrc" or VIM create or edit the file "~/.vimrc" set or add in the line.



                                            set nocompatible


                                            At the time of this writing there are commends on the second most voted item that are wondering why their entry was not accepted. The reason is there are hosts that do not allow installing other editors. Even then vim sometimes has the same effects, so there is a bunch of usable info from the top two entries. I cannot comment however hopefully this clears up reasons why neither one is 100% correct 100% of the time.






                                            share|improve this answer

























                                              up vote
                                              0
                                              down vote













                                              For VI create or edit the file "~/.exrc" or VIM create or edit the file "~/.vimrc" set or add in the line.



                                              set nocompatible


                                              At the time of this writing there are commends on the second most voted item that are wondering why their entry was not accepted. The reason is there are hosts that do not allow installing other editors. Even then vim sometimes has the same effects, so there is a bunch of usable info from the top two entries. I cannot comment however hopefully this clears up reasons why neither one is 100% correct 100% of the time.






                                              share|improve this answer























                                                up vote
                                                0
                                                down vote










                                                up vote
                                                0
                                                down vote









                                                For VI create or edit the file "~/.exrc" or VIM create or edit the file "~/.vimrc" set or add in the line.



                                                set nocompatible


                                                At the time of this writing there are commends on the second most voted item that are wondering why their entry was not accepted. The reason is there are hosts that do not allow installing other editors. Even then vim sometimes has the same effects, so there is a bunch of usable info from the top two entries. I cannot comment however hopefully this clears up reasons why neither one is 100% correct 100% of the time.






                                                share|improve this answer












                                                For VI create or edit the file "~/.exrc" or VIM create or edit the file "~/.vimrc" set or add in the line.



                                                set nocompatible


                                                At the time of this writing there are commends on the second most voted item that are wondering why their entry was not accepted. The reason is there are hosts that do not allow installing other editors. Even then vim sometimes has the same effects, so there is a bunch of usable info from the top two entries. I cannot comment however hopefully this clears up reasons why neither one is 100% correct 100% of the time.







                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Nov 28 at 18:29









                                                tuxdalinuxpenguin

                                                11




                                                11






























                                                    draft saved

                                                    draft discarded




















































                                                    Thanks for contributing an answer to Ask Ubuntu!


                                                    • Please be sure to answer the question. Provide details and share your research!

                                                    But avoid



                                                    • Asking for help, clarification, or responding to other answers.

                                                    • Making statements based on opinion; back them up with references or personal experience.


                                                    To learn more, see our tips on writing great answers.





                                                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                    Please pay close attention to the following guidance:


                                                    • Please be sure to answer the question. Provide details and share your research!

                                                    But avoid



                                                    • Asking for help, clarification, or responding to other answers.

                                                    • Making statements based on opinion; back them up with references or personal experience.


                                                    To learn more, see our tips on writing great answers.




                                                    draft saved


                                                    draft discarded














                                                    StackExchange.ready(
                                                    function () {
                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f353911%2fhitting-arrow-keys-adds-characters-in-vi-editor%23new-answer', 'question_page');
                                                    }
                                                    );

                                                    Post as a guest















                                                    Required, but never shown





















































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown

































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown







                                                    Popular posts from this blog

                                                    flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                                                    Mangá

                                                     ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕