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: Liu Hao
Subject: Re: spotlight and cutting/copying/zapping
Date: Wed, 10 Mar 2021 23:06:09 +0800
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0

在 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


With nano it requires use of a macro:

   0. Ctrl-W
   1. ,<Enter> (to search for a comma)
   2. Meta-\ (to go to beginning of this line)
   3. Meta-Shift-: (to start recording)
   4. Meta-W (to go to the first comma)
   5. Meta-A (to select it)
   6. Meta-W (to go to the second comma, adding the second field to selection)
   7. Ctrl-K (to cut the selection)
   8. End (to go to end of this line)
   9. Ctrl-U (to paste it)
  10. Home (to go to beginning again)
  11. Down (to go to next line, if any)
  12. Meta-Shift-: (to finish recording)
  13. Repeat Meta-Shift-; until all lines have been processed.

If the new behavior is available, then 4-6 can be combined into a single operation, which will be a bit more convenient.


--
Best regards,
Liu Hao

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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