2011/06/23

Indentar todo una sección de código python con emacs

Cuando has programado un trozo de código en python y luego es necesario meterlo en un bucle... Arrrgggg... ¿a indentar línea por línea?

Emacs tiene la solución. Marca la sección que quieres desplazar y teclea:

C-c >

Otros comandos (extraídos de python.about.com):

* C-j: Insert a new line with the same indentation level as the current line
* RET: Insert a new line with the same indentation level as the current line
* C-M-a: Go to the beginning of the current function or class
* C-M-e: Go to the end of the current function or class
* C-M-h: Mark the current function or class for copying, etc.
* C-M-x: Execute the current function or class
* C-c C-b: Submit a bug report
* C-c C-c: Execute the buffer (i.e., the file being displayed)
* C-c C-d: Trace the stack of the process being executed
* C-c C-h: Get context-based help
* C-c TAB: Indent a highlighted (or marked) region
* C-c C-k: Mark a block of text. Using this at the head of a class or function definition will mark the entire block.
* C-c C-l: Shift the region to the left. If the cursor is in the middle of a region, the lower half of the region will shift.
* C-c RET: Execute the current file, opening a new window to show the output.
* C-c C-n: Jump to the next statement.
* C-c C-p: Jump to the previous statement.
* C-c C-r: Shift the region to the right. If the cursor is in the middle of a region, the lower half of the region will shift.
* C-c C-s: Execute a Python command.
* C-c C-t: Toggle shells
* C-c C-u: Go up one block
* C-c C-v: List the version of the Python mode
* C-c C-w: Run PyChecker
* C-c !: Open the Python interactive shell
* C-c #: Comment the highlighted (marked) region
* C-c :: Check the indentation off-set
* C-c <: Shift the region to the left
* C-c >: Shift the region to the right
* C-c ?: Show Python mode documentation
* C-c |: Execute the highlighted (marked) part of the current program.

Note that Python mode for Emacs offers more functionality than this, but these are the basics. If you know Emacs from editing other languages, learning your way around the Python mode is a snap.
       
   

No hay comentarios: