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

  • SEARCH
  • Home
  • 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 834535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:41:12+00:00 2026-05-15T04:41:12+00:00

When I create a .tex file using vim I get a nice template from

  • 0

When I create a .tex file using vim I get a nice template from having

autocmd BufNewFile *.tex 0r $HOME/.vim/templates/skeleton.tex

in my .vimrc. I also have a makefile-template in my home directory, but this one I have to manually copy to where the .tex file is. In a Linux environment, how can I auto-copy or auto-generate the makefile at the same time as I create a .tex file?

  • 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-15T04:41:12+00:00Added an answer on May 15, 2026 at 4:41 am

    The portable answer would not use cp (which may overwrite a preexisting makefile) but the vim functions readfile() and writefile().

    To trigger it, the best thing would be to define and execute a function that loads the first skeleton, and creates the Makefile on the fly:

    " untested code
    "
    function! s:NewTeXPlusMakefile()
      let where = expand('%:p:h')
      " see mu-template's fork for a more advanced way to find template-files
      let skeletons_path = globpath(&rtp, 'templates')
    
      " the current .tex file
      let lines = readfile(skeletons_path.'/skeleton.tex')
      call setline(1, lines)
    
      " the Makefile, that MUST not be overwritten when it already exists!
      let makefile = where.'/Makefile'
      if ! filereadable(makefile)
        let lines = readfile(skeletons_path.'/skeleton.makefile')
        call writefile(lines, makefile )
      endif
    endfunction
    
    augroup LaTeXTemplates
      au!
      au BufNewFile *.tex call s:NewTeXPlusMakefile()
    augroup END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the next code written in C#....it create a tex file using utf-8.....the
I'm using ctags to create a tags file for use in Vim, so that
I need to generate a pdf from a tex file, as a temporary file.
I am trying to get the following: [today's date]___[textfilename].txt from the following code: using
I need to get my code to read if file doesnt exist create else
Create a new appdomain, setup the assemblyResolve handler and you always get an exception
Scenario: I have a main Latex file (main.tex) in which I include a subfile
I am using visual c++ 2005 .net and I am looking to create a
I have a Ruby script that produces a Latex document using an erb template.
For certain reasons, I have to create a 1024 kb .txt file. Below is

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.