i have the following problem , and once again i need your help.
i have the following configuration for sessions:
set sessionoptions+=resize
set sessionoptions+=slash
set sessionoptions+=unix
set sessionoptions+=winpos
to save a session i do: mksession ~/sessions/session_name.vim
and to load a session i do: source ~/sessions/session_name.vim
The problem is observable with files on different folders, for example if i have
~/folder/file1
~/folder/file2
~/folder/folder2/file3
I open them {in this orded if it matters} on different tabs and then i issue a
mksession ~/sessions/sample.vim
then on a different gvim i do
source ~/sessions/sample.vim
the result is that gvim opens all files on different tabs, *but* the
file3 is blank! {file3 is the file on the different directory than the
other 2.
the sessions work great if i load gvim with -u NONE and then save the
session option...
and then open them from a gvim -u NONE.
sessions fail if i save from a gvim -u NONE but try to open them from
a "normal" gvim..
any idea why this happens? maybe some other setting is causing it?{but which?}
Likely, you have 'autochdir' set somewhere in your startup files. You
can find out which file by executing ":verbose set autochdir". That
setting used to cause problems for me when reloading sessions. I used
to work around this problem with an autocommand similar to this:
autocmd BufWinEnter * exe 'lcd ' . expand('%:h')
I eventually quit using this for reasons I can't recall. It may have
problems as well.
'autochdir' is a Boolean option. Don't use
:verbose set autochdir
because it would _set_ the option and say nothing. Instead, use
:verbose set autochdir?
_with_ a question mark, to see the current value and where it was set.
Best regards,
Tony.
--
GUARD #1: Where'd you get the coconut?
ARTHUR: We found them.
GUARD #1: Found them? In Mercea? The coconut's tropical!
ARTHUR: What do you mean?
GUARD #1: Well, this is a temperate zone.
The Quest for the Holy Grail (Monty
Python)
amenu <silent>&simple.Enable\ autochdir :set autochdir <cr>
amenu <silent>&simple.Disable\ autochdir :set noautochdir <cr>
amenu <silent>&simple.autochdir\ Status :verbose set autochdir? <cr>
i have added a menu so that i can disable and enable autochdir with buttons.
i have 2 questions concerning the menu:
* is there any way to make an entry toggle-autochdir that will toggle
the the autochdir option?
*how can i present the state of autochdir in the status line?
currently i have the following:
set statusline=[FORMAT=%{&ff}]\ [TYPE=%Y]\
[Line,Column]=[%04l,%04v][%p%%]\ [%L\ Lines]\ [FILE=%F%m%r%h%w]
thanks in advance for your answers,
nicolas
is there any way to make vim save by default all sessions in the
specific folder and load from this specific folder.
so that i can do the following:
mksession session_name.vim
source session_name.vim
if this is not possible, can i define a sort of variable so that i can
something like this:
mksession $SESSION_DIR/session_name.vim
source $SESSION_DIR/session_name.vim
-nicolas
The simplest way to do this is probably to write your own commands to
load and save the sessions. As a bonus, these commands could do the
toggling of autochdir for you. My preference for any remotely complex
command is to write a function and bind the command to the function:
let g:my_session_dir = '~/.vim/sessions'
function! MakeSession(sessionName)
set noautochdir
" I'd love to know if there's a way to avoid :exe here.
exe ':mksession! ' . g:my_session_dir . '/' . a:sessionName
set autochdir
endfunction
command! -nargs=1 MKSession :call MakeSession(<f-args>)
The above is barely tested. I'll leave "loadession" as an exercise
for the reader. Relevant help sections in the manual are:
:he user-commands
:he 40.2
:he user-functions
:he 41.7
amenu <silent> &simple.Toggle\ autochdir :set autochdir!<CR>
(":set invautochdir" would also work, and you can shorten 'autochdir' to
'acd'
>
> *how can i present the state of autochdir in the status line?
>
> currently i have the following:
>
> set statusline=[FORMAT=%{&ff}]\ [TYPE=%Y]\
> [Line,Column]=[%04l,%04v][%p%%]\ [%L\ Lines]\ [FILE=%F%m%r%h%w]
e.g. add somewhere in your custom status line
%{&acd?'[acd]':''}
BTW your statusline looks wasteful of screen space. I use
if has("statusline")
set statusline=%<%f\ %h%m%r%=%k[%{(&fenc\ ==\
\"\"?&enc:&fenc).(&bomb?\",BOM\":\"\")}][U+%04B]\ %-12.(%l,%c%V%)\ %P
endif
>
> thanks in advance for your answers,
>
> nicolas
Best regards,
Tony.
--
Death is only a state of mind.
Only it doesn't leave you much time to think about anything else.
Tony i think i have some questions regarding the use of the
statusline....i will search a bit a more and then i will come back and
ask!
thanks
-nicolas