Python & vim

Christian Schaller chris at alaska.cert.siemens.de
Tue Jun 12 17:07:16 EDT 2001


Dear Pythoners,

  I've seen already some threads about configuring vim that it is
comfortable editing Python programs, so let's get one step further!  Use
the following script to be able moving up and down the same indentation
level of the line the cursor is on (just press F10 for down and
Shift-F10 for up).

  Have fun!

bye
  Chris...

"""
fu! Block(indent, dir)
  let line = getline(".")
  let blankCount = matchend(line, a:indent)
  let nr = line(".")
  let lastPos = nr
  let maxLine = line("$")
  while nr <= maxLine && nr > 0
    let nr = nr + a:dir
    let curr = getline(nr)
    if curr == ""
      continue
    endif
    if matchend(curr, a:indent) == blankCount
      break
    elseif matchend(curr, a:indent) < blankCount
      let nr = lastPos
      break
    endif
  endw
  exe nr
endfu

map <F10> :call Block("^[ ]*", 1)<c-m>
map <S-F10> :call Block("^[ ]*", -1)<c-m>
"""



More information about the Python-list mailing list