:sort in .tsv file

25 views
Skip to first unread message

c.willis111

unread,
Nov 17, 2025, 4:54:55 PM (5 days ago) Nov 17
to vim...@googlegroups.com

Hi

the /pattern/ feature of sort doesn't work if the recognized filetype is .tsv (which gives alternate colours for successive fields).

 

Is there a workaround, apart from copying it to a plain file and working on it there?

 

regards - Chris

Tim Chase

unread,
Nov 17, 2025, 6:30:58 PM (5 days ago) Nov 17
to Vim Use
I'm not sure if you have some plugin interfering, but when I open a TSV
file with the following contents:

$ cat test.tsv
h1 h2 h3 h4 h5
d c b a 1
c d a b 30
b a d c 4
a b c d 200

I can issue the following commands to sort by the various columns:

:2,$sort " sort by the first column
:2,$sor /[^^I]*^I/ " sort by the second column
:2,$sor /\([^^I]*^I\)\{2}/ " sort by third column
:2,$sor /\([^^I]*^I\)\{3}/ " sort by the fourth column
:2,$sor n /\([^^I]*^I\)\{4}/ " sort numerically by the fifth column

So I'm uncertain what you're seeing or how you're sorting that differs.

-tim
--





Christian Brabandt

unread,
Nov 18, 2025, 5:24:13 AM (4 days ago) Nov 18
to 'c.willis111 ' via vim_use

On Mo, 17 Nov 2025, 'c.willis111 ' via vim_use wrote:

> the /pattern/ feature of sort doesn't work if the recognized filetype is
> .tsv (which gives alternate colours for successive fields).

What exactly do you mean by this?

Thanks,
Christian
--
"We are on the verge: Today our program proved Fermat's next-to-last theorem."
-- Epigrams in Programming, ACM SIGPLAN Sept. 1982

c.willis111

unread,
Nov 18, 2025, 6:11:50 AM (4 days ago) Nov 18
to vim...@googlegroups.com

------ Original Message ------
From: cbl...@256bit.org
To: vim...@googlegroups.com
Sent: Tuesday, November 18th 2025, 10:24
Subject: Re: :sort in .tsv file
On Mo, 17 Nov 2025, 'c.willis111 ' via vim_use wrote: > the /pattern/ feature of sort doesn't work if the recognized filetype is > .tsv (which gives alternate colours for successive fields). What exactly do you mean by this? Thanks, Christian -- 

 

Hi Christian

 

I have the .csv plugin.

 

When I use the pattern in the vim :sort command, it does not work as expected.

 

I was mistaken in an earlier message. I am sure this is due to the plugin. If I copy the file I am working on to a, so that the plugin no longer recognizes it as a .tsv, the sort works as I had expected originally. I then have to copy my result back to the .tsv file.

 

 

The question was, is there a neater way of using the vim sort.

 

regards - Chris

c.willis111

unread,
Nov 18, 2025, 8:15:21 AM (4 days ago) Nov 18
to vim...@googlegroups.com

Subject: Re: :sort in .tsv file
On Mo, 17 Nov 2025, 'c.willis111 ' via vim_use wrote: > the /pattern/ feature of sort doesn't work if the recognized filetype is > .tsv (which gives alternate colours for successive fields). What exactly do you mean by this? Thanks, Christian -- 

 

Hi Christian

 

I have the .csv plugin.

 

When I use the pattern in the vim :sort command, it does not work as expected.

 

I was mistaken in an earlier message. I am sure this is due to the plugin. If I copy the file I am working on to a, so that the plugin no longer recognizes it as a .tsv, the sort works as I had expected originally. I then have to copy my result back to the .tsv file.

 

 

The question was, is there a neater way of using the vim sort.

 

regards - Chris

 

Hi Christian

 

it seems that if I type

 

  :filetype plugin off

 

before my sort command, the sort works, despite the screen still showing the plugin layout. (Despite the fact that I still need to use the letter keys for extending the line visual area, rather than the cursor keys).

 

regards - Chris

Reply all
Reply to author
Forward
0 new messages