comparison runtime/indent/python.vim @ 20:4ac1dce8dd5e v7.0012

updated for version 7.0012
author vimboss
date Mon, 26 Jul 2004 12:53:41 +0000
parents 7edf9b6e4c36
children 8b0ee9d57d7f
comparison
equal deleted inserted replaced
19:a81bc802c17c 20:4ac1dce8dd5e
1 " Vim indent file 1 " Vim indent file
2 " Language: Python 2 " Language: Python
3 " Maintainer: Bram Moolenaar <Bram@vim.org> 3 " Maintainer: Bram Moolenaar <Bram@vim.org>
4 " Original Author: David Bustos <bustos@caltech.edu> 4 " Original Author: David Bustos <bustos@caltech.edu>
5 " Last Change: 2004 Jun 15 5 " Last Change: 2004 Jul 25
6 6
7 " Only load this indent file when no other was loaded. 7 " Only load this indent file when no other was loaded.
8 if exists("b:did_indent") 8 if exists("b:did_indent")
9 finish 9 finish
10 endif 10 endif
97 97
98 " Get the line and remove a trailing comment. 98 " Get the line and remove a trailing comment.
99 " Use syntax highlighting attributes when possible. 99 " Use syntax highlighting attributes when possible.
100 let pline = getline(plnum) 100 let pline = getline(plnum)
101 let pline_len = strlen(pline) 101 let pline_len = strlen(pline)
102 let col = 0 102 if has('syntax_items')
103 while col < pline_len 103 " If the last character in the line is a comment, do a binary search for
104 if pline[col] == '#' && (!has('syntax_items') 104 " the start of the comment. synID() is slow, a linear search would take
105 \ || synIDattr(synID(plnum, col + 1, 1), "name") =~ "Comment$") 105 " too long on a long line.
106 let pline = strpart(pline, 0, col) 106 if synIDattr(synID(plnum, pline_len, 1), "name") =~ "Comment$"
107 break 107 let min = 1
108 let max = pline_len
109 while min < max
110 let col = (min + max) / 2
111 if synIDattr(synID(plnum, col, 1), "name") =~ "Comment$"
112 let max = col
113 else
114 let min = col + 1
115 endif
116 endwhile
117 echomsg min
118 let pline = strpart(pline, 0, min - 1)
119 echomsg pline
120 sleep 1
108 endif 121 endif
109 let col = col + 1 122 else
110 endwhile 123 let col = 0
124 while col < pline_len
125 if pline[col] == '#'
126 let pline = strpart(pline, 0, col)
127 break
128 endif
129 let col = col + 1
130 endwhile
131 endif
111 132
112 " If the previous line ended with a colon, indent this line 133 " If the previous line ended with a colon, indent this line
113 if pline =~ ':\s*$' 134 if pline =~ ':\s*$'
114 return plindent + &sw 135 return plindent + &sw
115 endif 136 endif