Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Tim Chase Newsgroups: comp.lang.python Subject: Re: Which Python editor has this feature? Date: Sun, 10 Jan 2016 20:37:48 -0600 Lines: 33 Message-ID: References: <830f6f97-22dd-488c-9dd6-e9cd92844307@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de +C7EZvVjqc+VoK9g5gYcdw7phDStoyGkUQgDlnBWoAew== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; "'',": 0.07; 'block;': 0.07; 'subject:editor': 0.07; 'block.': 0.09; 'cursor': 0.09; 'editor.': 0.09; 'url:github': 0.09; 'python': 0.10; '-tkc': 0.16; 'bracket': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'mark,': 0.16; 'pep8': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'work,': 0.21; 'object.': 0.22; 'matching': 0.23; "haven't": 0.24; 'header:In-Reply-To:1': 0.24; 'helpful': 0.27; 'start,': 0.27; "skip:' 10": 0.28; 'for,': 0.29; 'indentation': 0.29; 'spaces': 0.29; 'allows': 0.30; 'code': 0.30; '[1]': 0.32; 'jump': 0.33; 'lets': 0.33; "skip:' 20": 0.34; 'previous': 0.34; 'add': 0.34; 'skip:( 30': 0.35; 'text': 0.35; 'mapping': 0.35; 'quite': 0.35; 'something': 0.35; 'level': 0.35; 'asking': 0.35; 'should': 0.36; 'there': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'there,': 0.37; 'charset :us-ascii': 0.37; 'delete': 0.38; 'rather': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'your': 0.60; 'different': 0.63; 'between': 0.65; 'received:50': 0.66; 'upper': 0.76; 'subject:this': 0.85; 'skip:4 20': 0.91 X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-MC-Relay: Neutral X-MailChannels-SenderId: wwwh|x-authuser|tim@thechases.com X-MailChannels-Auth-Id: wwwh X-MC-Loop-Signature: 1452480004394:1902211515 X-MC-Ingress-Time: 1452480004394 In-Reply-To: <830f6f97-22dd-488c-9dd6-e9cd92844307@googlegroups.com> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) X-AuthUser: tim@thechases.com X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:101457 On 2016-01-10 17:59, jfong@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 Q '?^'.repeat(' ', (strlen(substitute(getline('.'), '\S.*', '', ''))-&sw)).'\S?e'."\" 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