Skip to content

Commit 050e1ac

Browse files
author
lepoussin
committed
Alignement now uses virtual column.
1 parent 6e59ffa commit 050e1ac

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

deps/README

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ depends.
33

44
- indent/vhdl.vim : Revised VHDL indent file
55
http://www.vim.org/scripts/script.php?script_id=1450
6+
Part of the default Vim runtime (v1.50, 2007-01-29)
7+
Current version: 1.54 (2007-08-17)
68

plugin/vhdl.vim

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ let g:vhdl_plugin=1
99
" Cursor is moved at the end of the given range
1010
fun! VHDL_align(delim) range
1111

12-
let l = getline(a:firstline,a:lastline)
13-
call map(l, 'substitute(v:val, "\\(--.*\\)\\<!@\\s*".a:delim."\\s*", " ".a:delim." ", "")')
14-
let pos = map(copy(l), 'stridx(v:val, a:delim)')
12+
call map(range(a:firstline,a:lastline), 'setline(v:val, substitute(getline(v:val), "\\(--.*\\)\\@<!\\s*".a:delim."\\s*", " ".a:delim." ", ""))')
13+
let pos = map(range(a:firstline,a:lastline), 'virtcol([v:val,stridx(getline(v:val),a:delim)+1])')
1514
let pos_max = max(pos)
1615

17-
let i = 0
18-
while i < len(l)
19-
let l[i] = substitute(l[i], '\ze'.a:delim, repeat(' ',pos_max-pos[i]), '')
16+
let i = a:firstline
17+
while i <= a:lastline
18+
if pos[i-a:firstline] > 0
19+
call setline(i, substitute(getline(i), '\ze'.a:delim, repeat(' ',pos_max-pos[i-a:firstline]), ''))
20+
endif
2021
let i+=1
2122
endwhile
2223

23-
call setline(a:firstline, l)
2424
call cursor(a:lastline,0)
2525

2626
endfun

0 commit comments

Comments
 (0)