2

i can execute a highlighted region, but is there a command to execute a single line? without C-space to highlight it.

any ideas?

1
  • Are you using the python.el that comes with emacs? Commented Mar 5, 2014 at 18:16

1 Answer 1

1

I am assuming you are using python.el that ships with Emacs. As far as I know the mode does not define a command to execute a single line. But we can easily define a command to do so. Below is my attempt to define such a command

(defun python-send-line ()
  (interactive)
  (save-excursion 
    (back-to-indentation)
    (python-shell-send-string (concat (buffer-substring-no-properties (point)
                                                                      (line-end-position)) 
                                      "\n"))))

If you are using python-mode.el, it does have a command named py-execute-line which according to docstring

Send current line from beginning of indent to Python interpreter.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.