SublimeREPL icon indicating copy to clipboard operation
SublimeREPL copied to clipboard

Possible to send a line without indentation

Open amcpherson opened this issue 10 years ago • 6 comments

When debugging a few lines of python code within a loop using SublimeREPL, it is necessary to unindent the code before sending the lines to sublimeREPL, otherwise the interpreter raises IndentationError. It would be nice if removal of the extraneous indentation were automatic, configurable, or another shortcut.

amcpherson avatar Apr 25 '14 16:04 amcpherson

+1 this makes it useless actually for me

hahla avatar Apr 16 '15 18:04 hahla

After navigating the web I ended up here wondering if anyone has ever solved this issue. It will be fantastic to send chunks of code within a function.

This is a reason why sometimes I end up using SendText and working in the terminal.

Any news on solving this issue?

Thanks!!

jrzaurin avatar Sep 12 '15 22:09 jrzaurin

+1

ebrensi avatar Nov 17 '15 06:11 ebrensi

Anyone have solution for mac? Thank you very much!

jasonzhang8801 avatar Nov 17 '15 06:11 jasonzhang8801

Found a solution! https://gist.github.com/ultinomics/46c40275a93bab74cff6.

tbenst avatar Nov 19 '15 00:11 tbenst

I used the solution suggested by tbenst above, but I also did modify my sublimeREPL to delete the extra spaces/indentation. It is not perfect but it worked for me.

In the text_transfer.py file I modified selected_lines

def selected_lines(self):
    v = self.view
    parts = []

    first_line = v.substr(v.lines(v.sel()[0])[0])
    empty_spaces = 0
    while first_line[empty_spaces] == " ":
        empty_spaces += 1

    for sel in v.sel():
        for line in v.lines(sel):
            parts.append(v.substr(line)[empty_spaces:])
    return "\n".join(parts)

cfingerh avatar May 03 '17 19:05 cfingerh