LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-11-2012, 03:05 AM   #1
RudraB
Member
 
Registered: Mar 2007
Distribution: Fedora
Posts: 262

Rep: Reputation: 23
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?
 
Old 01-11-2012, 05:31 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Vi/Vim/gVim vs Kate Diego Torquemada Linux - Newbie 7 04-01-2009 08:19 AM
gvim or vim? Abomb Programming 28 12-14-2006 11:27 PM
prompt within gvim/vim/vi zchoyt Linux - Software 6 02-02-2005 06:30 AM
vim or gvim raees Linux - General 7 03-17-2004 05:02 PM
vim / gvim Shak Linux - Software 4 04-03-2003 09:25 AM


All times are GMT -5. The time now is 06:04 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration