I'm using less to parse HTTP access logs. I want to view everything neatly on single lines, so I'm using -S.

The problem I have is that the first third of my terminal window is taken up with metadata that I don't care about. When I use my arrow keys to scroll right, I find that it scrolls past the start of the information that I do care about!

I could just delete the start of each line, but I don't know if I may need that data in the future, and I'd rather not have to maintain separate files or run a script each time I want to view some logs.


This line:

access.log00002: - USER_X [07/Nov/2013:16:50:50 +0000] "GET /some/long/URL"

Would scroll to: ng/URL"


Is there a way I can scroll in smaller increments, either by character or by word?

4 Answers 4


The only horizontal scrolling commands scroll by half a screenful, but you can pass a numeric argument to specify the number of characters, e.g. typing 4 Right scrolls to the right by 4 characters. Less doesn't really have a notion of “current line” and doesn't split a line into words, so there's no way to scroll by a word at a time.

You can define a command that scrolls by a fixed number of characters. For example, if you want Shift+Left and Shift+Right to scroll by 4 characters at a time:

  1. Determine the control sequences that your terminal sends for these key combinations. Terminals send a sequence of bytes that begin with the escape (which can be written \e, \033, ^[ in various contexts) character for function keys and keychords. Press Ctrl+V Shift+Left at a shell prompt: this inserts the escape character literally (you'll see ^[ on the screen) instead of it being processed by your shell, and inserts the rest of the escape sequence. A common setup has Shift+Left and Shift+Right send \eO2D and \eO2C respectively.

  2. Create a file called ~/.lesskey and add the following lines (adjust if your terminal sends different escape sequences):

    \eO2D noaction 4\e(
    \eO2C noaction 4\e)
    \eOD noaction 40\e(
    \eOC noaction 40\e)

    In addition to defining bindings for Shift+arrow, you may want to define bindings for arrow alone, because motion commands reuse the numeric values from the last call. Adjust 40 to your customary terminal width. There doesn't appear to be a way to say “now use the terminal width again, whatever it is at this moment”. A downside of these bindings is that you lose the ability to pass a numeric argument to Left and Right (you can still pass a numeric argument to Esc ( and Esc )).

Then run lesskey, which converts the human-readable ~/.lesskey into a binary file ~/.less that less reads when it starts.

  • Very nice explanation, thanks for the details. It seems the normal scrolling with Left/Right get switched to 4 characters also after using Shift + Left/Right, any workaround for this?
    – Slim
    Commented Jul 26, 2020 at 8:36
  • 1
    @Slim Not easily I think. Commented Jul 26, 2020 at 19:47
  • looks like your edit mentioning binding arrow is good enough (for me at least). thanks!
    – Slim
    Commented Jul 26, 2020 at 20:02

You can use option "-# " to set the number of columns for horizontal scrolling.

From man page:

-# or --shift
Specifies the default number of positions to scroll horizontally in the RIGHTARROW and LEFTARROW commands. If the number specified is zero, it sets the default number of positions to one half of the screen width.

Example (set horizontal scrolling to 10 columns):

less -S -# 10 my_file

  • Is there posibility to add this option to some configuration file so I don't have to pass -# 1 option everytime i type the command? Commented Feb 21, 2019 at 11:39
  • 3
    @Trismegistos Yes, you can set the environment variable in your ~/.bashrc with export LESS="-# 1"
    – wisbucky
    Commented Apr 9, 2019 at 21:54
  • 2
    You can also set a percentage of screen width if the number starts with a decimal point. For example, -# .25 would scroll by 1/4 of the screen width.
    – wisbucky
    Commented Apr 9, 2019 at 21:56
  • 1
    This answer has the added benefit of being easy to use in an open less, by using the command - and then specifying #, less will prompt for Horizontal shift: and set the user provided value for the current session. It really ought to be the accepted answer.
    – zrvan
    Commented Feb 24, 2022 at 10:33

Type a number, which is the number of columns you want to scroll to, then hit the arrow key.

Source: List of useful `less` functions


An alternative is to use the most pager.

In most, no-wrap (-S) is the default and Right scrolls one column to the right instead of a half screen. Use > or Tab to scroll faster.

Another alternative is the w3m pager (also one of the best terminal web browsers) where you can use <, > as well, and ,, . for finer-grain scrolling (same keys on qwerty keyboards).

  • This is not true. More is wrapping be default and there is no -S option. Commented Feb 21, 2019 at 11:48
  • 2
    @Trismegistos, I'm not talking about more (for which there are dozens of implementations), but about most (by John E. Davis, I'm not aware of any other implementation). Commented Feb 21, 2019 at 12:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .