Ever since Kakoune made the x key more predictable, I missed the easier way it provided to select new lines. However, I still prefer the new x behavior.
The solution was to either xJJJJ or JJJJx. This was good because it also worked upwards, by using K instead of J.
After some tweaking, I found a couple of mappings that are so good, I think they should even be hard-coded:
map -docstring 'extend lines downwards' global normal X %{<a-:>F<ret>x}
map -docstring 'extend lines upwards' global normal <a-X> %{<a-:><a-;><a-H>Kx}
I think this configuration makes a ton of sense and matches the behavior of other commands in Kakoune, such as / to search, ? to extend, and the alt- variants to do it backwards.
The right-hand-side of a mapping can use the %val{count} expansion to apply the active count to whichever parts of the mapping itās relevant for. Unfortunately it defaults to 0 rather than 1, but 0 is not a normal-mode command so if youāre just prefixing to a different normal-mode command it should be fine:
map -docstring 'cool j' global user j %{:exec "%val{count}j:echo cool!<lt>ret>"<ret>}
Test with 5<space>j.
Note: You need the :exec in the mapping so that %val{count} is not expanded until the mapping is executed, rather than when the mapping was defined.
This was useful after I upgraded Kakoune and my old configuration (which used the X command that seems to have disappeared) broke. In fact, I map "x" instead of "X" because I use this so much.
I was completely used to typing xx to select two lines and would have been lost without this.