Hacker News new | past | comments | ask | show | jobs | submit login

zt, zz and zb are great too. They redraw the screen so that the line the cursor is currently on becomes the top, middle, or bottom line of the window.



Other "z" commands (these are the ones I always get mixed up):

    :setlocal spell spelllang=en_us - turn on spell check
    z= - bring up list of suggestions
    zg - add word to dict
    zug - undo add to word
    zw - mark as wrong
    zuw - undo wrong
    :help fold
    zf<motion> - create fold (common motions '%', 'a{', 'a(' )
    zo - open fold
    zA - open folds recursively
    zc - close fold
    zd - forget fold
    zj - move to next fold
    zk - move to prev fold (up)


Some simple mnemonics might help you out.

  zg   g = Good word, add to personal dict
  zug  Undo Good word.
  zw   obviously, Wrong word.
  ...
  zo   Open
  zA   open All
  zc   Close
  zj   uses the same movement as the j key
  zk   ditto
Once you have the mnemonics sorted, sometimes you find you can remember the others because they are the ones "left out" of those with mnemonics, like zd doesn't have a mnemonic, so the command left over is "forget fold", so zd is that one. After a while, muscle memory takes over.


Yeah, I like the fold commands, which I barley discovered a few weeks ago. I typically do "set foldmethod=indent" then pres "zr" multiple times until I'm at the fold level I want. Then I can just do "zo" on the parts of code I'm interested in.


there's also

zR - Open all folds

zM - Close all folds

zO - Open all folds under the cursor recursively

zC - Close all folds under the cursor recursively

zX - Undo manually opened and closed folds: re-apply 'foldlevel'.


I'm a big fan of Ctrl-e and Ctrl-y which, despite being in the "one line at a time" category, are really useful for changing the context of the cursor a little bit without changing the cursor's line. I've even gone as far as to remap those to J and K.


thanks! I knew zz 'centers the screen'. you made it a lot clearer ;p




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: