1

I just opened a file and found what looked like a bunch of garbage at the beginning and ending of each line:

^[[35m^[[KsampleA.trimmed.count.20_to_30.not_in_ref.MULTI_in_sample.sam^[[m^[[K^[[36m^[[K:^[[m^[[K7
^[[35m^[[KsampleA.trimmed.count.20_to_30.not_in_ref.in_sample.sam^[[m^[[K^[[36m^[[K:^[[m^[[K4
...

I was wondering if Vim was in some funny UTF-8 mode or something.

This file was simply created using grep on Linux:

grep -c 'NM:i:0' *.sam > grep_example.txt

They look fine with more:

Image with the command "more grep_example.txt" followed by two lines in color showing the results.

But it has all these funny characters when using vim: Image showing the vim console with "extra" characters before and after the text that shows up as colored with more

3

Those characters are actually color encoding. Don't you think it odd that when you type more you get color instead of black-and-white characters?

You must have grep set as an alias to grep --color=always. You're probably going to want to make a separate grep alias for viewing results in the console versus extracting text from files.

Basically, vim is being honest and showing you the actual characters in the file. More is also honest, but it sends those characters to your console, which interprets them as color encoding instead of text.

Not the answer you're looking for? Browse other questions tagged or ask your own question.