nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: spotlight and cutting/copying/zapping


From: Benno Schulenberg
Subject: Re: spotlight and cutting/copying/zapping
Date: Thu, 11 Mar 2021 12:09:36 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

Op 10-03-2021 om 16:06 schreef Liu Hao:
> 在 2021-03-10 20:13, pepa65 写道:
>>
>> That's not quite true, I mailed in this on Dec.11:
>>
>> I use text editors a lot like this. The example I'm giving here is from
>> a recent case where I was inspecting a CSV file, where I decided I
>> wanted to move the second field (of 5) to the end of the line. If the
>> length is fixed, you can use Mark and count lefts until you cut what you
>> need to cut. In my case, I had 2 lengths, so I used a regex find twice
>> for both lengths. But with the new feature, I would search for /,[^,]/
>> then cut that, move to the end of the line and paste, for any length of
>> the field!
> 
> Although this can be done with nano, it might be a better job for sed:
> 
>   sed -Ei 's/^([^,]*),([^,]*),(.*)$/\1,\3,\2/' somefile.csv

This regex replacement can be done fine with nano too.

  Search for: ^([^,]+)(,[^,]+)(,.*)$
  Replace with: \1\3\2
  Type: A

It requires some thinking, but it looks easier to me than a macro.
Plus, if the file has more than a few dozen lines, it doesn't require
holding down <Alt+;>, with the risk of overshooting the end.

Benno

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]