Why do control-left and control-right (arrow keys) not navigate by word in `less`?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















In less's line editing mode, the left and right arrow keys move the cursor backwards and forwards. I was hoping to use these together with the control key to navigate by word, as promised by man less.



 ^LEFTARROW [ ESC-b or ESC-LEFTARROW ]
(That is, CONTROL and LEFTARROW simultaneously.) Move the cursor one word to the left.

^RIGHTARROW [ ESC-w or ESC-RIGHTARROW ]
(That is, CONTROL and RIGHTARROW simultaneously.) Move the cursor one word to the right.


Unfortunately, this seems not to work in my terminal. (Tilix 1.8.3, VTE 0.52, GTK 3.22.30 on Fedora 28). Instead, pressing Control-left prints something I don't recognise. In the example below, I typed alpha beta and then immediately pressed Control-Left. This added ESC[1;5D to the line.



[1]



Is there some misconfiguration going on here? In other applications (e.g. vim) Control-Left and Control-Right navigate by word as intended.



FWIW, Ctrl + left/right arrow keys issue, might be related as might Arrow keys in less










share|improve this question






















  • Looks like less doesn't support (at least not out of the box) the standard escape sequences that Ctrl+arrow keypresses generate nowadays in xterm and many other terminal emulators. It probably supports an older one instead. It would be lovely if you reported this to less's developer, thanks in advance!

    – egmont
    Mar 15 at 12:32

















1















In less's line editing mode, the left and right arrow keys move the cursor backwards and forwards. I was hoping to use these together with the control key to navigate by word, as promised by man less.



 ^LEFTARROW [ ESC-b or ESC-LEFTARROW ]
(That is, CONTROL and LEFTARROW simultaneously.) Move the cursor one word to the left.

^RIGHTARROW [ ESC-w or ESC-RIGHTARROW ]
(That is, CONTROL and RIGHTARROW simultaneously.) Move the cursor one word to the right.


Unfortunately, this seems not to work in my terminal. (Tilix 1.8.3, VTE 0.52, GTK 3.22.30 on Fedora 28). Instead, pressing Control-left prints something I don't recognise. In the example below, I typed alpha beta and then immediately pressed Control-Left. This added ESC[1;5D to the line.



[1]



Is there some misconfiguration going on here? In other applications (e.g. vim) Control-Left and Control-Right navigate by word as intended.



FWIW, Ctrl + left/right arrow keys issue, might be related as might Arrow keys in less










share|improve this question






















  • Looks like less doesn't support (at least not out of the box) the standard escape sequences that Ctrl+arrow keypresses generate nowadays in xterm and many other terminal emulators. It probably supports an older one instead. It would be lovely if you reported this to less's developer, thanks in advance!

    – egmont
    Mar 15 at 12:32













1












1








1








In less's line editing mode, the left and right arrow keys move the cursor backwards and forwards. I was hoping to use these together with the control key to navigate by word, as promised by man less.



 ^LEFTARROW [ ESC-b or ESC-LEFTARROW ]
(That is, CONTROL and LEFTARROW simultaneously.) Move the cursor one word to the left.

^RIGHTARROW [ ESC-w or ESC-RIGHTARROW ]
(That is, CONTROL and RIGHTARROW simultaneously.) Move the cursor one word to the right.


Unfortunately, this seems not to work in my terminal. (Tilix 1.8.3, VTE 0.52, GTK 3.22.30 on Fedora 28). Instead, pressing Control-left prints something I don't recognise. In the example below, I typed alpha beta and then immediately pressed Control-Left. This added ESC[1;5D to the line.



[1]



Is there some misconfiguration going on here? In other applications (e.g. vim) Control-Left and Control-Right navigate by word as intended.



FWIW, Ctrl + left/right arrow keys issue, might be related as might Arrow keys in less










share|improve this question














In less's line editing mode, the left and right arrow keys move the cursor backwards and forwards. I was hoping to use these together with the control key to navigate by word, as promised by man less.



 ^LEFTARROW [ ESC-b or ESC-LEFTARROW ]
(That is, CONTROL and LEFTARROW simultaneously.) Move the cursor one word to the left.

^RIGHTARROW [ ESC-w or ESC-RIGHTARROW ]
(That is, CONTROL and RIGHTARROW simultaneously.) Move the cursor one word to the right.


Unfortunately, this seems not to work in my terminal. (Tilix 1.8.3, VTE 0.52, GTK 3.22.30 on Fedora 28). Instead, pressing Control-left prints something I don't recognise. In the example below, I typed alpha beta and then immediately pressed Control-Left. This added ESC[1;5D to the line.



[1]



Is there some misconfiguration going on here? In other applications (e.g. vim) Control-Left and Control-Right navigate by word as intended.



FWIW, Ctrl + left/right arrow keys issue, might be related as might Arrow keys in less







terminal less input-method user-input






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 15 at 10:18









David RobertsonDavid Robertson

1064




1064












  • Looks like less doesn't support (at least not out of the box) the standard escape sequences that Ctrl+arrow keypresses generate nowadays in xterm and many other terminal emulators. It probably supports an older one instead. It would be lovely if you reported this to less's developer, thanks in advance!

    – egmont
    Mar 15 at 12:32

















  • Looks like less doesn't support (at least not out of the box) the standard escape sequences that Ctrl+arrow keypresses generate nowadays in xterm and many other terminal emulators. It probably supports an older one instead. It would be lovely if you reported this to less's developer, thanks in advance!

    – egmont
    Mar 15 at 12:32
















Looks like less doesn't support (at least not out of the box) the standard escape sequences that Ctrl+arrow keypresses generate nowadays in xterm and many other terminal emulators. It probably supports an older one instead. It would be lovely if you reported this to less's developer, thanks in advance!

– egmont
Mar 15 at 12:32





Looks like less doesn't support (at least not out of the box) the standard escape sequences that Ctrl+arrow keypresses generate nowadays in xterm and many other terminal emulators. It probably supports an older one instead. It would be lovely if you reported this to less's developer, thanks in advance!

– egmont
Mar 15 at 12:32










4 Answers
4






active

oldest

votes


















3














Because you are not using OS/2



I am not kidding.



The OS/2 input handling code in less has a "special key" mapping for the ⎈ Control+ and ⎈ Control+ chords to its internal SK_CTL_LEFT_ARROW and SK_CTL_RIGHT_ARROW events.



The Unix code simply has no equivalent mapping. It relies upon termcap, and termcap is notoriously deficient in this area.



What is in square brackets in the doco is right, and what is in parentheses is wrong. You'll have to use ⎋ Escape B, ⎋ Escape F, ⎋ Escape (sic!), and ⎋ Escape (sic!) sequences (not chords, note) until someone makes less better. Please file a report.



(In some terminal emulators, you can configure a modifier key to cause an ⎋ Escape to be prefixed. This is not true for all terminal emulators and terminals, in particular the ones whose input control sequences are being emulated here (which, rather, report modifiers in the CSI sequence), and the important part is that the first character received by less from the terminal is . less itself has no notion of such a modifier.)



Further reading



  • https://unix.stackexchange.com/a/444270/5132

  • https://unix.stackexchange.com/a/465308/5132

  • "What if I find a bug in less?". less FAQ. Greenwood Software.





share|improve this answer


















  • 1





    Do we have any alternative that uses GNU readline so that I can play with ~/.inputrc?

    – Weijun Zhou
    Mar 15 at 19:06


















2














Try Alt+w and Alt+b



w will be used for forward search and b will be used for backward.






share|improve this answer






























    1














    less is a termcap application, using the termcap interface to obtain all of the information it "knows" about a given terminal. Unless its developer introduces some hard-coded behavior (as done in a very few programs which I won't mention), less will provide no support for those key combinations because they are not standard features (see for instance the termcap column of the capabilities listed in ncurses' terminfo(5)), and have no 2-character names assigned to them (see the terminal database for a summary of extensions).



    By the way, referring to my answer and taking a quick look at less's source-code, I do not see anything that corresponds to left/right word movement (unless that is the intended meaning of the left/right shift A_LSHIFT and A_RSHIFT). git blame says those as well as the manual page comment about "word" date back to 2007 (version 394). These look more promising (from 2016):



     SK(SK_CTL_RIGHT_ARROW),0, A_RRSHIFT,
    SK(SK_CTL_LEFT_ARROW),0, A_LLSHIFT


    but the checkin comment only says



    commit e5c195113d1666ac506ea3f65545d436d96fe099
    Author: Mark Nudelman <markn@greenwoodsoftware.com>
    Date: Sat Oct 22 15:25:44 2016 +0000

    New commands ESC- and ESC- to shift to start/end of displayed lines.


    Reading the code (in command.c) for shifting, I did not see anything that disagrees with the conclusion that less scrolls by columns (single characters) rather than words, but OP's comment pointed to these:



     ESC,SK(SK_LEFT_ARROW),0, EC_W_LEFT, /* ESC LEFTARROW */
    SK(SK_CTL_LEFT_ARROW),0, EC_W_LEFT, /* CTRL-LEFTARROW */
    ESC,'w',0, EC_W_RIGHT, /* ESC w */
    ESC,SK(SK_RIGHT_ARROW),0, EC_W_RIGHT, /* ESC RIGHTARROW */
    SK(SK_CTL_RIGHT_ARROW),0, EC_W_RIGHT, /* CTRL-RIGHTARROW */


    which use space as a delimiter for "words". Perhaps when the developer made those changes, he had in mind imitating vi, which can do both (though vi's words are delimited differently).



    The suggested *Escapeleft-arrow, etc., are provided using these lines from the table:



     ESC,SK(SK_LEFT_ARROW),0, EC_W_LEFT, /* ESC LEFTARROW */

    ESC,SK(SK_RIGHT_ARROW),0, EC_W_RIGHT, /* ESC RIGHTARROW */


    However—the current program does not contain any assignments using those SK_CTL_RIGHT_ARROW or SK_CTL_LEFT_ARROW symbols. That would be done in lesskey, e.g., in this case statement (or close by, at any rate):



     switch (*++p)

    case 'u': ch = SK_UP_ARROW; break;
    case 'd': ch = SK_DOWN_ARROW; break;
    case 'r': ch = SK_RIGHT_ARROW; break;
    case 'l': ch = SK_LEFT_ARROW; break;
    case 'U': ch = SK_PAGE_UP; break;
    case 'D': ch = SK_PAGE_DOWN; break;
    case 'h': ch = SK_HOME; break;
    case 'e': ch = SK_END; break;
    case 'x': ch = SK_DELETE; break;
    default:
    error("illegal char after \k", NULL_PARG);
    *pp = p+1;
    return ("");



    Without assignments in the code, those are hard-coded only, not configurable.



    The MSDOS / OS/2 configurations differ from the Unix one by having a (hard-coded) table of key codes:



    #if MSDOS_COMPILER || OS2
    static char k_right = '340', PCK_RIGHT, 0 ;
    static char k_left = '340', PCK_LEFT, 0 ;
    static char k_ctl_right = '340', PCK_CTL_RIGHT, 0 ;
    static char k_ctl_left = '340', PCK_CTL_LEFT, 0 ;


    and provides for using those in a case statement:



    #if MSDOS_COMPILER || OS2
    case SK_INSERT:
    s = k_insert;
    break;
    case SK_CTL_LEFT_ARROW:
    s = k_ctl_left;
    break;
    case SK_CTL_RIGHT_ARROW:
    s = k_ctl_right;
    break;


    (note: still no assignments, hence the cases are unused), while in the termcap configuration, those symbols are not used at all. (termcap is "extensible", and if you took the trouble to invent 2-character mnemonics for your own use and modify less to implement those cases, it would do what you want).



    Revisiting lesskey's manual page, it says this:




    An action may be followed by an "extra" string. When such a command is
    entered while running less, the action is performed, and then the extra
    string is parsed, just as if it were typed in to less. This feature
    can be used in certain cases to extend the functionality of a command.
    For example, see the "{" and ":t" commands in the example below. The
    extra string has a special meaning for the "quit" action: when less
    quits, first character of the extra string is used as its exit status.




    That implies that you could do something like this:



    e[1;5D noaction ee[D
    e[1;5C noaction ee[C


    to map into an extra string which uses the predefined word-shift.






    share|improve this answer

























    • Esc ← and Esc → navigate by what looks like words to me (as in JdeBP's answer). Note that there are separate binds and commands for the "text buffer" you get at the bottom of less, and in particular EC_W_LEFT which seems promising. Perhaps I can use lesskey(1) to make less treat whatever input it is getting as if it was getting Ctrl-← and Ctrl-→; I will investigate.

      – David Robertson
      Mar 15 at 22:26












    • I see - will update

      – Thomas Dickey
      Mar 15 at 22:30











    • Thank you for your thoroughness. Do I understand you and the source code correctly? 1. There is no way for lesskey to generate a SK_SPECIAL_KEY string whose second (i.e. index 1) character is SK_CTL_LEFT_ARROW. This is because there is no standard termcap 2-character mnemonic for the Ctrl-← chord. 2. This means there is no way to "hit" the SK(SK_CTL_LEFT_ARROW),0, EC_W_LEFT, /* CTRL-LEFTARROW */ entry in the edittable which in order to trigger the EC_W_LEFT "action".

      – David Robertson
      Mar 15 at 23:31












    • right less doesn't ask tgetstr for a capability, and none is defined (terminfo uses more than 2 characters) and lesskey doesn't have a way to set the value. As I read it, you can only get to those word-shifts using the escape+key stuff.

      – Thomas Dickey
      Mar 16 at 0:32











    • The noaction approach looks promising. lesskey doesn't like using the noaction action within a #line-edit section, I assume because there is no entry in editnames. There is a code EC_NOACTION which is used here but not assigned anywhere.

      – David Robertson
      Mar 18 at 12:57


















    0














    I managed to get this working in the end. (I contacted less's author, whose response pointed out that I was making things a little more complicated than they needed to be.)



    Here's the lesskey configuration file I ended up using.



    #! /usr/bin/env lesskey
    #line-edit
    e[1;5D word-left
    e[1;5C word-right
    e[3;5~ word-delete


    Running lesskey on this file and starting a new instance made Ctrl-← and Ctrl-→ navigate by (space-delimited?) word, and Ctrl-Delete delete rightwards to the end of the current word. I guess the downside of this solution is that it's hard-coded to the particular escape sequences generated by my terminal emulator; the other answers explain why a generic "control+arrow key" mechanism wasn't possible.






    share|improve this answer























      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      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: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      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%2funix.stackexchange.com%2fquestions%2f506469%2fwhy-do-control-left-and-control-right-arrow-keys-not-navigate-by-word-in-less%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      3














      Because you are not using OS/2



      I am not kidding.



      The OS/2 input handling code in less has a "special key" mapping for the ⎈ Control+ and ⎈ Control+ chords to its internal SK_CTL_LEFT_ARROW and SK_CTL_RIGHT_ARROW events.



      The Unix code simply has no equivalent mapping. It relies upon termcap, and termcap is notoriously deficient in this area.



      What is in square brackets in the doco is right, and what is in parentheses is wrong. You'll have to use ⎋ Escape B, ⎋ Escape F, ⎋ Escape (sic!), and ⎋ Escape (sic!) sequences (not chords, note) until someone makes less better. Please file a report.



      (In some terminal emulators, you can configure a modifier key to cause an ⎋ Escape to be prefixed. This is not true for all terminal emulators and terminals, in particular the ones whose input control sequences are being emulated here (which, rather, report modifiers in the CSI sequence), and the important part is that the first character received by less from the terminal is . less itself has no notion of such a modifier.)



      Further reading



      • https://unix.stackexchange.com/a/444270/5132

      • https://unix.stackexchange.com/a/465308/5132

      • "What if I find a bug in less?". less FAQ. Greenwood Software.





      share|improve this answer


















      • 1





        Do we have any alternative that uses GNU readline so that I can play with ~/.inputrc?

        – Weijun Zhou
        Mar 15 at 19:06















      3














      Because you are not using OS/2



      I am not kidding.



      The OS/2 input handling code in less has a "special key" mapping for the ⎈ Control+ and ⎈ Control+ chords to its internal SK_CTL_LEFT_ARROW and SK_CTL_RIGHT_ARROW events.



      The Unix code simply has no equivalent mapping. It relies upon termcap, and termcap is notoriously deficient in this area.



      What is in square brackets in the doco is right, and what is in parentheses is wrong. You'll have to use ⎋ Escape B, ⎋ Escape F, ⎋ Escape (sic!), and ⎋ Escape (sic!) sequences (not chords, note) until someone makes less better. Please file a report.



      (In some terminal emulators, you can configure a modifier key to cause an ⎋ Escape to be prefixed. This is not true for all terminal emulators and terminals, in particular the ones whose input control sequences are being emulated here (which, rather, report modifiers in the CSI sequence), and the important part is that the first character received by less from the terminal is . less itself has no notion of such a modifier.)



      Further reading



      • https://unix.stackexchange.com/a/444270/5132

      • https://unix.stackexchange.com/a/465308/5132

      • "What if I find a bug in less?". less FAQ. Greenwood Software.





      share|improve this answer


















      • 1





        Do we have any alternative that uses GNU readline so that I can play with ~/.inputrc?

        – Weijun Zhou
        Mar 15 at 19:06













      3












      3








      3







      Because you are not using OS/2



      I am not kidding.



      The OS/2 input handling code in less has a "special key" mapping for the ⎈ Control+ and ⎈ Control+ chords to its internal SK_CTL_LEFT_ARROW and SK_CTL_RIGHT_ARROW events.



      The Unix code simply has no equivalent mapping. It relies upon termcap, and termcap is notoriously deficient in this area.



      What is in square brackets in the doco is right, and what is in parentheses is wrong. You'll have to use ⎋ Escape B, ⎋ Escape F, ⎋ Escape (sic!), and ⎋ Escape (sic!) sequences (not chords, note) until someone makes less better. Please file a report.



      (In some terminal emulators, you can configure a modifier key to cause an ⎋ Escape to be prefixed. This is not true for all terminal emulators and terminals, in particular the ones whose input control sequences are being emulated here (which, rather, report modifiers in the CSI sequence), and the important part is that the first character received by less from the terminal is . less itself has no notion of such a modifier.)



      Further reading



      • https://unix.stackexchange.com/a/444270/5132

      • https://unix.stackexchange.com/a/465308/5132

      • "What if I find a bug in less?". less FAQ. Greenwood Software.





      share|improve this answer













      Because you are not using OS/2



      I am not kidding.



      The OS/2 input handling code in less has a "special key" mapping for the ⎈ Control+ and ⎈ Control+ chords to its internal SK_CTL_LEFT_ARROW and SK_CTL_RIGHT_ARROW events.



      The Unix code simply has no equivalent mapping. It relies upon termcap, and termcap is notoriously deficient in this area.



      What is in square brackets in the doco is right, and what is in parentheses is wrong. You'll have to use ⎋ Escape B, ⎋ Escape F, ⎋ Escape (sic!), and ⎋ Escape (sic!) sequences (not chords, note) until someone makes less better. Please file a report.



      (In some terminal emulators, you can configure a modifier key to cause an ⎋ Escape to be prefixed. This is not true for all terminal emulators and terminals, in particular the ones whose input control sequences are being emulated here (which, rather, report modifiers in the CSI sequence), and the important part is that the first character received by less from the terminal is . less itself has no notion of such a modifier.)



      Further reading



      • https://unix.stackexchange.com/a/444270/5132

      • https://unix.stackexchange.com/a/465308/5132

      • "What if I find a bug in less?". less FAQ. Greenwood Software.






      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Mar 15 at 19:00









      JdeBPJdeBP

      38.1k478185




      38.1k478185







      • 1





        Do we have any alternative that uses GNU readline so that I can play with ~/.inputrc?

        – Weijun Zhou
        Mar 15 at 19:06












      • 1





        Do we have any alternative that uses GNU readline so that I can play with ~/.inputrc?

        – Weijun Zhou
        Mar 15 at 19:06







      1




      1





      Do we have any alternative that uses GNU readline so that I can play with ~/.inputrc?

      – Weijun Zhou
      Mar 15 at 19:06





      Do we have any alternative that uses GNU readline so that I can play with ~/.inputrc?

      – Weijun Zhou
      Mar 15 at 19:06













      2














      Try Alt+w and Alt+b



      w will be used for forward search and b will be used for backward.






      share|improve this answer



























        2














        Try Alt+w and Alt+b



        w will be used for forward search and b will be used for backward.






        share|improve this answer

























          2












          2








          2







          Try Alt+w and Alt+b



          w will be used for forward search and b will be used for backward.






          share|improve this answer













          Try Alt+w and Alt+b



          w will be used for forward search and b will be used for backward.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 15 at 11:00









          ProgrammerProgrammer

          459




          459





















              1














              less is a termcap application, using the termcap interface to obtain all of the information it "knows" about a given terminal. Unless its developer introduces some hard-coded behavior (as done in a very few programs which I won't mention), less will provide no support for those key combinations because they are not standard features (see for instance the termcap column of the capabilities listed in ncurses' terminfo(5)), and have no 2-character names assigned to them (see the terminal database for a summary of extensions).



              By the way, referring to my answer and taking a quick look at less's source-code, I do not see anything that corresponds to left/right word movement (unless that is the intended meaning of the left/right shift A_LSHIFT and A_RSHIFT). git blame says those as well as the manual page comment about "word" date back to 2007 (version 394). These look more promising (from 2016):



               SK(SK_CTL_RIGHT_ARROW),0, A_RRSHIFT,
              SK(SK_CTL_LEFT_ARROW),0, A_LLSHIFT


              but the checkin comment only says



              commit e5c195113d1666ac506ea3f65545d436d96fe099
              Author: Mark Nudelman <markn@greenwoodsoftware.com>
              Date: Sat Oct 22 15:25:44 2016 +0000

              New commands ESC- and ESC- to shift to start/end of displayed lines.


              Reading the code (in command.c) for shifting, I did not see anything that disagrees with the conclusion that less scrolls by columns (single characters) rather than words, but OP's comment pointed to these:



               ESC,SK(SK_LEFT_ARROW),0, EC_W_LEFT, /* ESC LEFTARROW */
              SK(SK_CTL_LEFT_ARROW),0, EC_W_LEFT, /* CTRL-LEFTARROW */
              ESC,'w',0, EC_W_RIGHT, /* ESC w */
              ESC,SK(SK_RIGHT_ARROW),0, EC_W_RIGHT, /* ESC RIGHTARROW */
              SK(SK_CTL_RIGHT_ARROW),0, EC_W_RIGHT, /* CTRL-RIGHTARROW */


              which use space as a delimiter for "words". Perhaps when the developer made those changes, he had in mind imitating vi, which can do both (though vi's words are delimited differently).



              The suggested *Escapeleft-arrow, etc., are provided using these lines from the table:



               ESC,SK(SK_LEFT_ARROW),0, EC_W_LEFT, /* ESC LEFTARROW */

              ESC,SK(SK_RIGHT_ARROW),0, EC_W_RIGHT, /* ESC RIGHTARROW */


              However—the current program does not contain any assignments using those SK_CTL_RIGHT_ARROW or SK_CTL_LEFT_ARROW symbols. That would be done in lesskey, e.g., in this case statement (or close by, at any rate):



               switch (*++p)

              case 'u': ch = SK_UP_ARROW; break;
              case 'd': ch = SK_DOWN_ARROW; break;
              case 'r': ch = SK_RIGHT_ARROW; break;
              case 'l': ch = SK_LEFT_ARROW; break;
              case 'U': ch = SK_PAGE_UP; break;
              case 'D': ch = SK_PAGE_DOWN; break;
              case 'h': ch = SK_HOME; break;
              case 'e': ch = SK_END; break;
              case 'x': ch = SK_DELETE; break;
              default:
              error("illegal char after \k", NULL_PARG);
              *pp = p+1;
              return ("");



              Without assignments in the code, those are hard-coded only, not configurable.



              The MSDOS / OS/2 configurations differ from the Unix one by having a (hard-coded) table of key codes:



              #if MSDOS_COMPILER || OS2
              static char k_right = '340', PCK_RIGHT, 0 ;
              static char k_left = '340', PCK_LEFT, 0 ;
              static char k_ctl_right = '340', PCK_CTL_RIGHT, 0 ;
              static char k_ctl_left = '340', PCK_CTL_LEFT, 0 ;


              and provides for using those in a case statement:



              #if MSDOS_COMPILER || OS2
              case SK_INSERT:
              s = k_insert;
              break;
              case SK_CTL_LEFT_ARROW:
              s = k_ctl_left;
              break;
              case SK_CTL_RIGHT_ARROW:
              s = k_ctl_right;
              break;


              (note: still no assignments, hence the cases are unused), while in the termcap configuration, those symbols are not used at all. (termcap is "extensible", and if you took the trouble to invent 2-character mnemonics for your own use and modify less to implement those cases, it would do what you want).



              Revisiting lesskey's manual page, it says this:




              An action may be followed by an "extra" string. When such a command is
              entered while running less, the action is performed, and then the extra
              string is parsed, just as if it were typed in to less. This feature
              can be used in certain cases to extend the functionality of a command.
              For example, see the "{" and ":t" commands in the example below. The
              extra string has a special meaning for the "quit" action: when less
              quits, first character of the extra string is used as its exit status.




              That implies that you could do something like this:



              e[1;5D noaction ee[D
              e[1;5C noaction ee[C


              to map into an extra string which uses the predefined word-shift.






              share|improve this answer

























              • Esc ← and Esc → navigate by what looks like words to me (as in JdeBP's answer). Note that there are separate binds and commands for the "text buffer" you get at the bottom of less, and in particular EC_W_LEFT which seems promising. Perhaps I can use lesskey(1) to make less treat whatever input it is getting as if it was getting Ctrl-← and Ctrl-→; I will investigate.

                – David Robertson
                Mar 15 at 22:26












              • I see - will update

                – Thomas Dickey
                Mar 15 at 22:30











              • Thank you for your thoroughness. Do I understand you and the source code correctly? 1. There is no way for lesskey to generate a SK_SPECIAL_KEY string whose second (i.e. index 1) character is SK_CTL_LEFT_ARROW. This is because there is no standard termcap 2-character mnemonic for the Ctrl-← chord. 2. This means there is no way to "hit" the SK(SK_CTL_LEFT_ARROW),0, EC_W_LEFT, /* CTRL-LEFTARROW */ entry in the edittable which in order to trigger the EC_W_LEFT "action".

                – David Robertson
                Mar 15 at 23:31












              • right less doesn't ask tgetstr for a capability, and none is defined (terminfo uses more than 2 characters) and lesskey doesn't have a way to set the value. As I read it, you can only get to those word-shifts using the escape+key stuff.

                – Thomas Dickey
                Mar 16 at 0:32











              • The noaction approach looks promising. lesskey doesn't like using the noaction action within a #line-edit section, I assume because there is no entry in editnames. There is a code EC_NOACTION which is used here but not assigned anywhere.

                – David Robertson
                Mar 18 at 12:57















              1














              less is a termcap application, using the termcap interface to obtain all of the information it "knows" about a given terminal. Unless its developer introduces some hard-coded behavior (as done in a very few programs which I won't mention), less will provide no support for those key combinations because they are not standard features (see for instance the termcap column of the capabilities listed in ncurses' terminfo(5)), and have no 2-character names assigned to them (see the terminal database for a summary of extensions).



              By the way, referring to my answer and taking a quick look at less's source-code, I do not see anything that corresponds to left/right word movement (unless that is the intended meaning of the left/right shift A_LSHIFT and A_RSHIFT). git blame says those as well as the manual page comment about "word" date back to 2007 (version 394). These look more promising (from 2016):



               SK(SK_CTL_RIGHT_ARROW),0, A_RRSHIFT,
              SK(SK_CTL_LEFT_ARROW),0, A_LLSHIFT


              but the checkin comment only says



              commit e5c195113d1666ac506ea3f65545d436d96fe099
              Author: Mark Nudelman <markn@greenwoodsoftware.com>
              Date: Sat Oct 22 15:25:44 2016 +0000

              New commands ESC- and ESC- to shift to start/end of displayed lines.


              Reading the code (in command.c) for shifting, I did not see anything that disagrees with the conclusion that less scrolls by columns (single characters) rather than words, but OP's comment pointed to these:



               ESC,SK(SK_LEFT_ARROW),0, EC_W_LEFT, /* ESC LEFTARROW */
              SK(SK_CTL_LEFT_ARROW),0, EC_W_LEFT, /* CTRL-LEFTARROW */
              ESC,'w',0, EC_W_RIGHT, /* ESC w */
              ESC,SK(SK_RIGHT_ARROW),0, EC_W_RIGHT, /* ESC RIGHTARROW */
              SK(SK_CTL_RIGHT_ARROW),0, EC_W_RIGHT, /* CTRL-RIGHTARROW */


              which use space as a delimiter for "words". Perhaps when the developer made those changes, he had in mind imitating vi, which can do both (though vi's words are delimited differently).



              The suggested *Escapeleft-arrow, etc., are provided using these lines from the table:



               ESC,SK(SK_LEFT_ARROW),0, EC_W_LEFT, /* ESC LEFTARROW */

              ESC,SK(SK_RIGHT_ARROW),0, EC_W_RIGHT, /* ESC RIGHTARROW */


              However—the current program does not contain any assignments using those SK_CTL_RIGHT_ARROW or SK_CTL_LEFT_ARROW symbols. That would be done in lesskey, e.g., in this case statement (or close by, at any rate):



               switch (*++p)

              case 'u': ch = SK_UP_ARROW; break;
              case 'd': ch = SK_DOWN_ARROW; break;
              case 'r': ch = SK_RIGHT_ARROW; break;
              case 'l': ch = SK_LEFT_ARROW; break;
              case 'U': ch = SK_PAGE_UP; break;
              case 'D': ch = SK_PAGE_DOWN; break;
              case 'h': ch = SK_HOME; break;
              case 'e': ch = SK_END; break;
              case 'x': ch = SK_DELETE; break;
              default:
              error("illegal char after \k", NULL_PARG);
              *pp = p+1;
              return ("");



              Without assignments in the code, those are hard-coded only, not configurable.



              The MSDOS / OS/2 configurations differ from the Unix one by having a (hard-coded) table of key codes:



              #if MSDOS_COMPILER || OS2
              static char k_right = '340', PCK_RIGHT, 0 ;
              static char k_left = '340', PCK_LEFT, 0 ;
              static char k_ctl_right = '340', PCK_CTL_RIGHT, 0 ;
              static char k_ctl_left = '340', PCK_CTL_LEFT, 0 ;


              and provides for using those in a case statement:



              #if MSDOS_COMPILER || OS2
              case SK_INSERT:
              s = k_insert;
              break;
              case SK_CTL_LEFT_ARROW:
              s = k_ctl_left;
              break;
              case SK_CTL_RIGHT_ARROW:
              s = k_ctl_right;
              break;


              (note: still no assignments, hence the cases are unused), while in the termcap configuration, those symbols are not used at all. (termcap is "extensible", and if you took the trouble to invent 2-character mnemonics for your own use and modify less to implement those cases, it would do what you want).



              Revisiting lesskey's manual page, it says this:




              An action may be followed by an "extra" string. When such a command is
              entered while running less, the action is performed, and then the extra
              string is parsed, just as if it were typed in to less. This feature
              can be used in certain cases to extend the functionality of a command.
              For example, see the "{" and ":t" commands in the example below. The
              extra string has a special meaning for the "quit" action: when less
              quits, first character of the extra string is used as its exit status.




              That implies that you could do something like this:



              e[1;5D noaction ee[D
              e[1;5C noaction ee[C


              to map into an extra string which uses the predefined word-shift.






              share|improve this answer

























              • Esc ← and Esc → navigate by what looks like words to me (as in JdeBP's answer). Note that there are separate binds and commands for the "text buffer" you get at the bottom of less, and in particular EC_W_LEFT which seems promising. Perhaps I can use lesskey(1) to make less treat whatever input it is getting as if it was getting Ctrl-← and Ctrl-→; I will investigate.

                – David Robertson
                Mar 15 at 22:26












              • I see - will update

                – Thomas Dickey
                Mar 15 at 22:30











              • Thank you for your thoroughness. Do I understand you and the source code correctly? 1. There is no way for lesskey to generate a SK_SPECIAL_KEY string whose second (i.e. index 1) character is SK_CTL_LEFT_ARROW. This is because there is no standard termcap 2-character mnemonic for the Ctrl-← chord. 2. This means there is no way to "hit" the SK(SK_CTL_LEFT_ARROW),0, EC_W_LEFT, /* CTRL-LEFTARROW */ entry in the edittable which in order to trigger the EC_W_LEFT "action".

                – David Robertson
                Mar 15 at 23:31












              • right less doesn't ask tgetstr for a capability, and none is defined (terminfo uses more than 2 characters) and lesskey doesn't have a way to set the value. As I read it, you can only get to those word-shifts using the escape+key stuff.

                – Thomas Dickey
                Mar 16 at 0:32











              • The noaction approach looks promising. lesskey doesn't like using the noaction action within a #line-edit section, I assume because there is no entry in editnames. There is a code EC_NOACTION which is used here but not assigned anywhere.

                – David Robertson
                Mar 18 at 12:57













              1












              1








              1







              less is a termcap application, using the termcap interface to obtain all of the information it "knows" about a given terminal. Unless its developer introduces some hard-coded behavior (as done in a very few programs which I won't mention), less will provide no support for those key combinations because they are not standard features (see for instance the termcap column of the capabilities listed in ncurses' terminfo(5)), and have no 2-character names assigned to them (see the terminal database for a summary of extensions).



              By the way, referring to my answer and taking a quick look at less's source-code, I do not see anything that corresponds to left/right word movement (unless that is the intended meaning of the left/right shift A_LSHIFT and A_RSHIFT). git blame says those as well as the manual page comment about "word" date back to 2007 (version 394). These look more promising (from 2016):



               SK(SK_CTL_RIGHT_ARROW),0, A_RRSHIFT,
              SK(SK_CTL_LEFT_ARROW),0, A_LLSHIFT


              but the checkin comment only says



              commit e5c195113d1666ac506ea3f65545d436d96fe099
              Author: Mark Nudelman <markn@greenwoodsoftware.com>
              Date: Sat Oct 22 15:25:44 2016 +0000

              New commands ESC- and ESC- to shift to start/end of displayed lines.


              Reading the code (in command.c) for shifting, I did not see anything that disagrees with the conclusion that less scrolls by columns (single characters) rather than words, but OP's comment pointed to these:



               ESC,SK(SK_LEFT_ARROW),0, EC_W_LEFT, /* ESC LEFTARROW */
              SK(SK_CTL_LEFT_ARROW),0, EC_W_LEFT, /* CTRL-LEFTARROW */
              ESC,'w',0, EC_W_RIGHT, /* ESC w */
              ESC,SK(SK_RIGHT_ARROW),0, EC_W_RIGHT, /* ESC RIGHTARROW */
              SK(SK_CTL_RIGHT_ARROW),0, EC_W_RIGHT, /* CTRL-RIGHTARROW */


              which use space as a delimiter for "words". Perhaps when the developer made those changes, he had in mind imitating vi, which can do both (though vi's words are delimited differently).



              The suggested *Escapeleft-arrow, etc., are provided using these lines from the table:



               ESC,SK(SK_LEFT_ARROW),0, EC_W_LEFT, /* ESC LEFTARROW */

              ESC,SK(SK_RIGHT_ARROW),0, EC_W_RIGHT, /* ESC RIGHTARROW */


              However—the current program does not contain any assignments using those SK_CTL_RIGHT_ARROW or SK_CTL_LEFT_ARROW symbols. That would be done in lesskey, e.g., in this case statement (or close by, at any rate):



               switch (*++p)

              case 'u': ch = SK_UP_ARROW; break;
              case 'd': ch = SK_DOWN_ARROW; break;
              case 'r': ch = SK_RIGHT_ARROW; break;
              case 'l': ch = SK_LEFT_ARROW; break;
              case 'U': ch = SK_PAGE_UP; break;
              case 'D': ch = SK_PAGE_DOWN; break;
              case 'h': ch = SK_HOME; break;
              case 'e': ch = SK_END; break;
              case 'x': ch = SK_DELETE; break;
              default:
              error("illegal char after \k", NULL_PARG);
              *pp = p+1;
              return ("");



              Without assignments in the code, those are hard-coded only, not configurable.



              The MSDOS / OS/2 configurations differ from the Unix one by having a (hard-coded) table of key codes:



              #if MSDOS_COMPILER || OS2
              static char k_right = '340', PCK_RIGHT, 0 ;
              static char k_left = '340', PCK_LEFT, 0 ;
              static char k_ctl_right = '340', PCK_CTL_RIGHT, 0 ;
              static char k_ctl_left = '340', PCK_CTL_LEFT, 0 ;


              and provides for using those in a case statement:



              #if MSDOS_COMPILER || OS2
              case SK_INSERT:
              s = k_insert;
              break;
              case SK_CTL_LEFT_ARROW:
              s = k_ctl_left;
              break;
              case SK_CTL_RIGHT_ARROW:
              s = k_ctl_right;
              break;


              (note: still no assignments, hence the cases are unused), while in the termcap configuration, those symbols are not used at all. (termcap is "extensible", and if you took the trouble to invent 2-character mnemonics for your own use and modify less to implement those cases, it would do what you want).



              Revisiting lesskey's manual page, it says this:




              An action may be followed by an "extra" string. When such a command is
              entered while running less, the action is performed, and then the extra
              string is parsed, just as if it were typed in to less. This feature
              can be used in certain cases to extend the functionality of a command.
              For example, see the "{" and ":t" commands in the example below. The
              extra string has a special meaning for the "quit" action: when less
              quits, first character of the extra string is used as its exit status.




              That implies that you could do something like this:



              e[1;5D noaction ee[D
              e[1;5C noaction ee[C


              to map into an extra string which uses the predefined word-shift.






              share|improve this answer















              less is a termcap application, using the termcap interface to obtain all of the information it "knows" about a given terminal. Unless its developer introduces some hard-coded behavior (as done in a very few programs which I won't mention), less will provide no support for those key combinations because they are not standard features (see for instance the termcap column of the capabilities listed in ncurses' terminfo(5)), and have no 2-character names assigned to them (see the terminal database for a summary of extensions).



              By the way, referring to my answer and taking a quick look at less's source-code, I do not see anything that corresponds to left/right word movement (unless that is the intended meaning of the left/right shift A_LSHIFT and A_RSHIFT). git blame says those as well as the manual page comment about "word" date back to 2007 (version 394). These look more promising (from 2016):



               SK(SK_CTL_RIGHT_ARROW),0, A_RRSHIFT,
              SK(SK_CTL_LEFT_ARROW),0, A_LLSHIFT


              but the checkin comment only says



              commit e5c195113d1666ac506ea3f65545d436d96fe099
              Author: Mark Nudelman <markn@greenwoodsoftware.com>
              Date: Sat Oct 22 15:25:44 2016 +0000

              New commands ESC- and ESC- to shift to start/end of displayed lines.


              Reading the code (in command.c) for shifting, I did not see anything that disagrees with the conclusion that less scrolls by columns (single characters) rather than words, but OP's comment pointed to these:



               ESC,SK(SK_LEFT_ARROW),0, EC_W_LEFT, /* ESC LEFTARROW */
              SK(SK_CTL_LEFT_ARROW),0, EC_W_LEFT, /* CTRL-LEFTARROW */
              ESC,'w',0, EC_W_RIGHT, /* ESC w */
              ESC,SK(SK_RIGHT_ARROW),0, EC_W_RIGHT, /* ESC RIGHTARROW */
              SK(SK_CTL_RIGHT_ARROW),0, EC_W_RIGHT, /* CTRL-RIGHTARROW */


              which use space as a delimiter for "words". Perhaps when the developer made those changes, he had in mind imitating vi, which can do both (though vi's words are delimited differently).



              The suggested *Escapeleft-arrow, etc., are provided using these lines from the table:



               ESC,SK(SK_LEFT_ARROW),0, EC_W_LEFT, /* ESC LEFTARROW */

              ESC,SK(SK_RIGHT_ARROW),0, EC_W_RIGHT, /* ESC RIGHTARROW */


              However—the current program does not contain any assignments using those SK_CTL_RIGHT_ARROW or SK_CTL_LEFT_ARROW symbols. That would be done in lesskey, e.g., in this case statement (or close by, at any rate):



               switch (*++p)

              case 'u': ch = SK_UP_ARROW; break;
              case 'd': ch = SK_DOWN_ARROW; break;
              case 'r': ch = SK_RIGHT_ARROW; break;
              case 'l': ch = SK_LEFT_ARROW; break;
              case 'U': ch = SK_PAGE_UP; break;
              case 'D': ch = SK_PAGE_DOWN; break;
              case 'h': ch = SK_HOME; break;
              case 'e': ch = SK_END; break;
              case 'x': ch = SK_DELETE; break;
              default:
              error("illegal char after \k", NULL_PARG);
              *pp = p+1;
              return ("");



              Without assignments in the code, those are hard-coded only, not configurable.



              The MSDOS / OS/2 configurations differ from the Unix one by having a (hard-coded) table of key codes:



              #if MSDOS_COMPILER || OS2
              static char k_right = '340', PCK_RIGHT, 0 ;
              static char k_left = '340', PCK_LEFT, 0 ;
              static char k_ctl_right = '340', PCK_CTL_RIGHT, 0 ;
              static char k_ctl_left = '340', PCK_CTL_LEFT, 0 ;


              and provides for using those in a case statement:



              #if MSDOS_COMPILER || OS2
              case SK_INSERT:
              s = k_insert;
              break;
              case SK_CTL_LEFT_ARROW:
              s = k_ctl_left;
              break;
              case SK_CTL_RIGHT_ARROW:
              s = k_ctl_right;
              break;


              (note: still no assignments, hence the cases are unused), while in the termcap configuration, those symbols are not used at all. (termcap is "extensible", and if you took the trouble to invent 2-character mnemonics for your own use and modify less to implement those cases, it would do what you want).



              Revisiting lesskey's manual page, it says this:




              An action may be followed by an "extra" string. When such a command is
              entered while running less, the action is performed, and then the extra
              string is parsed, just as if it were typed in to less. This feature
              can be used in certain cases to extend the functionality of a command.
              For example, see the "{" and ":t" commands in the example below. The
              extra string has a special meaning for the "quit" action: when less
              quits, first character of the extra string is used as its exit status.




              That implies that you could do something like this:



              e[1;5D noaction ee[D
              e[1;5C noaction ee[C


              to map into an extra string which uses the predefined word-shift.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Mar 16 at 13:55

























              answered Mar 15 at 22:00









              Thomas DickeyThomas Dickey

              54.3k5106181




              54.3k5106181












              • Esc ← and Esc → navigate by what looks like words to me (as in JdeBP's answer). Note that there are separate binds and commands for the "text buffer" you get at the bottom of less, and in particular EC_W_LEFT which seems promising. Perhaps I can use lesskey(1) to make less treat whatever input it is getting as if it was getting Ctrl-← and Ctrl-→; I will investigate.

                – David Robertson
                Mar 15 at 22:26












              • I see - will update

                – Thomas Dickey
                Mar 15 at 22:30











              • Thank you for your thoroughness. Do I understand you and the source code correctly? 1. There is no way for lesskey to generate a SK_SPECIAL_KEY string whose second (i.e. index 1) character is SK_CTL_LEFT_ARROW. This is because there is no standard termcap 2-character mnemonic for the Ctrl-← chord. 2. This means there is no way to "hit" the SK(SK_CTL_LEFT_ARROW),0, EC_W_LEFT, /* CTRL-LEFTARROW */ entry in the edittable which in order to trigger the EC_W_LEFT "action".

                – David Robertson
                Mar 15 at 23:31












              • right less doesn't ask tgetstr for a capability, and none is defined (terminfo uses more than 2 characters) and lesskey doesn't have a way to set the value. As I read it, you can only get to those word-shifts using the escape+key stuff.

                – Thomas Dickey
                Mar 16 at 0:32











              • The noaction approach looks promising. lesskey doesn't like using the noaction action within a #line-edit section, I assume because there is no entry in editnames. There is a code EC_NOACTION which is used here but not assigned anywhere.

                – David Robertson
                Mar 18 at 12:57

















              • Esc ← and Esc → navigate by what looks like words to me (as in JdeBP's answer). Note that there are separate binds and commands for the "text buffer" you get at the bottom of less, and in particular EC_W_LEFT which seems promising. Perhaps I can use lesskey(1) to make less treat whatever input it is getting as if it was getting Ctrl-← and Ctrl-→; I will investigate.

                – David Robertson
                Mar 15 at 22:26












              • I see - will update

                – Thomas Dickey
                Mar 15 at 22:30











              • Thank you for your thoroughness. Do I understand you and the source code correctly? 1. There is no way for lesskey to generate a SK_SPECIAL_KEY string whose second (i.e. index 1) character is SK_CTL_LEFT_ARROW. This is because there is no standard termcap 2-character mnemonic for the Ctrl-← chord. 2. This means there is no way to "hit" the SK(SK_CTL_LEFT_ARROW),0, EC_W_LEFT, /* CTRL-LEFTARROW */ entry in the edittable which in order to trigger the EC_W_LEFT "action".

                – David Robertson
                Mar 15 at 23:31












              • right less doesn't ask tgetstr for a capability, and none is defined (terminfo uses more than 2 characters) and lesskey doesn't have a way to set the value. As I read it, you can only get to those word-shifts using the escape+key stuff.

                – Thomas Dickey
                Mar 16 at 0:32











              • The noaction approach looks promising. lesskey doesn't like using the noaction action within a #line-edit section, I assume because there is no entry in editnames. There is a code EC_NOACTION which is used here but not assigned anywhere.

                – David Robertson
                Mar 18 at 12:57
















              Esc ← and Esc → navigate by what looks like words to me (as in JdeBP's answer). Note that there are separate binds and commands for the "text buffer" you get at the bottom of less, and in particular EC_W_LEFT which seems promising. Perhaps I can use lesskey(1) to make less treat whatever input it is getting as if it was getting Ctrl-← and Ctrl-→; I will investigate.

              – David Robertson
              Mar 15 at 22:26






              Esc ← and Esc → navigate by what looks like words to me (as in JdeBP's answer). Note that there are separate binds and commands for the "text buffer" you get at the bottom of less, and in particular EC_W_LEFT which seems promising. Perhaps I can use lesskey(1) to make less treat whatever input it is getting as if it was getting Ctrl-← and Ctrl-→; I will investigate.

              – David Robertson
              Mar 15 at 22:26














              I see - will update

              – Thomas Dickey
              Mar 15 at 22:30





              I see - will update

              – Thomas Dickey
              Mar 15 at 22:30













              Thank you for your thoroughness. Do I understand you and the source code correctly? 1. There is no way for lesskey to generate a SK_SPECIAL_KEY string whose second (i.e. index 1) character is SK_CTL_LEFT_ARROW. This is because there is no standard termcap 2-character mnemonic for the Ctrl-← chord. 2. This means there is no way to "hit" the SK(SK_CTL_LEFT_ARROW),0, EC_W_LEFT, /* CTRL-LEFTARROW */ entry in the edittable which in order to trigger the EC_W_LEFT "action".

              – David Robertson
              Mar 15 at 23:31






              Thank you for your thoroughness. Do I understand you and the source code correctly? 1. There is no way for lesskey to generate a SK_SPECIAL_KEY string whose second (i.e. index 1) character is SK_CTL_LEFT_ARROW. This is because there is no standard termcap 2-character mnemonic for the Ctrl-← chord. 2. This means there is no way to "hit" the SK(SK_CTL_LEFT_ARROW),0, EC_W_LEFT, /* CTRL-LEFTARROW */ entry in the edittable which in order to trigger the EC_W_LEFT "action".

              – David Robertson
              Mar 15 at 23:31














              right less doesn't ask tgetstr for a capability, and none is defined (terminfo uses more than 2 characters) and lesskey doesn't have a way to set the value. As I read it, you can only get to those word-shifts using the escape+key stuff.

              – Thomas Dickey
              Mar 16 at 0:32





              right less doesn't ask tgetstr for a capability, and none is defined (terminfo uses more than 2 characters) and lesskey doesn't have a way to set the value. As I read it, you can only get to those word-shifts using the escape+key stuff.

              – Thomas Dickey
              Mar 16 at 0:32













              The noaction approach looks promising. lesskey doesn't like using the noaction action within a #line-edit section, I assume because there is no entry in editnames. There is a code EC_NOACTION which is used here but not assigned anywhere.

              – David Robertson
              Mar 18 at 12:57





              The noaction approach looks promising. lesskey doesn't like using the noaction action within a #line-edit section, I assume because there is no entry in editnames. There is a code EC_NOACTION which is used here but not assigned anywhere.

              – David Robertson
              Mar 18 at 12:57











              0














              I managed to get this working in the end. (I contacted less's author, whose response pointed out that I was making things a little more complicated than they needed to be.)



              Here's the lesskey configuration file I ended up using.



              #! /usr/bin/env lesskey
              #line-edit
              e[1;5D word-left
              e[1;5C word-right
              e[3;5~ word-delete


              Running lesskey on this file and starting a new instance made Ctrl-← and Ctrl-→ navigate by (space-delimited?) word, and Ctrl-Delete delete rightwards to the end of the current word. I guess the downside of this solution is that it's hard-coded to the particular escape sequences generated by my terminal emulator; the other answers explain why a generic "control+arrow key" mechanism wasn't possible.






              share|improve this answer



























                0














                I managed to get this working in the end. (I contacted less's author, whose response pointed out that I was making things a little more complicated than they needed to be.)



                Here's the lesskey configuration file I ended up using.



                #! /usr/bin/env lesskey
                #line-edit
                e[1;5D word-left
                e[1;5C word-right
                e[3;5~ word-delete


                Running lesskey on this file and starting a new instance made Ctrl-← and Ctrl-→ navigate by (space-delimited?) word, and Ctrl-Delete delete rightwards to the end of the current word. I guess the downside of this solution is that it's hard-coded to the particular escape sequences generated by my terminal emulator; the other answers explain why a generic "control+arrow key" mechanism wasn't possible.






                share|improve this answer

























                  0












                  0








                  0







                  I managed to get this working in the end. (I contacted less's author, whose response pointed out that I was making things a little more complicated than they needed to be.)



                  Here's the lesskey configuration file I ended up using.



                  #! /usr/bin/env lesskey
                  #line-edit
                  e[1;5D word-left
                  e[1;5C word-right
                  e[3;5~ word-delete


                  Running lesskey on this file and starting a new instance made Ctrl-← and Ctrl-→ navigate by (space-delimited?) word, and Ctrl-Delete delete rightwards to the end of the current word. I guess the downside of this solution is that it's hard-coded to the particular escape sequences generated by my terminal emulator; the other answers explain why a generic "control+arrow key" mechanism wasn't possible.






                  share|improve this answer













                  I managed to get this working in the end. (I contacted less's author, whose response pointed out that I was making things a little more complicated than they needed to be.)



                  Here's the lesskey configuration file I ended up using.



                  #! /usr/bin/env lesskey
                  #line-edit
                  e[1;5D word-left
                  e[1;5C word-right
                  e[3;5~ word-delete


                  Running lesskey on this file and starting a new instance made Ctrl-← and Ctrl-→ navigate by (space-delimited?) word, and Ctrl-Delete delete rightwards to the end of the current word. I guess the downside of this solution is that it's hard-coded to the particular escape sequences generated by my terminal emulator; the other answers explain why a generic "control+arrow key" mechanism wasn't possible.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 23 at 11:27









                  David RobertsonDavid Robertson

                  1064




                  1064



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • 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%2funix.stackexchange.com%2fquestions%2f506469%2fwhy-do-control-left-and-control-right-arrow-keys-not-navigate-by-word-in-less%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

                      How to check contact read email or not when send email to Individual?

                      Bahrain

                      Postfix configuration issue with fips on centos 7; mailgun relay