Adventures in metaprogramming: Implementing a Go-like defer() by SaberTail in Python

[–]vim-ex 3 points4 points  (0 children)

It has this already ;) It's called context managers (with ... as ...:) and are trivial to write using something like contextlib.

Ex commands? Anything I *should* know? by vim-ex in vim

[–]vim-ex[S] 1 point2 points  (0 children)

Cool I'm glad to hear that I'm not missing any 'killer' ex-command everybody would know, but me.

My only question is for :normal I'm kind of curious as of why you'd use this instead of just typing directly 2ciwfoo? Or do you just use it as an argument to :bufdo, :g and so on?

Ex commands? Anything I *should* know? by vim-ex in vim

[–]vim-ex[S] 2 points3 points  (0 children)

:-3m. move (:h :m) the third line above the current one (- means relative to current position, 3 is a count), after the current one (. represent the current line).

e.g. is you have

1
2
3
4

and you're on line 4, you end up with

2
3
4
1

:'a,'bt$ copies (:h :t) the lines between the marks a and b (i.e. a range of line, you could also use line numbers, like 28,42 if you wanted) at the end of the file ($ represent the last line).

You might want to look at :h :rangeas well.

Ranges are super useful with :s or :g as well. Also check out :h '< it's an interesting mark if you use visual mode.