Customizing the Build functionality

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Customizing the Build functionality

tonymcdaniel
I use a project folder hierarchy where the Project folder contains the
Makefile and Doxyfile files. Then the source files are in Project/src,
the intermediate build products are in Project/build and the doxygen
generated files are in Project/docs.

When I'm editing a source file (ie. Project/src/main.cpp) and use the
"Build" command (or :make), I get an error that no Makefile can be
located. Is there a way to have set the Build command to run make in
the Project directory without having to change directories first?

Another issue is if I'm editing a *.tex file which is part of a larger
project. For instance, if I have a book where the main file is
main.tex which includes chapter1.tex and chapter2.tex, is there a way
to run Build while editing chapter1.tex and have it run on main.tex?
In the past, I've just run latexmk on main.tex and let it auto-update
whenever any of the included files is edited, but I would welcome a
simpler way if one exists.

--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Customizing the Build functionality

Björn Winckler
On 15 August 2011 18:15, tonymcdaniel wrote:
>
> Another issue is if I'm editing a *.tex file which is part of a larger
> project. For instance, if I have a book where the main file is
> main.tex which includes chapter1.tex and chapter2.tex, is there a way
> to run Build while editing chapter1.tex and have it run on main.tex?
> In the past, I've just run latexmk on main.tex and let it auto-update
> whenever any of the included files is edited, but I would welcome a
> simpler way if one exists.

I don't have any answers to your first question, nor any good answers
to this second question, but I can tell you my rather obtuse solution
to this.  I add the line

setl makeprg=pdflatex\ -interaction=nonstopmode\ %:p:h:t

to ~/.vim/ftplugin/tex.vim (create files/folders if they do not exist)
and then I name the folder that all the .tex files are in to the same
as the main .tex file.  E.g. in your example I would have

main/
  main.tex
  chapter1.tex
  ...

Then (in MacVim) I can just hit Cmd-b to create a pdf and it works
regardless whether I'm editing main.tex, chapter1.tex or whatever.tex.
 Note that this only works if the folder and the main .tex file share
a name, which is a bit dumb.

You should probably ask on the vim_use group if you don't find this
answer satisfactory as this really is a general question about Vim and
is not specific to running Vim on the Mac.

Björn

--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Customizing the Build functionality

David Henderson
In reply to this post by tonymcdaniel

On 15 Aug 2011, at 09:15, tonymcdaniel wrote:

> When I'm editing a source file (ie. Project/src/main.cpp) and use the
> "Build" command (or :make), I get an error that no Makefile can be
> located. Is there a way to have set the Build command to run make in
> the Project directory without having to change directories first?
>
I would search vim.org for project manager plugins; there are more than a few. I use project.vim <http://www.vim.org/scripts/script.php?script_id=69> for instance.

> Another issue is if I'm editing a *.tex file which is part of a larger
> project. For instance, if I have a book where the main file is
> main.tex which includes chapter1.tex and chapter2.tex, is there a way
> to run Build while editing chapter1.tex and have it run on main.tex?
> In the past, I've just run latexmk on main.tex and let it auto-update
> whenever any of the included files is edited, but I would welcome a
> simpler way if one exists.

Are you using a plugin like Latex-suite or Latexbox? If you’re using the former, then all you need do is to add a main.latexmain file (empty) in the root of your latex directory. Although project.vim could probably solve the issue as well IIRC.

David P Henderson
c: xxx.xxx.xxxx
--
"Human beings are unable to be honest with themselves about themselves. They cannot talk about themselves without embellishing."
    -- Akira Kurosawa

--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Customizing the Build functionality

Frank Hellenkamp-2
In reply to this post by tonymcdaniel
Hi,

> I use a project folder hierarchy where the Project folder contains the
> Makefile and Doxyfile files. Then the source files are in Project/src,
> the intermediate build products are in Project/build and the doxygen
> generated files are in Project/docs.
>
> When I'm editing a source file (ie. Project/src/main.cpp) and use the
> "Build" command (or :make), I get an error that no Makefile can be
> located. Is there a way to have set the Build command to run make in
> the Project directory without having to change directories first?


I usually just stay in the root of the project-folder (I don't change the working directory), so the PWD is the same folder, where the Makefile is, so you can use make as intended.

This should fix your problem.


The other reason I do this is "sessions":

I autosave my sessions in the current working directory (this is from my vimrc):

    " save session on losing focus
    au FocusLost *
        \ :exe "mks! _vimsession.vis"

    " also save colorscheme
    au FocusLost *
        \ :call writefile(['set bg='.&bg, 'color '.colors_name], '_vimsessionx.vim')
       
So when I want to open my project, i just type:

    :so ~/path-to-project/_vimsession.vis

And all project-files I worked on are opened.
I also have an automator-workflow to do this by doubleclicking on the .vis-file.


Best

Frank

--
frank hellenkamp | interface designer
solmsstraße 7 | 10961 berlin

+49.30.49 78 20 70 | tel
+49.176.32 13 88 89 | mbl
+49.3212.100 35 22 | fax
[hidden email]

http://depage.net | bureau
http://depagecms.net | content management
http://immerdasgleiche.de | read
http://everydayisexactlythesame.net | see

--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php