Differences between revisions 4 and 5
Revision 4 as of 2003-08-13 19:54:46
Size: 1549
Editor: 192
Comment:
Revision 5 as of 2005-02-25 18:41:33
Size: 1872
Editor: Delfinnet
Comment: Uncommenting using rectangles.
Deletions are marked like this. Additions are marked like this.
Line 15: Line 15:
There are two solutions: There are (at least) three solutions:

 There are (at least) three solutions:
Line 27: Line 29:
   III. Rectangles. Place point and mark at opposing corners of a comment region. C-x r d will kill the offending # signs. C-x r o can be used against a region to usher code back into ranks. C-h a "rectangle" and [http://www.emacswiki.org] are your friends.

Python Mode is a major editing mode for the EmacsEditor.

The [http://www.python.org/emacs/python-mode/python-mode.el current release] is version 4.6 (~123KB). The list of changes since the last released version [http://www.python.org/emacs/python-mode/changes-406.html are given in detail], as well as some [http://www.python.org/emacs/python-mode/installation.html installation notes.] If you're having problems with font-lock in python-mode, read the [http://www.python.org/emacs/python-mode/faq.html FAQ.]

Python Mode is part of the source distribution of Python (as the file Misc/python-mode.el) and a more recent version than the above release may be available through CVS.

See PythonMode for information on how to install, configure and add shortcuts keys to python-mode.

Python Mode FAQ

How can I run Uncomment Region?

The handy Uncomment Region command does not have a shortcut key. Actually, you can not run it from the command line at all! If you look into the python-mode description (C-h m), you will find that there is no such command.

There are (at least) three solutions:

  • There are (at least) three solutions:
  • Prefix the Comment Region command with C-u, like this: C-u C-c #
  • If you really want to save this extra C-u and have a shortcut like C-c 3, put this elisp code into your .emacs file:

;; The missing key shortcuts for Uncomment Region
  (add-hook 'python-mode-hook (lambda () 
    (define-key py-mode-map "\C-c3" 
      (lambda (beg end) (interactive "r")
        (py-comment-region beg end '(4))))))
  • III. Rectangles. Place point and mark at opposing corners of a comment region. C-x r d will kill the offending # signs. C-x r o can be used against a region to usher code back into ranks. C-h a "rectangle" and [http://www.emacswiki.org] are your friends.

EmacsPythonMode (last edited 2020-11-25 22:12:14 by JonMoore)

Unable to edit the page? See the FrontPage for instructions.