Is there a way to indent automatcally after typing a : when editing python in vim? I works that way in CodeMirror and I found it nice; so I wondered if vim has that capability?
Try adding the following lines to your
syntax on filetype plugin indent on
plugin is not necessary for indenting, but it enables filetype plugins to run, which you probably want.
This will cause Vim to load its Python indent script when you edit a Python file, which will set the following option:
This will cause Vim to use an automatic indent on lines after statements that end in
If you'd like to see how this works, you can view the indent script with the command:
:h :filetype-indent-on and
:h indent-expressions for more details.
If you find Vim's included indent file insufficient for your needs, you might like to try this plugin, which offers a few refinements over the built-in version: this is what I'm currently using for Python indenting.