Hacker News new | ask | show | jobs
by joslin01 2958 days ago
I'm guessing you mean "dd" and "yy" to delete/yank lines. "x" deletes a single character, what you mean extract a line?

If you learn "w", which just means advance by a word, you can combine them with your existing knowledge for much better use. So "dw" becomes delete a word, or "d3w" means delete next 3 words. "v" is also useful in conjunction with "w" / "b".

2 comments

I would either:

* SHIFT+V to highlight a line, `d` to delete * `:d` to delete the current line

Not experimented with `dd` (or `yy`).

SHIFT+V + 'd' is a longer way of doing 'dd'. SHIFT+V + 'y' is a longer way of doing 'yy'.

You can also delete and yank multiple lines by using 'd2d' (delete two lines) or similar. You can also delete lines upwards by using a movement command like 'dk' (or 'd2k' if you want to delete the two lines above).

I quite like the visual confirmation that I'm not about to do something stupid, to me that's worth paying the cost of an extra key.

And I jump between enough systems that I doubt myself with stuff like: is `d1d` or `d0d` or `dd` equal?

'[d|c]iw', to delete/change the word your inside of is another small improvement.
I'm also a big fan of `ci[(|'|"]` to change all the text between a pair of delimiters. I can type `ci"` while my cursor's at the start of the line, and it'll jump to the first set of double quotes, remove the text that's currently between them, and enter edit mode.
You can also use `cib` to change text between braces and `ciB` to change text between curly braces.
Isn't this part of vim-surround?

http://github.com/tpope/vim-surround

I'm fairly sure that works out of the box. I get annoyed when another editor's VIM mode doesn't properly emulate it.