Thursday, December 12, 2013

Vim - Reminders part 1

On this page I show some commands which you might forgot. For me it's to quickly look up how to do it again. So let's start.



Fold
  • zf{motion} = create fold
  • zo = open fold
  • zc = close fold
  • zj = go to next fold
  • zk = go to previous fold
  • zM = close all folds
  • zR = open all folds
  • zd = delete fold
  • za = toggel fold to open/close
  • zfa} = fold within curly brackets

Substitute
You can substitute certain words from the command mode, like this:
:%s/foo/bar/g
where all occurrence of word foo is substituted by bar in the whole file (%)
:%s/foo/bar/gc
adding 'c' will Vim asks for confirmation.
:.s/foo/bar/
will do this for the current line
:10s/foo/bar/
will do this for line number 10

No comments:

Post a Comment

NSNotification example