Advertisement
Guest User

Untitled

a guest
Jan 12th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. foo i()
  2. ...
  3. End foo i
  4.  
  5. autocmd CursorMovedI *.f90 :call FixName("foo")
  6.  
  7. " FixName: Change Subprogram name {{{1
  8. function! FixName(arg)
  9. let [buf, l, c, off] = getpos('.')
  10. call cursor([1, 1, 0])
  11.  
  12. let lnum = search('vc^s*' . a:arg . 's+', 'cnW')
  13. if !lnum
  14. call cursor(l, c, off)
  15. return
  16. endif
  17.  
  18. let parts = matchlist(getline(lnum), 'vc^s*' . a:arg . 's+(S*)s*$')
  19. if len(parts) < 2
  20. call cursor(l, c, off)
  21. return
  22. endif
  23.  
  24. let lnum = search('vc^s*Ends*' . a:arg . 's+', 'cnW')
  25. call cursor(l, c, off)
  26. if !lnum
  27. return
  28. endif
  29.  
  30. call setline(lnum, substitute(getline(lnum), 'vc^s*Ends*' . a:arg . 's+zs.*', parts[1], ''))
  31. endfunction
  32.  
  33. 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