1

When I copy and paste text from the clipboard, the code looks like

[core]
    repositoryformatversion = 0
        filemode = true
            bare = false
                logallrefupdates = true
                [remote "heroku"]

instead of

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "heroku"]

Here is my .nanorc file

set tabsize 4
set autoindent

According to Why does Vim indent pasted code incorrectly? the set autoindent is inserting the leading tabs into the code when I am pasting from the clipboard.

Is there a way I can configure .nanorc to turn-off autoindenting while pasting from the clipboard and turn it back on otherwise?

  • It pastes fine in Nano for me. Are you using an old version? 6.4 is the latest, as I speak. Type nano --version to see the version. What app did you copy the stuff from, which clipboard, and which desktop are you using (I'm using Cinnamon)? Or are you copying from within nano with alt+6 and pasting with ctrl+u? That pastes fine for me, too. – Brōtsyorfuzthrāx Sep 30 '22 at 05:26
  • Does the problem exist when you start nano with nano -I? If not, it's likely an issue with your nanorc file(s). – Brōtsyorfuzthrāx Sep 30 '22 at 05:30
  • I am using nano version 3.2 on a Debian 10 Windows SubSystem for Linux. I am copying by highlighting the selection, right-clicking, then moving over to the other window and doing a Ctrl-V or Right-click and paste. – siralbert Oct 03 '22 at 04:07

1 Answers1

1

If you don't want autoindent enabled, you should not set autoindent, as that enables it.

Instead, use unset autoindent in your .nanorc.

For more information, see man nanorc

You can also toggle autoindent with ALT+I (see CTRL+G for all shortcuts).

Panki
  • 6,664
  • 1
    The OP does want autoindent, but not when pasting: “Is there a way I can configure .nanorc to turn-off autoindenting while pasting from the clipboard and turn it back on otherwise?” – Stephen Kitt Aug 27 '22 at 15:18
  • Thanks, tried the toggling autoindent before pasting with ALT+I and the lines line up correctly. – siralbert Oct 03 '22 at 04:10