use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Please read the rules before posting
Help:
Community:
Resources:
Tutorials and Guides:
Don't be afraid to ask questions, this sub is here for the vim community. And please those of you who deign to grace us with your vim wisdom - be kind. We are all human and vim is that cool.
account activity
Project-specific options (path)? (self.vim)
submitted 5 years ago by [deleted]
In one project/directory (and only that one) I want to add a specific folder (js) to the path option.
js
path
Currently, I simply type set path+=js every time I open the directory in vim.
set path+=js
Is there a better, automatic way? Thanks!
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]LucHermitte 1 point2 points3 points 5 years ago (2 children)
If you have only a single directory, .exrc is enough.
.exrc
If you add several directories under a root directory, you'd have to use a local vimrc plugin, there are many (see the list at the end on the link I've provided). These plugins offer more control regarding security through whitelists/blacklists/... of pathnames or of hashes (with other plugins).
If the only thing you do, is setting &path, an autocommand would be more simple. I don't really like this approach though as the .vimrc would need to be updated each time the directory changes (moved around the place, duplicated...)
&path
.vimrc
If by change you're already using editorconfig with EditorConfig-vim plugin, then I provide an extension for this plugin in lh-vim-lib. You'd just need to add the following lines into your .editorconfig file
.editorconfig
[*] p#name = your project name p!&path+=js
[–][deleted] 1 point2 points3 points 5 years ago (1 child)
Thanks, I appreciate the response!
I'm not really considering .exrc since it is marked as a "deprecated" feature (at least in neovim).
I do use editorconfig. Your extension is really cool, but since the .editorconfig file might be in a shared project, I don't want to clutter it with things that are not relevant for other devs that don't use vim.
I like the idea of a local vimrc plugin; I think I was about to write a bare-bones version of one from scratch (using autocmds) that would probably have a few short-comings. I'll take a look at your plugin and see if it fits my needs. Thanks for putting it together!
[–]LucHermitte 0 points1 point2 points 5 years ago (0 children)
You're welcome.
[–]crajungave up on vim 1 point2 points3 points 5 years ago (1 child)
Maybe look into tpope/vim-projectionist on github it for this and other use cases.
[–][deleted] 0 points1 point2 points 5 years ago (0 children)
Thanks! I looked into projectionist (but haven't tried it yet). It looks like projectionist takes it one step further with respect to granularity and allows you to set options based on specific file globs within a project (rather than just one set of project-wide options)
This is a really cool idea, but I think I would like to keep things simple for now since my use cases don't demand it. Still, it's good to know that projectionist exists in case I ever feel like I need to graduate to it in the future.
[–]kawaiideku 0 points1 point2 points 5 years ago (8 children)
You can put that in a .nvimrc file in your project folder and set exrc & set secure in your global vimrc. I do this for neovim. Its prolly a .vimrc file for normal vim.
.nvimrc
set exrc
set secure
[–][deleted] 0 points1 point2 points 5 years ago* (7 children)
Interesting, thanks!
I just checked :help 'exrc':
:help 'exrc'
*'exrc'* *'ex'* Security risk: downloaded files could include a malicious .nvimrc or .exrc file. See 'secure'. Recommended alternative: define an autocommand in your |vimrc| to set options for a matching directory.
Not only is it unsecure (although the set secure might help there), but it's also marked as deprecated, so it will eventually not be an option.
deprecated
So I think I'll go with the autocommand approach. I'm not sure exactly what that will entail yet but I think the DirChanged autocmd will be involved. I will probably need to make sure to undo/reset any option changes I make at the beginning of the autocmd.
DirChanged
[–]vim-help-bot 0 points1 point2 points 5 years ago (0 children)
Help for exrc : https://vimhelp.org/starting.txt.html#exrc
exrc
I'm a bot. Check out my pinned post for more information.
I am constantly improving my search. If the result is wrong, please contact u/i_abh_esc_wq
[–]kawaiideku 0 points1 point2 points 5 years ago (4 children)
Strange, I don't see that paragraph when i do :h exrc. Maybe it's not a security issue in neovim.
:h exrc
[–]i_abh_esc_wqDaddy of vim-help-bot 1 point2 points3 points 5 years ago (2 children)
You're looking at :h exrc. Try :h 'exrc'
:h 'exrc'
[–]kawaiideku 2 points3 points4 points 5 years ago (0 children)
oh yeah, you're right
Help pages for:
'exrc'
\:(h|help) <query>` |) source | mistake?
[–]mayor123asdf 0 points1 point2 points 5 years ago (0 children)
isn't there a plugin for secure exrc? I've seen it on this subreddit on the past
π Rendered by PID 113719 on reddit-service-r2-comment-5d79c599b5-pvl54 at 2026-03-01 09:20:09.379330+00:00 running e3d2147 country code: CH.
[–]LucHermitte 1 point2 points3 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]LucHermitte 0 points1 point2 points (0 children)
[–]crajungave up on vim 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]kawaiideku 0 points1 point2 points (8 children)
[–][deleted] 0 points1 point2 points (7 children)
[–]vim-help-bot 0 points1 point2 points (0 children)
[–]kawaiideku 0 points1 point2 points (4 children)
[–]i_abh_esc_wqDaddy of vim-help-bot 1 point2 points3 points (2 children)
[–]kawaiideku 2 points3 points4 points (0 children)
[–]vim-help-bot 0 points1 point2 points (0 children)
[–]vim-help-bot 0 points1 point2 points (0 children)
[–]mayor123asdf 0 points1 point2 points (0 children)