Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1091095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:28:18+00:00 2026-05-16T23:28:18+00:00

This is really a newbie question – but basically, how do I enable a

  • 0

This is really a newbie question – but basically, how do I enable a template for certain filetypes.

Basically, I just want the template to insert a header of sorts, that is with some functions that I find useful, and libraries loaded etc.

I interpret

:help template

the way that I should place this in my vimrc

au BufNewFile,BufRead ~/.vim/skeleton.R

Running a R script then shows that something could happen, but apparently does not:

--- Auto-Commands ---

This may be because a template consists of commands (and there are no such in skeleton.R) – and in this case I just want it to insert a text header (which skelton.R consist of).

Sorry if this question is mind boggeling stupid ;-/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:28:18+00:00Added an answer on May 16, 2026 at 11:28 pm

    The command that you’ve suggested is not going to work: what this will do is run no Vim command whenever you open ~/.vim/skeleton.R

    A crude way of achieving what you want would be to use:

    :au BufNewFile *.R r ~/.vim/skeleton.R
    

    This will read (:r) your file whenever a new *.R file is created. You want to avoid having BufRead in the autocmd, or it will read the skeleton file into your working file every time you open the file!

    There are many plugins that add a lot more control to this process. Being the author and therefore completely biased, I’d recommend this one, but there are plenty of others listed here.


    Shameless plug:

    They all work in a relatively similar way, but to explain my script:

    You install the plugin as described on the linked page and then create some templates in ~/.vim/templates. These templates should have the same extension as the ‘target’ file, so if it’s a template for .R files, call it something like skeleton.R. In your .vimrc, add something like this:

    let g:file_template_default = {}
    let g:file_template_default['R'] = 'skeleton'
    

    Then create your new .R file (with a filename, so save it if it’s new) and enter:

    :LoadFileTemplate
    

    You can also skip the .vimrc editing and just do:

    :LoadFileTemplate skeleton
    

    See the website for more details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for this lame question, but I really am a database newbie: I want
This is probably a really newbie question (well, I'm pretty sure it is), but
Sorry fot his newbie question. But I really need a start on this one.
This is really a dumb newbie question, but I am still learning the ropes
This is really a newbie question, but I don't know how to search answers
this is really a newbie question, but it would help me to have a
this is going to be a total newbie question but I can't really do
This is probably a really stupid newbie-sounding question to you developer type people, but
this is probably a really stupid question, but I am big R newbie and.
This is probably a newbie question, but i really need help. I am creating

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.