[Top][All Lists]

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

Re: [Help-nano] getting nicely justified comments in an easy way

From: Benno Schulenberg
Subject: Re: [Help-nano] getting nicely justified comments in an easy way
Date: Fri, 29 Mar 2019 19:55:51 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1

Hello Seb,

Op 29-03-19 om 14:14 schreef Seb:
> First of all, thanks to the team for 'nano', which keeps getting better.

It's nice to hear that it is appreciated.  :)

> When I write some code, I comment a lot. What I do is disable the wrapping of
> long lines, write the long comment on one line, starting with '#', then apply 
> ^J.
> Then the comment looks nice.
> But this is not really convenient since I often need to re-read a part of the
> comment that is no longer on the screen. I then ^J and restart the process.
> What I'd like is to enable the wrapping of long lines, start a comment with #,
> type away and see a '#' automagically appear at the beginning of a new line.

This automatic appearing of "#" (or whatever the comment starts with) is
not possible.  But you can use the new region-justifying feature to achieve
something close to it.

Start nano with --quotestr="^(# |// )".  When you want to write a comment,
you enable automatic hard-wrapping with M-L and start your comment with
either "# " or "// ", and then type away your text.  When you've finished,
you use <Shift+Up> to select the whole comment (but make sure the selection
does not begin before the first comment line), and then type ^J.  Et voilà:
the comment is justified and all lines start with the same character sequence
as the first.

You don't even have to select the whole first comment line, as long as
the cursor is on that line when you press ^J, nano will use the prefix
of that line for the rest of the lines too.

(David Ramsey made this new feature, available in nano-4.0.)

> Additionaly, I'd like to enable both '#' and '//' as comment strings within 
> the
> same document, since I write HTML pages containing both Perl and JavaScript 
> code.

The justify command will recognize any character (or character group)
that is in quotestr as a comment-introducer.  See man nanor(5).  You
can customize it if you want, like adding a mandatory trailing space,
as done above.

> Finally, a completely unrelated question: when a document contain long lines 
> (>
> 80 chars), is there a keyboard switch what would allow me to see the far end 
> of
> the line as wrapped, on the same screen, as Vim does?

Yes, you can toggle softwrap with: M-$.  On an American keyboard this
is somewhat awkward: Alt+Shift+$, but on a French keyboard it seems
the $ is on the first, unshifted plane, next to the Enter key?  So it
should be easy to type.  Or does the keystroke not work for you?


Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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