Today I learned a neat vim trick (via the Aaron Paterson Play by Play interview):
You can highlight some lines with visual mode and then press =
and it will fix all of the indentation mistakes therein. If youâre in normal mode, you can press ==
to fix just the line youâre currently on.
Paterson cites this trick as an argument in favor of not indenting private methods an extra level, because vim doesnât do that. For example:
# do this:
class Dog
def bark
barks.sample
end
private
def barks
["woof", "yap", "ruff"]
end
end
# NOT this:
class Cat
def meow
meows.sample
end
private
def meows
["meow", "purr", "idk what else, cats are weird"]
end
end
I generally do that extra indent but I might stop now đ.
Note: I don't have comments or analytics on this website, so it's hard to tell if people are reading or enjoying it.
Please feel free to share any feedback or thoughts by shooting me an email or tagging me in a post on Mastodon @maxjacobson@mastodon.online.