I have a function I wrote specifically for a certain session in vim. Manually redefining it every time I load the session is tedious. Is there any way custom functions can be saved with the session? If not, what're some options for speeding up reloading that function every time I load the session?
Put the function in a file with the same name as your session file but ending in
x.vim as described in item 10 under
Assuming the functions are something you don't want all the time, so you don't want them in your
.vimrc file, you can define them in a separate file and use
:source filename to load in the definitions. This avoids the security issues of
set exrc and loading untrusted files.
If the pathname to your functions file is irritatingly long, you could even define a function in your
.vimrc just to call
Assuming that “certain session” means “certain project” and “certain directory” I would try to use the per-project
.vimrc file. To get vim to additionally read the
.vimrc in the current directory, I have
set exrc in my