Mathias Hasselmann

Project specific editor settings

Everyone knows the problem that seemingly each project uses its own code style. So here is my solution for that problem:

$ cat ~/.vim/after/ftplugin/c.vim 
if filereadable('.project.vim')
    source .project.vim
else
    set sw=2 sta et
endif

Maybe you had some better ideas already - I'd like to read about them.

Veröffentlicht am Juli 24, 2008 durch Mathias Hasselmann « 8 Kommentare

Kommentare

fraggle commented on Juli 24, 2008 at 1:10 p.m.

Thank you! I've been wondering about this problem myself for a while now.

One thing, though: if you have a project with multiple subdirectories of source code, it would be nice to have a single project file at the top level, rather than a vim project file in every directory.

Why on earth do you think you should be using Anjuta? Personally I don't think I'd ever give up vim, it's so much more efficient to use than other editors ...

jonner commented on Juli 24, 2008 at 2:02 p.m.

you should be able to put a .vimrc in the root of you project tree and it should be sourced automatically, right?

Panos Laganakos commented on Juli 24, 2008 at 2:04 p.m.

I agree on using Vim, I always try new IDEs and Editors, as soon as they get released.

Once you get used to the modal editing Vim offers, everything else seems redundant.

With all those plugins available I don't ever miss an IDE.

Although I prefer NERDTree over Project.vim

I've read that Anjuta is getting a Vim extension soon, so go Anjuta!

If you're on the Mac too, give MacVim a try, we'll be getting GUI plugins soon :D

Mathias Hasselmann commented on Juli 24, 2008 at 2:06 p.m.

fraggle: vim loads that ".project.vim" file from the current working directory (:help pwd). For me this usually is the project's top-level folder.

Anjuta? Well, more modern?

Juri Pakaste commented on Juli 24, 2008 at 3:30 p.m.

For Emacs, I use this: https://launchpad.net/pgrok/ . It does both mode-specific and general files, looking them up in the same directory as the file being opened or a directory higher up in the tree.

oliver commented on Juli 24, 2008 at 3:34 p.m.

Nice - something like this would be really useful for many projects.

Do you see a way how to use the same file from kate and gedit and others? That would be awesome! Otherwise, I doubt many projects would allow for ten different .project.<someones favorite editor> files in their tree :-)

roktas commented on Juli 24, 2008 at 5:23 p.m.

fraggle: you may find the following VIM script useful:

http://www.vim.org/scripts/script.php?sc...

Marius Gedminas commented on Juli 24, 2008 at 11:07 p.m.

I tend to put project-specific vim stuff into my ~/.vimrc:

autocmd BufRead,BufNewFile * if expand('%:p') =~ 'projectname' | setlocal foo bar baz | endif

I primarily use Python, which has only one popular style guide (PEP-8), so I don't have many project-specific customizations.

Your method is clever and should scale better if you work on multiple projects.

Kommentieren

Optional: Only needed, if you wish to subscribe.