Which Python editor has this feature?

Tim Chase python.list at tim.thechases.com
Sun Jan 10 21:37:48 EST 2016


On 2016-01-10 17:59, jfong at ms4.hinet.net wrote:
> It lets you jump between the current cursor position and the line
> the upper level indentation start, something like the bracket
> matching in C editor. Because of Python use indentation as its code
> block mark, It might be helpful if we can jump between different
> level of it:-)

While not quite what you're asking for, vim offers an "indent text
object" plugin[1] that allows you to use a block of indentation
around the cursor as an object.  So you can use vim's grammar to issue
commands like "dai" to delete the current indentation-defined block;
or you can use ">ii" to add a level of indentation to the
indentation-defined block.

If you want to make a vim mapping that will jump up to the top of the
previous level of indentation, the following should do the trick

  :nnoremap <expr> Q '?^'.repeat(' ', (strlen(substitute(getline('.'), '\S.*', '', ''))-&sw)).'\S?e'."\<cr>"

There might be some edge-cases that I haven't caught there, but, as
long as you edit with spaces rather than tabs, it should work,
including the accommodation of your 'shiftwidth', even if it's not
PEP8 4-spaces-per-indent.

-tkc

[1]
https://github.com/michaeljsmith/vim-indent-object








More information about the Python-list mailing list