Continuing the trend of short tips due to lots of work I have nowadays, here is one thing that bothered me for some time and how I fixed it.
I use Ivy and Counsel a lot. One of the functions I have even bound to an easily accessible key is counsel-rg
. Within it, I often use C-c C-o
, which is bound to ivy-occur
, which uses the string I have entered to create an occur buffer with all the matches shown. However, in some of the projects I work on, the lines in various files tend to be quite long (sometimes on the order of a few kilobytes!), and the occur
buffer is a bit unwieldy then. 99% of the time the first thing I did in it was to run toggle-truncate-lines
. One day, it occurred to me (lame pun intended, SCNR) that I should really make Emacs do that for me. A minute or two of searching for the right hook resulted in this snippet I have put in my init.el
:
(add-hook 'ivy-occur-grep-mode-hook (lambda () (toggle-truncate-lines 1)))
and now I’m a happier Ivy/Counsel user.