sac
sac

Reputation: 75

Geany and Python 3. Sending text to terminal automatically adds indentation. Why?

I'm running python 3.19 (in ipython 8.1) with Geany (Manjaro XFCE), and when I send the following text to terminal (with keyboard shortcut):

def myequation(x, B, a):
    y=np.exp(-B*x)
    return y

I have the classical "unexpected indent". It is not a problem of spaces/tabs, etc. Using copy/paste works fine; using %paste works fine. The problem is that when sending the text to terminal Geany automatically adds indents that I don't want, so my code ends up being sent like:

def myequation(x, B, a):
        y=np.exp(-B*x)
            return y

Thus, to be sent properly I should write:

def myequation(x, B, a):
y=np.exp(-B*x)
return y

or

def myequation(x, B, a):
    y=np.exp(-B*x)
return y

which looks very strange. I've been using geany and python (2 and 3) before, and never had this issue. Any idea how to stop this automatic indentation when sending text to terminal?

Thanks!

Upvotes: 0

Views: 203

Answers (1)

sac
sac

Reputation: 75

Ok, found how to solve it. Just in case anyone has the same problem, here the answer:

  1. Use %autoindent (will toggle autoindentation OFF)
  2. Go to ./ipython/profile_default/ipython_config.py (if file doesn't exist you can create it with: ipython profile create) and change "c.TerminalInteractiveShell.autoindent = False"; as default autoindent=True.

Here a couple of links where I found the answer: https://github.com/kassio/neoterm/issues/71 ; https://github.com/kassio/neoterm/pull/90

Upvotes: 1

Related Questions