Incremental searching with the `less` utility

9

4

Does less have an incremental search?

I'm on xubuntu.

hasen

Posted 2010-02-26T05:00:39.970

Reputation: 4 556

Answers

6

Unfortunately the less pager does not have this functionality. The only search options available are / for a forward search, and ? for a backward search.

John T

Posted 2010-02-26T05:00:39.970

Reputation: 149 037

someone should implement that ability then ;) – hasen – 2010-02-26T06:23:13.657

according to the manpage: "n .. repeat previous search" ... isnt that incremental? – akira – 2010-02-26T07:20:56.290

2

Incremental usually means "search as you type". See http://www.codinghorror.com/blog/2005/10/search-if-it-isnt-incremental-its-excremental.html

– mrucci – 2010-02-26T16:28:42.110

4

You can use view (vim in read only mode) as a replacement for less.. vim has incremental search, just add:

set incsearch

to your .vimrc

user23307

Posted 2010-02-26T05:00:39.970

Reputation: 5 915

I know about it but can you pipe text to it? i.e. use it as a pager for other tools (such as git) – hasen – 2010-02-27T02:08:17.287

1looks like vim comes with a script for that.. export PAGER=/usr/share/vim/vim71/macros/less.sh or if you google 'vimpager' there is a supposedly better replacement.. git sort of has issues with it because of the terminal escape codes for color, but there might be an easy fix for that... – user23307 – 2010-02-27T11:04:59.540

I forgot about view – at. – 2010-02-27T23:55:11.980

0

I added incremental search to less and pushed it to a fork on GitHub.

Matt McClure

Posted 2010-02-26T05:00:39.970

Reputation: 283