How do I do a block search-and-replace with Vim?
When using ex commands in visual block mode, :, they always operate on the whole line. There are two ways around this: The … Read more
When using ex commands in visual block mode, :, they always operate on the whole line. There are two ways around this: The … Read more
Find: ([^\|]*\|[^\|]*)\| Replace to: \1\n
Make the regexp a little more specific. sed -n ‘s/.* \([0-9]*%\),.*/Battery: \1/p’ Pick a different tool. perl -ne ‘/(\d+%)/ && print “Battery: $1\n”;’ … Read more
First approach, try to exclude the one-liner JS files from being grepped in the first place. Often these will have a name like … Read more
You can supply grep the -o option. Like such: grep -o pattern file (Hint: The mnemonic I use for this is: omit everything … Read more
The :global command that you reference in your question actually doesn’t just take literal strings, it handles any regular expression. So, you just … Read more
Well, here’s a wikipedia page for matching or replacing with Perl one liners. I did this in Cygwin: Perl can behave like grep … Read more
Well I don’t think you can do it with one search-replace. I’d do this. Open up the search-replace, choose mode regex and search … Read more
No regex required in this case. Edit > Blank Operations > Trim leading Space. Replace All “\r\n” with ” | ” (make sure … Read more
In substitution, only the match (left-hand side) is a regular expression. The replacement is more or less just a literal string (with some … Read more