Arbitrary multiple selections

I found myself wanting to rename a bunch of files, for which I use ranger and :bulkrename. This launches kakoune to edit the filenames.

Most of the changes were easy, but there was one step where I wanted to have multiple selections, but without following any obvious pattern. Does kakoune have a command for “select here, and here, and here, and here”?

Example:

202301-My Bank Statement.pdf
202212-My Bank Statement.pdf
202211-My Bank Statement.pdf
202210-My Bank Statement.pdf
202209-My Bank Statement.pdf
202208-My Bank Statement.pdf
202207-My Bank Statement.pdf
202206-My Bank Statement.pdf

How can I select all the months with 31 days so that I can then do i 3 1 for those months without adding any text for the months with 30 days?

Thanks.

The easiest way to add selections at arbitrary places is to ctrl-click anywhere in the buffer to add a new cursor at that point.

If you don’t have a mouse or have disabled Kakoune’s mouse support, the second easiest way is:

  • move to the first location, store it with Z
  • move to the second location, add it to the stored selections with <a-Z>a
  • repeat for all additional selections
  • restore all the stored selections at once with z
4 Likes

Excellent! This is exactly what I was looking for, so thank you.