Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foo i()
- ...
- End foo i
- autocmd CursorMovedI *.f90 :call FixName("foo")
- " FixName: Change Subprogram name {{{1
- function! FixName(arg)
- let [buf, l, c, off] = getpos('.')
- call cursor([1, 1, 0])
- let lnum = search('vc^s*' . a:arg . 's+', 'cnW')
- if !lnum
- call cursor(l, c, off)
- return
- endif
- let parts = matchlist(getline(lnum), 'vc^s*' . a:arg . 's+(S*)s*$')
- if len(parts) < 2
- call cursor(l, c, off)
- return
- endif
- let lnum = search('vc^s*Ends*' . a:arg . 's+', 'cnW')
- call cursor(l, c, off)
- if !lnum
- return
- endif
- call setline(lnum, substitute(getline(lnum), 'vc^s*Ends*' . a:arg . 's+zs.*', parts[1], ''))
- endfunction
- call setline(lnum, substitute(getline(lnum), 'vc^s*Ends*' . a:arg . 's+zs.*[?=(]', parts[1], ''))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement