Advertisement
Guest User

Untitled

a guest
May 31st, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. For those of you who may (still !) have to read/code in Fortran, using VIM, if you're navigating in a huge project written ages ago by people who were better at science than at coding, this might come in handy.
  2.  
  3. This little script ads to your VIMs *statusline* the **name of the subroutine** youre cursor is currently in. It proved very useful for me, especially when dealing with similar subroutines that I did not write myself in the first place.
  4.  
  5. The following function extract the name of the current subroutine :
  6.  
  7. function! SubName() abort
  8. if &syntax!='fortran'
  9. return ''
  10. endif
  11. let line_num = search('subroutine', 'bncW')
  12. return ' '.matchstr(getline(line_num), 'subroutine \zs\w\+').' '
  13. endfunction
  14.  
  15. The next line updates your `statusline` :
  16.  
  17. set statusline+=%8*%{SubName()}
  18.  
  19. You may want to have
  20.  
  21. set laststatus=2
  22.  
  23. so that your statusline is always displayed, even when your window isn't splitted.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement