I am writing a little hack for vim session that will save and load sessions more conveniently - I am aiming for more project-style sessions.
When you are in directory my-proj
and call vim
, it should automatically open the session associated with the current directory. (This is 'almost' working so far - the problem is with getting the current directory). Saving the 'project' (i.e. a session) can be done with SaveSession
I have done this so far:
let g:session_autosave = 'yes'
let g:session_autoload = 'yes'
let g:session_default_name = getcwd()
The minor problem is, if I call vim ~/x.txt
, getcwd()
will not return ~/x.txt
. It will return the current directory in bash (which could be almost anything). How can I get the directory that vim was called on in the command line (i.e. ~
in this case)? And if vim was opened with just vim
then it should get the current working directory.
:h autochdir
will help you.