SHARE
TWEET

Untitled

a guest Jan 12th, 2017 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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], ''))
RAW Paste Data
Top