Arrow keys work like option+arrow in terminal in tmux on osx












1















The following setting in .tmux.conf breaks arrow keys in terminal in tmux:



set-window-option -g xterm-keys on


When I disable this setting, then arrow keys work as expected in terminal but then they don't work in Vim.



With this setting, the arrow keys move the cursor word wise as option+arrow keys.



The problem occurs both inside Terminal and iterm2.










share|improve this question





























    1















    The following setting in .tmux.conf breaks arrow keys in terminal in tmux:



    set-window-option -g xterm-keys on


    When I disable this setting, then arrow keys work as expected in terminal but then they don't work in Vim.



    With this setting, the arrow keys move the cursor word wise as option+arrow keys.



    The problem occurs both inside Terminal and iterm2.










    share|improve this question



























      1












      1








      1


      1






      The following setting in .tmux.conf breaks arrow keys in terminal in tmux:



      set-window-option -g xterm-keys on


      When I disable this setting, then arrow keys work as expected in terminal but then they don't work in Vim.



      With this setting, the arrow keys move the cursor word wise as option+arrow keys.



      The problem occurs both inside Terminal and iterm2.










      share|improve this question
















      The following setting in .tmux.conf breaks arrow keys in terminal in tmux:



      set-window-option -g xterm-keys on


      When I disable this setting, then arrow keys work as expected in terminal but then they don't work in Vim.



      With this setting, the arrow keys move the cursor word wise as option+arrow keys.



      The problem occurs both inside Terminal and iterm2.







      macos keyboard terminal tmux






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 17 '14 at 15:19









      mMontu

      35318




      35318










      asked Oct 13 '14 at 7:53









      Mert NuhogluMert Nuhoglu

      1,04031730




      1,04031730






















          2 Answers
          2






          active

          oldest

          votes


















          1














          I just encountered this same error and fixed it by disabling xterm-keys in my tmux.conf:



          setw -g xterm-keys off


          I then added the following lines to my .vimrc based on this answer to enable the arrow keys to work correctly inside tmux.



          " Needed for tmux and vim to play nice
          nnoremap ^[[A <Up>
          nnoremap ^[[B <Down>
          nnoremap ^[[D <Left>
          nnoremap ^[[C <Right>


          I added the "^[[A" characters by using Vim's verbatim mode, i.e. pressing Ctrl-v and then the correspodning arrow key.



          Finally, I set my tmux terminal to screen256-color using the following line (also in my tmux.conf):



          set-option -g default-terminal "screen-256color" 





          share|improve this answer































            0














            On my macOS High Sierra 10.13.6 the keys are not the same - they are:



            nnoremap ^[OA <Up>
            nnoremap ^[OB <Down>
            nnoremap ^[OD <Left>
            nnoremap ^[OC <Right>


            NB: This is not the functionality I was personally looking for and not sure what the tmux command does.



            I want to stop the arrows keys opening and performing Mission Control actions. For that, I had to disable the keyboard shortcuts in Preferences.



            See: How can I make ctrl+right/left arrow stop changing Desktops in Lion?






            share|improve this answer

























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "3"
              };
              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',
              autoActivateHeartbeat: false,
              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%2fsuperuser.com%2fquestions%2f825441%2farrow-keys-work-like-optionarrow-in-terminal-in-tmux-on-osx%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              I just encountered this same error and fixed it by disabling xterm-keys in my tmux.conf:



              setw -g xterm-keys off


              I then added the following lines to my .vimrc based on this answer to enable the arrow keys to work correctly inside tmux.



              " Needed for tmux and vim to play nice
              nnoremap ^[[A <Up>
              nnoremap ^[[B <Down>
              nnoremap ^[[D <Left>
              nnoremap ^[[C <Right>


              I added the "^[[A" characters by using Vim's verbatim mode, i.e. pressing Ctrl-v and then the correspodning arrow key.



              Finally, I set my tmux terminal to screen256-color using the following line (also in my tmux.conf):



              set-option -g default-terminal "screen-256color" 





              share|improve this answer




























                1














                I just encountered this same error and fixed it by disabling xterm-keys in my tmux.conf:



                setw -g xterm-keys off


                I then added the following lines to my .vimrc based on this answer to enable the arrow keys to work correctly inside tmux.



                " Needed for tmux and vim to play nice
                nnoremap ^[[A <Up>
                nnoremap ^[[B <Down>
                nnoremap ^[[D <Left>
                nnoremap ^[[C <Right>


                I added the "^[[A" characters by using Vim's verbatim mode, i.e. pressing Ctrl-v and then the correspodning arrow key.



                Finally, I set my tmux terminal to screen256-color using the following line (also in my tmux.conf):



                set-option -g default-terminal "screen-256color" 





                share|improve this answer


























                  1












                  1








                  1







                  I just encountered this same error and fixed it by disabling xterm-keys in my tmux.conf:



                  setw -g xterm-keys off


                  I then added the following lines to my .vimrc based on this answer to enable the arrow keys to work correctly inside tmux.



                  " Needed for tmux and vim to play nice
                  nnoremap ^[[A <Up>
                  nnoremap ^[[B <Down>
                  nnoremap ^[[D <Left>
                  nnoremap ^[[C <Right>


                  I added the "^[[A" characters by using Vim's verbatim mode, i.e. pressing Ctrl-v and then the correspodning arrow key.



                  Finally, I set my tmux terminal to screen256-color using the following line (also in my tmux.conf):



                  set-option -g default-terminal "screen-256color" 





                  share|improve this answer













                  I just encountered this same error and fixed it by disabling xterm-keys in my tmux.conf:



                  setw -g xterm-keys off


                  I then added the following lines to my .vimrc based on this answer to enable the arrow keys to work correctly inside tmux.



                  " Needed for tmux and vim to play nice
                  nnoremap ^[[A <Up>
                  nnoremap ^[[B <Down>
                  nnoremap ^[[D <Left>
                  nnoremap ^[[C <Right>


                  I added the "^[[A" characters by using Vim's verbatim mode, i.e. pressing Ctrl-v and then the correspodning arrow key.



                  Finally, I set my tmux terminal to screen256-color using the following line (also in my tmux.conf):



                  set-option -g default-terminal "screen-256color" 






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jun 23 '17 at 18:00









                  nosbormnosborm

                  111




                  111

























                      0














                      On my macOS High Sierra 10.13.6 the keys are not the same - they are:



                      nnoremap ^[OA <Up>
                      nnoremap ^[OB <Down>
                      nnoremap ^[OD <Left>
                      nnoremap ^[OC <Right>


                      NB: This is not the functionality I was personally looking for and not sure what the tmux command does.



                      I want to stop the arrows keys opening and performing Mission Control actions. For that, I had to disable the keyboard shortcuts in Preferences.



                      See: How can I make ctrl+right/left arrow stop changing Desktops in Lion?






                      share|improve this answer






























                        0














                        On my macOS High Sierra 10.13.6 the keys are not the same - they are:



                        nnoremap ^[OA <Up>
                        nnoremap ^[OB <Down>
                        nnoremap ^[OD <Left>
                        nnoremap ^[OC <Right>


                        NB: This is not the functionality I was personally looking for and not sure what the tmux command does.



                        I want to stop the arrows keys opening and performing Mission Control actions. For that, I had to disable the keyboard shortcuts in Preferences.



                        See: How can I make ctrl+right/left arrow stop changing Desktops in Lion?






                        share|improve this answer




























                          0












                          0








                          0







                          On my macOS High Sierra 10.13.6 the keys are not the same - they are:



                          nnoremap ^[OA <Up>
                          nnoremap ^[OB <Down>
                          nnoremap ^[OD <Left>
                          nnoremap ^[OC <Right>


                          NB: This is not the functionality I was personally looking for and not sure what the tmux command does.



                          I want to stop the arrows keys opening and performing Mission Control actions. For that, I had to disable the keyboard shortcuts in Preferences.



                          See: How can I make ctrl+right/left arrow stop changing Desktops in Lion?






                          share|improve this answer















                          On my macOS High Sierra 10.13.6 the keys are not the same - they are:



                          nnoremap ^[OA <Up>
                          nnoremap ^[OB <Down>
                          nnoremap ^[OD <Left>
                          nnoremap ^[OC <Right>


                          NB: This is not the functionality I was personally looking for and not sure what the tmux command does.



                          I want to stop the arrows keys opening and performing Mission Control actions. For that, I had to disable the keyboard shortcuts in Preferences.



                          See: How can I make ctrl+right/left arrow stop changing Desktops in Lion?







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Jan 22 at 0:10

























                          answered Jan 21 at 23:44









                          Tony BarganskiTony Barganski

                          1012




                          1012






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Super User!


                              • 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%2fsuperuser.com%2fquestions%2f825441%2farrow-keys-work-like-optionarrow-in-terminal-in-tmux-on-osx%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

                              Сан-Квентин

                              Алькесар

                              Josef Freinademetz