News for hackers. Stuff that matters.
Re:Seven habits of effective text editing (2000) by somezero on Tuesday October 24, 2017 @02:12AM (#15539602)
Editor macros are one of the reasons you'll want to use Emacs or Vim instead of notepad. They're just like linguistic macros: You'll never know you need one if you haven't used one. However unlike linguistic macros -where choosing to use one is much more of a design decision than a necessary step- the only viable alternative to editor macros are doing their job by hand.
Re:Seven habits of effective text editing (2000) by jokoon on Tuesday October 24, 2017 @08:22AM (#15541014)
I guess this is just pre-filled if/else/while/for loops snippets? ST3 does it too I guess.

I don't really think those are very useful, they don't save you that much time. Your editor cannot guess what kind of code you precisely want to type. Or maybe you're using a language that has too much syntax. Or maybe you're typing too much code, and that can be a bad thing too.

Re:Seven habits of effective text editing (2000) by somezero on Tuesday October 24, 2017 @04:38PM (#15545038)
As others pointed out, snippets are not macros. And in addition using macros for simple text transformation that was pointed out by @ethagnawl, below are other ideas all of which I use on an almost daily basis:

1. Macros can be shared with different buffers which enables you to a) do complicated transformations in a step by step manner and b) do transformations where the content of one buffer affects the content of another etc.

2. Macros can have state, typically demonstrated by having a counter. Imagine replicating your keys, but somewhere in between, a number is incremented or a word from a list is being chosen etc.

3. Extension of (2) is generative ones e.g. abo abo's `tiny` package.

4. Macros can act in arbitrary buffers. For example, If you're in `dired` or `ranger-mode` or alike, you could edit the file system the same way you were editing the code.

The common denominator of all these is the keyboard. Any GUI version would either be too complex to represent all the possible variations, or there are use cases that are not covered by GUI and those use cases -if they matter to you- would be the reasons you'd be gravitating towards keyboard based editors. For the case of notepad, the uncovered use cases are quite trivial. :)

Re:Seven habits of effective text editing (2000) by ethagnawl on Tuesday October 24, 2017 @01:06PM (#15543152)
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.

Re:Seven habits of effective text editing (2000) by jokoon on Wednesday October 25, 2017 @04:51PM (#15554148)
CTRL 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.

Re:Seven habits of effective text editing (2000) by tincholio on Tuesday October 24, 2017 @10:35AM (#15541832)
> I guess this is just pre-filled if/else/while/for loops snippets? ST3 does it too I guess.

No, you seem to be simply talking out of ignorance.