3 ms·
I rarely use global find and replace nowadays (just for complex regex replaces). I hold Ctrl-D until all occurrences are selected and type the replacement strin
by njoh 14y ago
I rarely use global find and replace nowadays (just for complex regex replaces). I hold Ctrl-D until all occurrences are selected and type the replacement string (assuming occurrences are low in quantity, which they usually are in most cases).
- weaksauce 14y agovisual selection replacement is good too. :'<,'>s/this/to that/g I think vim does that automatically when you have a selection active and hit :
- caioariede 14y agoNote that this will replace over the entirely lines even if it's a blockwise selection. So you might consider using :'<,'>s/\%Vthis/to that/g
- weaksauce 14y agoIt might be a setting or something but it definitely doesn't do that on my machine or the linux machine I have in the cloud. this ipsum dolor sit amet this ipsum dolor sit amet this ipsum dolor sit amet this ipsum dolor sit amet this ipsum dolor sit amet select the middle 3 lines and do what I said will give you: this ipsum dolor sit amet to that ipsum dolor sit amet to that ipsum dolor sit amet to that ipsum dolor sit amet this ipsum dolor sit amet
- Already__Taken 14y agoYou know crt + H (global find and replace) takes what's highlighted and uses the last thing you looked for it nothing is highlighted.
- MetaCosm 14y agoThat sounds like a lot more work...
- njoh 14y agoNo it's not! Plus, you'd get to see the replacement targets while you're holding the keys, so you'd be more confident about the final result. Just give Ctrl-D a try for a couple of days.. It's a total different user experience compared to the traditional find/replace method.
- dmatlack 14y agoDo you mean it's a lot of work to type in that prefix? Because vim automatically inserts it for you when you enter command mode while something is visually selected. A making a visual selection is very quick and easy.
- robin_reala 14y agoCtrl+cmd+g is cmd+d for all occurrences on the page.
- deleted 14y ago[deleted]