Differences between revisions 9 and 10
Revision 9 as of 2010-05-20 23:29:02
Size: 1337
Editor: 65
Comment:
Revision 10 as of 2023-09-17 13:10:57
Size: 1494
Editor: MatsWichmann
Comment:
Deletions are marked like this. Additions are marked like this.
Line 9: Line 9:
Python uses indentation to group statements. A well designed mode should offer support for smart indentation of code. For example, a line beginning with the keyword def and ending with : should cause the editor to indent the following line upon hitting of the return key. Python uses indentation to group statements. A well-designed mode should offer support for smart indentation of code. For example, a line beginning with the keyword `def` and ending with `:` should cause the editor to indent the following line upon hitting of the return key.
Line 17: Line 17:
Python supports three types of string literals. Strings can be enclosed in single quotes ('), double quotes (") and in groups of three single or double quotes (and are then referred to as triple-quoted strings). A well designed mode should support all three types. In particular, a mode should correctly recognize that triple-quoted strings can include unescaped newlines and quotes. Python supports three types of string literals. Strings can be enclosed in single quotes (`'`), double quotes (`"`) and in groups of three single or double quotes (referred to as triple-quoted strings). A well-designed mode should support all three types. In particular, a mode should correctly recognize that triple-quoted strings can include unescaped newlines and quotes.
Line 19: Line 19:
Python allows for raw strings without \-escape sequences (written with a preceding r: r"c:\dir1\dir2"). A well designed mode should support this feature as well. Python allows for raw strings without \-escape sequences (written with a preceding r: `r"c:\dir1\dir2"`). A well-designed mode should support this feature as well.

== EditorConfig ==

An emerging standard for describing the configuration of code editors in a portable way is [[https://editorconfig.org|EditorConfig]].

Python's syntax requires special handling in the construction of a Python editor mode. Two issues are particular to Python:

See also HowToEditPythonCode for concrete examples of editor configuration.

Indentation

Python uses indentation to group statements. A well-designed mode should offer support for smart indentation of code. For example, a line beginning with the keyword def and ending with : should cause the editor to indent the following line upon hitting of the return key.

The most widely used standard is four-space indent. Using tabs is discouraged, so the editor should be configured to convert tabs to spaces.

Code examples or references on how to deal with indentation should follow.

Strings

Python supports three types of string literals. Strings can be enclosed in single quotes ('), double quotes (") and in groups of three single or double quotes (referred to as triple-quoted strings). A well-designed mode should support all three types. In particular, a mode should correctly recognize that triple-quoted strings can include unescaped newlines and quotes.

Python allows for raw strings without \-escape sequences (written with a preceding r: r"c:\dir1\dir2"). A well-designed mode should support this feature as well.

EditorConfig

An emerging standard for describing the configuration of code editors in a portable way is EditorConfig.


CategoryEditors

EditorConfigurationHowto (last edited 2023-09-17 13:10:57 by MatsWichmann)

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