Webdev: the times, they are a changin'

Andy Bradford amb-plugg at bradfords.org
Thu Apr 19 22:58:05 MDT 2012


Thus said Dave Smith on Thu, 19 Apr 2012 07:13:13 MDT:

> If I  have an existing block  of code that I  want to wrap in  an "if"
> statement, I have  to manually indent the whole  block (thank goodness
> for Vim's Ctrl+v and Shift+i).

No you don't, it's quite easy in  vi (not even vim is required for this)
to mark the  beginning of a block,  mark the end of the  block, and then
just  use an  ex  command to  indent  it. For  example,  insert your  if
expression: and then  move to the next  line (j), the first  part of the
block, press ma, move  to the last part of the block,  press mb, then ex
it with:

:'a,'bs/^/<tab>/

And now you  know how to edit  and indent blocks of python  code with vi
(and vim  if you please).  This is no more  work than you  suggested for
wrapping C++ code with an if {}.

Andy



More information about the PLUG mailing list