Today I Learned

hashrocket A Hashrocket project

Place a cursor at ALL occurrences in Visual Studio

One of the nice things about working with Visual Studio based text editors is its multi-cursor abilities. For those who don't know, you can highlight a word and pressing CMD+D you can place another cursor at the next occurrence of that string.

This is helpful for making a lot of changes at once. Here's an example where we can fix a typo that was made all throughout a file:

typo = getTypo

if(typo)
    # do something with the typo
else
    # do something else
end

def getTypo()
  typo
end

Well, what if we want a cursor at every occurrence of a typo, but we want a faster way than pressing CMD+D a bunch of times?

TLDR
Just highlight the word you want to grab and press CMD+Shift+L and it will grab all occurrences found in that file. (Just be careful and make sure that's what you actually want!)

See More #workflow TILs