nano-devel
[Top][All Lists]
Advanced

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

Re: Global tabgives and spacestotab config option


From: Benno Schulenberg
Subject: Re: Global tabgives and spacestotab config option
Date: Tue, 1 Jun 2021 10:51:55 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

Op 31-05-2021 om 18:46 schreef Peter Magnusson:
> One thing has annoyed me but I never put time into try to fix it until
> recently. The problem is that tabstospaces always is active even that it
> isnt so in the cfg.

It is not, but it may seem that way because of the way that nano displays
things.

> If I ^K a line and ^U the tab will still be there.
> If I do the same with the mouse and cut and paste it will do tabstospaces.

Using the mouse (under X) to select stuff in the terminal will copy the
text as it is displayed on the terminal.  And nano never sends tabs to
the terminal, but always the relevant number of spaces, even though the
buffer itself contains tabs.  You can see this by opening a file that
contains tabs, switch on whitespacedisplay (M-P), and slowly select a
couple of tabs.  You will see that the selection happens space by space
and never a tab jump at a time.  For example in:

    »   »   »   »   some text;

Nano has always done this.  If nano would send real tabs to the terminal,
it would depend on the tab setting of the terminal how the text would be
displayed, and nano wouldn't know in which column the cursor actually is.

> I like tabs and want to be able to copy text with tabs from one host to
> and other host without acutally moving the file.

Sorry, this is not possible.

> both these files exists:
> /usr/share/nano-syntax-highlighting/python.nanorc
> /usr/share/nano-syntax-highlighting/makefile.nanorc

They may exist, but you must also 'include' them into your .nanorc
for nano to read them.  And you must include them before you can
extend them.  So better move those 'extendsyntax' commands to your
personal ~/.nanorc file.

> How do I do something like this?
> 
> extendsyntax * tabgives "       "
> tabgives * "    "
> tabgives "      "

This is not possible.  The 'tabgives' command is syntax specific.
(And it wouldn't solve your problem anyway.)

> Im not alone with this problem, there is at least one more that have the
> exactly the same problem:
> https://discuss.getsol.us/d/4837-terminal-nano-converts-tab-to-ordinary-space
> I think its a good idea, can nano have a spacestotab config option?

In theory a --spacestotab option would be possible, but it would be
wildly complicated because of Undo -- nano would need to backtrack
and change not only the typed spaces in the buffer to a tab but also
the spaces in the undo stack, and not forget to adjust the file size.
Sounds feasible, but is complicated.  Do you have a patch?  :)

Benno

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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