Search code examples
indentationnano

How do I eliminate cascading indents when pasting text in nano?


Background

I am doing a simple copy paste from one shell to another. Below is an example set of text I would copy from a code file:

code
code 
  code 
code code

However, when pasted, the text comes out like this in a nano editor

code
  code
      code
        code code

For each new line, it keeps indenting the pasted code in the editor. It is exactly the problem faced in this vim autoindenting question however, I am not familiar with the equivalent nano setting, hence why I am asking the question.

Question

How do I prevent the cascading indenting issue that I am experiencing above?


Solution

  • While nano and vim derive from different text editors, the ~/.nanorc file for nano as well as the manually created ~/.vimrc for vim have idential keywords that perform identical functions. One such instance of this identicality happens with the autoindent keyword. Remove the line that states set autoindent in your ~/.nanorc file and see if that resolves the issue.

    NOTE: You will be unable to autoindent while typing if you use this method. But if that does not concern you, follow the solution above.