News for hackers. Stuff that matters.
Re:Vim: ZZ and zz: Do you know the difference? by pawelduda on Monday January 09, 2023 @05:03AM (#34308654)
Quick pro tip for zz, I pair zz with search/jumps, so the next match/jump location ends up centered.

Edit: more elegant solution https://news.ycombinator.com/item?id=34308688

  " Center screen on next/previous selection.
  nmap n /<CR>zz
  nmap N ?<CR>zz
  " Last and next jump should center too.
  nnoremap <C-o> <C-o>zz
  nnoremap <C-i> <C-i>zz
Re:Vim: ZZ and zz: Do you know the difference? by vault on Monday January 09, 2023 @05:07AM (#34308688)
The source you copied this from offers a simpler version:

  " Center screen on next/previous selection.
  nnoremap n nzz
  nnoremap N Nzz
  " Last and next jump should center too.
  nnoremap <C-o> <C-o>zz
  nnoremap <C-i> <C-i>zz
Re:Vim: ZZ and zz: Do you know the difference? by pawelduda on Monday January 09, 2023 @05:14AM (#34308727)
I copied it from my vimrc, I don't recall after many years where it came from :)
Re:Vim: ZZ and zz: Do you know the difference? by 2mur on Monday January 09, 2023 @10:46AM (#34311593)
I pair it with half-page ups/downs. The cursor is always on the center line for easier vertical movements after scrolling

nnoremap <C-d> <C-d>zz

nnoremap <C-u> <C-u>zz

Re:Vim: ZZ and zz: Do you know the difference? by fleekonpoint on Monday January 09, 2023 @01:49PM (#34314306)
Very cool!