:g/^/exec "s/^/".strpart(line(".")." ", 0, 4) This runs the exec command on every line that matches /^/ (matches every line). The exec command takes a string and executes it as if it were typed in. line(".")." " number of the current line plus four spaces strpart("123 ", 0, 4) first four characters ("123 ") "s/^/123 " substitute the beginning of the line with "123 "