LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   open new file with vim/gvim (https://www.linuxquestions.org/questions/programming-9/open-new-file-with-vim-gvim-923205/)

RudraB 01-11-2012 03:05 AM

open new file with vim/gvim
 
Dear friends,
How can I open a new fortran file (.f90 extension) with some predefined lines added?
Like, say, if I open a new file foo.f90, can I edit vimrc in such a way that, it will write
1 This is file "foo"
2 Implicit None

any suggestion?

druuna 01-11-2012 05:31 AM

Hi,

Try adding this to your .vimrc file:
Code:

autocmd BufNewFile *.f90 call New_Fortran_File()
fun! New_Fortran_File()
    :0put='This is file : ' . expand('%')
    :put='Implicit None'
    exe ":3"
endf

The above is only activated when a fortran extension is seen (.f90) and the file is new.

Hope this helps.


All times are GMT -5. The time now is 11:42 AM.