4 ms·
I can't tell whether or not you're trolling, but I'll bite. To provide a contrived example of the sort of editor macro capabilities (I believe) somezero was re
by ethagnawl 9y ago
I can't tell whether or not you're trolling, but I'll bite.
To provide a contrived example of the sort of editor macro capabilities (I believe) somezero was referring to: Imagine you have N lines of hashrocket style Ruby hashes (`{:foo => "bar"}`) and you want to convert all of them to JSON style hashes (`{foo: "bar"}`). In Vim, you can create a macro which records the keystrokes/commands used while massaging first hash (moving :s, removing =>s, etc.) and then replay that macro over any other hashes you want to change.
I just performed a very unscientific test of the example I've provided above and it took < 10 seconds to write/record and apply the macro to 100 hashes - all without touching the mouse or thinking too hard about what I was doing. I'd be interested to know 1) if a similar operation is possible using traditional GUI editors, 2) how long it takes, 3) whether or not the same operation can be performed without touching the mouse and 4) whether or not those "operations" can be shared.
- jokoon 9y agoCTRL H, remove all occurrences of ':', then replace '=>' by ':'. In python it's as simple as .replace().replace(). Oh and you don't need to learn that much to do it, or print some large VIM cheatsheet. > 4) whether or not those "operations" can be shared. Better even, those can be done in python. To be honest I prefer using basic tools and building my own when it really is necessary, instead of using complex ones, even if they are more powerful. Sometimes you can waste time coming up with good solutions that you will only use once.