How to look around conveniently?

I’m a neovim user who pokes in kakoune once in a while.

Currently my main beef with kak is that I can’t easily look around and read a source file. Examples:

  1. In Vim, I often look around by moving by a paragraph. That’s shift-[ in Vim and it’s not too bad. I can jump to the next code block. In kak, it seems to be accomplished by alt-a p, and I’m currently unsure how to go in the other direction. I tried alt-[ p and then I can go to the start of the current paragraph, but it’s very unwieldy for something I would use on a ragular basis!

  2. I don’t know how to move the screen around by a small amount. There’s CTRL-u and CTRL-d for scrolling half a screen. That’s it? I need some convenient ways to scroll. Some HTML files have no empty lines between them and scrolling by paragraph won’t work.

  3. When I have multiple selections, especially in a HTML file with long lines, I can’t conveniently scroll the screen to the start of the lines (left). I know about commands 'v’iew and 'g’oto, but goto drops selections while view only goes to the leftmost selection which can be far from line start.

  4. When I have

  1. “to next paragraph” in Kakoune is ]p and “to previous paragraph” is [p
    • Kakoune’s <a-a> and <a-i> are more like Vim’s va and vi, they select around the current cursor(s) rather than moving forward or backward
  2. You can scroll the screen up or down by a single line with vk or vj respectively, or just use the scroll-wheel on your mouse
  3. I recommend using Z to save the current selections as the default mark, then gh to move each cursor to the beginning of the line it’s on (causing the screen to scroll to keep them visible), then z to restore the saved selections
    • Kakoune believes very strongly that the currently-active cursor should never scroll off the screen, mostly because Vim has the same behaviour
    • 'g’oto doesn’t always drop selections; the movements that are relative to the current position of each cursor (gh, gi, gl) keep all the cursors, the movements that are relative to the buffer (gg, gk, gj, ge) or window (gt, gb, gc) cause all the cursors to pile up in those places, and then when duplicates are removed only one cursor remains
1 Like

I’ve mapped ]p to ]r which feels more convenient:

map global object r p
map global object R p

I personally like the to use the view menu (v key) to move around, especially when using it in locked mode (shift+v key)!

shift+v and then hold j to go down
shift+v and then hold l to go up

1 Like

I use C-d same as vim for half pages

See this thread for more ways to navigate paragraphs:

https://discuss.kakoune.com/t/key-mappings-for-navigating-paragraphs/1558

I have this and use it a lot

# navigate by paragraphs
map global normal <c-n>     ']pj;'
map global normal <c-p>     '[p;'

If you’re using a terminal that handles ambiguous keys, you could also set it to <c-j> and <c-k> which would make more sense.