New answers tagged


The global command marks every line matching a pattern and executes a list of actions on them. Each action is separated by the pipe symbol, |. In :g/^/s/foo/bar/|+t+|-d the pattern is ^, so all the lines are marked. Then, three actions are executed on the marked lines: s/foo/bar/: substitute "foo" by "bar". +t+: Duplicate the next line. ...


It probably worked only on the current line. You need to specify a range to the substitute command, for example: :1,$s/\s//g There is a shortcut for the range that matches the entire file, which is %: :%s/\s//g See :help ranges.

Top 50 recent answers are included