Which Python editor has this feature?

jfong at ms4.hinet.net jfong at ms4.hinet.net
Mon Jan 11 06:08:53 EST 2016


Tim Chase at 2016/1/11 UTC+8 11:16:27AM wrote:
> 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.

Thanks, Tim.
I always admire people who can remember all those detail commands/parameters/options which a DOS-style editor as vim has. It's almost like a mission impossible to me:-(

> 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>"

But, but... this line??? won't it goes too far for a human being to read?

--Jach

> 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