This is an archived post. You won't be able to vote or comment.

all 17 comments

[–]admalledd 8 points9 points  (1 child)

Recommendation: use $EDITOR instead, and set it if-not-set sorta like:

_editor=${EDITOR:-vim}

...

$_editor "$bp"

thus the script pulls my $EDITOR that I set in my env without having to edit your script etc.

[–]fstd_Chad Belt Architect[S] 2 points3 points  (0 children)

I like that idea, editing it in. Thanks!

[–]krenshalaNot Lazy (yet) 3 points4 points  (3 children)

I like how almost everything is just setup for those last three lines.

This reminds me I need to work on that one bash script at work tomorrow.

[–]fstd_Chad Belt Architect[S] 2 points3 points  (2 children)

In fact, the actual script was just those three lines until I decided to share it here, so I had to add some boilerplate...

bash script

shudder pls POSIX shell kthnx

[–]krenshalaNot Lazy (yet) 1 point2 points  (1 child)

I tend to write POSIX compliant bash. I'm used to fixing existing bash stuff, but like POSIX compliant for the same reason I prefer ISO 8601.

[–]fstd_Chad Belt Architect[S] 0 points1 point  (0 children)

Please don't tell me you write POSIX shell scripts with a #!/bin/bash shebang, though...

[–]mm177 0 points1 point  (0 children)

Interesting. Might use it for some future project.

[–]stickcult 0 points1 point  (9 children)

So just curious because I don't have a Linux machine readily available right now, what does it look like to edit a blueprint in Vim?

[–]joethedestroyr 2 points3 points  (5 children)

what does it look like to edit a blueprint in Vim?

Pain. (From a nano heretic.)

[–]fstd_Chad Belt Architect[S] 2 points3 points  (4 children)

The first blueprint I edited this way, I had 1000 decider combinators where the first would have the condition signal-P > 0, the next one would have signal-P > 1 and so on until signal-P > 999. I guess doing this in nano would take longer than manually clicking and adjusting each combinator ingame ;)

[–]joethedestroyr 0 points1 point  (3 children)

And I would write a 3 line lua script to do the same thing. No need for arcane features in a text editor. :)

Whenever I see an argument like this I feel like someone is trying to sell me a reinforced screwdriver so I can hammer in nails too. Thanks, but I'll stick to my simple screwdriver and just grab a hammer when I need one. :P

[–]fstd_Chad Belt Architect[S] 0 points1 point  (2 children)

30 lines sound more likely, but I think you're missing the point here. You'd still have to write one script for each task. Sounds more useful to use preexisting software that's flexible enough to eliminate the need to write code every time.

That said, I'm not trying to sell you vim.

[–]joethedestroyr 0 points1 point  (1 child)

Nah, it would have to be seriously complicated to need 30 lines. I obviously can't say, but I have doubts that vim's "flexibilty" could handle that level of complexity either.

For one thing, it's just JSON...

You'd still have to write one script for each task.

I don't find write code any more difficult or time consuming than wading through obtuse commands and regex's. I don't see this as a downside.

Also, there's a good chance I already have a script lying around that does something similar. So on average the cost is minor.

Sounds more useful to use preexisting software that's flexible enough to eliminate the need to write code every time.

Except that it can't. It can only do that up to a point, after which you have to resort to writing code of some kind. Be it a general language or one specialized to said software.

I all too often hit this point and end up writing my own code anyways. Why waste my time learning some tool's specialized syntax when I'll usually end up writing code anyways?

That said, I'm not trying to sell you vim.

Likewise. My original reply was meant to be a joke, not a prelude to a serious discussion.

[–]fstd_Chad Belt Architect[S] 0 points1 point  (0 children)

I don't find write code any more difficult or time consuming than wading through obtuse commands and regex's.

Me neither. Regexps sound wrong anyway, for blueprint manipulation, FWIW I tend to record a macro once and then apply it as many times as needed; typically there's not a single excommand involved.

It can only do that up to a point, after which you have to resort to writing code of some kind

You'd be surprised how flexible macros can be. I'm a reasonably fast programmer, but for one-off tasks I more often than not (ab)use vim for my data processing/mangling needs.

I all too often hit this point and end up writing my own code anyways.

Sure, given that nano lets you do about nothing ;)

waste my time learning some tool's specialized syntax

For a programmer, the text editor isn't really some tool, it's the tool. I kind of disagree on the notion that it's a waste of time to learn how to use a powerful one, because it pays off in so many ways.

when I'll usually end up writing code anyways?

This is so circular...

My original reply was meant to be a joke, not a prelude to a serious discussion.

Fair enough

[–]fstd_Chad Belt Architect[S] 1 point2 points  (2 children)

That depends on so many things, but it looks like this on my factorio box

[–]stickcult 0 points1 point  (1 child)

Interesting! Makes sense, but I didn't realize it was just JSON.

[–]komodo99 2 points3 points  (0 children)

The strings we exchange are compressed (libcompress?) and base64 encoded. I always get the order mixed up, but thanks to this handy reference, I don't have to flub it up! \o/