# Tag Info

2

Rotate your loops Rotating loops is a golfing trick in many languages but I've found it to be more frequently useful in vim, largely due to the fact that loops usually exit by failure. This allows you to determine a subset of code to be executed on the first and/or last iteration. Thus, when you have code like <init>qq<loop>@qq@q<finalize>, ...

1

Checking if a boolean value is false and an integer is a specific odd integer ~True is ~1 is -2 and ~False is ~0 is -1 -1&int is always int -2&int is always even Therefore, despite operator order, ~bool&int==odd_int works fine. It's shorter than all of these equivalents: not bool and int==odd_int -~bool and int==odd_int -~bool&int==odd_int

2

Rather than using [bool] for boolean conversion ou can instead use !! 1 # 1 [bool]1 # True !!1 # True 0 # 0 [bool]0 # False !!0 # False !!null # False 0 Align Registers to by Power of 2 Value with or/inc Say you want to aligned a pointer for a load. I.e saying aligning for xmm load: This is a pretty common idiom: addq16, %rdi // 4b andq $-16, %rdi // 4b A cheaper way: orq$15, %rdi // 4b incq %rdi // 3b Also worth noting the or alone will round to value minus 1 so it can be used to keep ...

1

Use String Mode to Allow the IP to Pass Through Other Code If you need the IP to get from here to there and there's a bunch of existing and unmovable code in the way in every direction, just push a 0, go into string mode, pass through the code, come out of string mode, and pop all the garbage before continuing. This trick employed in Wim Rijnder's Wumpus ...

1

#n at first to imply -n (GNU extension) Warning: if the first two characters of the sed script are #n, then the -n (no-autoprint) option is forced. Source: GNU sed manual This is useful if you prefer NOT to output something by default.

0

The L command in old GNU sed versions Used, for example, in the second solution in https://codegolf.stackexchange.com/a/220633/. Older versions of GNU sed like GNU sed 4.2.2 have the L command, which was later removed in newer versions. From the archived docs, L n This GNU sed extension fills and joins lines in pattern space to produce output lines of (at ...

3

You are free to trash stdout and stack under the top... ... as long as your submission is a function and the result is returned on the top of the stack. Simple example . is shorter than drop, and . . is shorter than 2drop. (Almost) any object that you will encounter while golfing is printable via ., and it has the effect of removing the top item of the stack....

Top 50 recent answers are included