xolox / vim-session Goto Github PK
View Code? Open in Web Editor NEWExtended session management for Vim (:mksession on steroids)
Home Page: http://peterodding.com/code/vim/session/
Extended session management for Vim (:mksession on steroids)
Home Page: http://peterodding.com/code/vim/session/
I have a use case that doesn't seem too unusual that would be incredibly useful to myself: usually, I don't want to make a default.vim session in any directory I happen to open vim in, otherwise I litter my clean directories with sessions from random times I needed vim open. On the other hand, if I have been using sessions (e.g. default.vim exists) I would like the autosave functionality to be "yes" so that when I quit, default.vim reflects the state of vim before exiting.
In essence, a fourth option of "ifexists", which acts like "no" if there isn't a default.vim in the current directory, and "yes" if there is one. This way, I don't litter my drive with sessions files, but get the autosave functionality where I have explicitly called SaveSession before.
~ Jonathan Martin
when no session is open and there are no existing sessions then when the user quits vim without invoking :SaveSession it would be nice if the plugin asked him whether he wants to save the current environment as a session. or it could silently store the environment as the 'default' session (based on some option).
this change will enable the following scenario: you download vim-session, install it, put some lines into your .vimrc and forget about the plugin. also some users might forget to invoke :SaveSession for the first time and thus lose their environment.
Updated to cfc5bdf today — not sure from what, just something relatively recent. Since then I get on starting vim (7.3.1030 on Arch Linux):
Error detected while processing /home/nwt/.vim/bundle/vim-session/plugin/session.vim:
line 72:
E117: Unknown function: xolox#misc#os#is_win
E15: Invalid expression: xolox#misc#os#is_win()
line 86:
E121: Undefined variable: g:session_directory
E116: Invalid arguments for function fnamemodify(g:session_directory, ':p')
E15: Invalid expression: fnamemodify(g:session_directory, ':p')
line 87:
E121: Undefined variable: s:directory
E116: Invalid arguments for function isdirectory(s:directory)
E15: Invalid expression: !isdirectory(s:directory)
line 90:
E121: Undefined variable: s:directory
E116: Invalid arguments for function filewritable(s:directory) != 2
E15: Invalid expression: filewritable(s:directory) != 2
line 96:
E108: No such variable: "s:directory"
I'd love to have an option to configure the default name vim-session uses.
My use case: I'd like to only use vim-session when I'm working on big projects, and I'd like to save a session per project. I'm using g:session_directory = '.'
to save the session to the project directory, but I want to have the name be a dotfile that I can easily ignore (and also put in my global gitignore). I manually changed the name of the default in my own fork but it would be great if this were an option.
Hello. After I've updated vim-session plugin I have an error popup on my gvim startup with following message:
Error detected while processing C:\Users\rgr.vim\bundle\vim-session\plug
in\session.vim:
line 72: E117: Unknown function: xolox#misc#os#is_win
E15: Invalid expression: xolox#misc#os#is_win()
line 86:
E121: Undefined variable: g:session_directory
E116: Invalid arguments for function fnamemodify(g:session_directory, ':p')
E15: Invalid expression: fnamemodify(g:session_directory, ':p')
line 87:
E121: Undefined variable: s:directory
E116: Invalid arguments for function isdirectory(s:directory)
E15: Invalid expression: !isdirectory(s:directory)
line 90:
E121: Undefined variable: s:directory
E116: Invalid arguments for function filewritable(s:directory) != 2
E15: Invalid expression: filewritable(s:directory) != 2
line 96:
E108: No such variable: "s:directory"
I'm having issues on default installation of this plugin.
Steps to reproduce my issue:
During gvim startup I see an error message:
Error detected while processing function xolox#session#auto_load..54_prompt:
line 9:
E121: Undefined variable: a:var
Press ENTER or type command to continue
Please note that I'm not doing any configuration. Just installing
Here is my ~/.vim/sessions/default.vim:
" ~/.vim/sessions/default.vim: Vim session script.
" Created by session.vim 1.7 on 03 May 2013 at 13:24:15.
" Open this file in Vim and run :source % to restore your session.
set guioptions=aegimrLtT
silent! set guifont=
if exists('g:syntax_on') != 1 | syntax on | endif
if exists('g:did_load_filetypes') != 1 | filetype on | endif
if exists('g:did_load_ftplugin') != 1 | filetype plugin on | endif
if exists('g:did_indent_on') != 1 | filetype indent on | endif
if &background != 'dark'
set background=dark
endif
if !exists('g:colors_name') || g:colors_name != 'solarized' | colorscheme solarized | endif
call setqflist([])
let SessionLoad = 1
if &cp | set nocp | endif
let s:so_save = &so | let s:siso_save = &siso | set so=0 siso=0
let v:this_session=expand("<sfile>:p")
silent only
cd ~/.vim/sessions
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
let s:wipebuf = bufnr('%')
endif
set shortmess=aoO
badd +1 /tmp/test.txt
silent! argdel *
edit /tmp/test.txt
set splitbelow splitright
set nosplitbelow
set nosplitright
wincmd t
set winheight=1 winwidth=1
" argglobal
setlocal fdm=manual
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=#
setlocal fdl=0
setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
let s:l = 1 - ((0 * winheight(0) + 20) / 41)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
1
normal! 0
tabnext 1
if exists('s:wipebuf')
silent exe 'bwipe ' . s:wipebuf
endif
unlet! s:wipebuf
set winheight=1 winwidth=20 shortmess=filnxtToO
let s:sx = expand("<sfile>:p:r")."x.vim"
if file_readable(s:sx)
exe "source " . fnameescape(s:sx)
endif
let &so = s:so_save | let &siso = s:siso_save
tabnext 1
1wincmd w
doautoall SessionLoadPost
unlet SessionLoad
" vim: ft=vim ro nowrap smc=128
Hello,
What do you think about add some menu entries (for gvim)?
For example, I have:
amenu 10.321 &File.Open\ Session\.\.\. :OpenSession<CR>
What about to add something like this to core plugin?
Error detected while processing function xolox#session#auto_load:
line 8:
E117: Unknown function: xolox#misc#option#split
Press ENTER or type command to continue
Error detected while processing function xolox#session#auto_load:
line 8:
E116: Invalid arguments for function index(xolox#misc#option#split(&viminfo), '%') >= 0)
Press ENTER or type command to continue
Error detected while processing function xolox#session#auto_load:
line 8:
E15: Invalid expression: (index(xolox#misc#option#split(&viminfo), '%') >= 0)
Press ENTER or type command to continue
Error detected while processing function xolox#session#auto_load..xolox#session#get_names:
line 1:
E121: Undefined variable: g:session_directory
Press ENTER or type command to continue
Error detected while processing function xolox#session#auto_load..xolox#session#get_names:
line 1:
E116: Invalid arguments for function xolox#misc#path#absolute(g:session_directory)
Press ENTER or type command to continue
Error detected while processing function xolox#session#auto_load..xolox#session#get_names:
line 1:
E15: Invalid expression: xolox#misc#path#absolute(g:session_directory)
Press ENTER or type command to continue
Error detected while processing function xolox#session#auto_load..xolox#session#get_names:
line 2:
E121: Undefined variable: directory
Press ENTER or type command to continue
Error detected while processing function xolox#session#auto_load..xolox#session#get_names:
line 2:
E116: Invalid arguments for function xolox#misc#path#merge(directory, '*' . g:session_extension)), "\n")
TagBar (https://github.com/majutsushi/tagbar) creates buffer TagBar that also should be treated specially.
Error detected while processing /home/vampas/.Dotfiles/vim/bundle/vim-session/plugin/session.vim:
line 72:
E117: Unknown function: xolox#misc#os#is_win
E15: Invalid expression: xolox#misc#os#is_win()
line 86:
E121: Undefined variable: g:session_directory
E116: Invalid arguments for function fnamemodify(g:session_directory, ':p')
E15: Invalid expression: fnamemodify(g:session_directory, ':p')
line 87:
E121: Undefined variable: s:directory
E116: Invalid arguments for function isdirectory(s:directory)
E15: Invalid expression: !isdirectory(s:directory)
line 90:
E121: Undefined variable: s:directory
E116: Invalid arguments for function filewritable(s:directory) != 2
E15: Invalid expression: filewritable(s:directory) != 2
line 96:
E108: No such variable: "s:directory"
Press ENTER or type command to continue
Right now i have a session that's over 800 lines... I've been working on this client project awhile, and that's the output of many many days of opening and closing the same session.
in fact, scarily:
% grep -c badd redstamp.vim
829
I don't really want this many buffers open. :(
i've resorted to deleting the session, and starting again -- but i wonder, could you consider -- if there's any way? to be able to rebuild/reset the session with whatever is currently in view? I don't need hidden or unloaded buffers, for example, nor do i want to have settings that i've set, unset, etc.
or another best case way of doing it?
in autoload / xolox / session.vim, if is_all_tabs, xolox#session#save_colors(a:commands) has been called,
add an option let savesession not call this.
With this error:
Error detected while processing function xolox#session#complete_names..xolox#session#get_names:
line 5:
E121: Undefined variable: g:session_directory
E116: Invalid arguments for function xolox#misc#path#absolute(g:session_directory)
E15: Invalid expression: xolox#misc#path#absolute(g:session_directory)
line 6:
E121: Undefined variable: directory
E116: Invalid arguments for function xolox#misc#path#merge(directory, '' . g:session_extension)), "\n")
E116: Invalid arguments for function glob(xolox#misc#path#merge(directory, '' . g:session_extension)), "\n")
E116: Invalid arguments for function split(glob(xolox#misc#path#merge(directory, '' . g:session_extension)), "\n")
E15: Invalid expression: split(glob(xolox#misc#path#merge(directory, '' . g:session_extension)), "\n")
line 7:
E121: Undefined variable: filenames
E116: Invalid arguments for function map(filenames, 'xolox#session#path_to_name(v:val)')
E15: Invalid expression: map(filenames, 'xolox#session#path_to_name(v:val)')
Error detected while processing function xolox#session#complete_names:
line 3:
E712: Argument of filter() must be a List or Dictionary
line 4:
E712: Argument of map() must be a List or Dictionary
I have no idea it doesnt work :( i looked at the doc's known issues( https://github.com/xolox/vim-session/blob/master/doc/session.txt#L465 ) but couldn't find anything out.
This commit aadb3a2 cause some troubles to me. Every time I saved a session, it added an empty buffer in the beginning. Does it the normal behavior?
If I have:
let $TODAYS_DATE = strftime('%b_%d')
in my .vimrc file,
I'd like to be able to run
:SessionSave $TODAYS_DATE
and result in a Aug_17.vim
file instead of a $TODAYS_DATE.vim
file.
i installed this plugin without any modification
commands all run well
but just no autosave/load even i enabled the opts.
echo checked in vim, they are set to 1
but still no luck...
anything i miss?
what i put in my vimrc is:
let g:session_autosave = 1
let g:session_autoload = 1
also tried;
let g:session_command_aliases = 1
let g:session_directory = "~/.vim_runtime/sessions"
let g:session_autoload = 'yes'
let g:session_autosave = 'yes'
no luck..
thanks
hi,
just found out that there is a problem if I use NERDTreeMirror and save that as a session ...
best regards
ST
Error detected while processing /Users/IT001-xu/.vim/bundle/vim-session/plugin/session.vim:
line 72:
E117: Unknown function: xolox#misc#os#is_win
E15: Invalid expression: xolox#misc#os#is_win()
line 86:
E121: Undefined variable: g:session_directory
E116: Invalid arguments for function fnamemodify(g:session_directory, ':p')
E15: Invalid expression: fnamemodify(g:session_directory, ':p')
line 87:
E121: Undefined variable: s:directory
E116: Invalid arguments for function isdirectory(s:directory)
E15: Invalid expression: !isdirectory(s:directory)
line 90:
E121: Undefined variable: s:directory
E116: Invalid arguments for function filewritable(s:directory) != 2
E15: Invalid expression: filewritable(s:directory) != 2
line 96:
E108: No such variable: "s:directory"
Hi, your plugin is great, thanks for it. This is a feature request.
I compiled vim my self and run it from a non standard location, i made sure theres always a $VIMRUNTIME enviromental variable.
When using :RestartVim it opens a new vim without my .vimrc loaded. This file is in the standard place ~/.vimrc
I tried debugging the function that does the restart but it is beyond my skills.
I made symlinks of my vim binaries to /usr/local/bin with the default names vim and gvim.
Thanks again.
hi - I use the solarized theme which is configured in this way:
set t_Co=256
set background=dark
let g:solarized_termcolors=256
colorscheme solarized
after loading a session with OpenSession, the background is set to light instead of dark -
is there a way to save also the background variable?
I am using your plugins session and easytags (and the following folder names for it: easytags
, session
and vim-misc
).
When using "vim-misc" as "vim-misc", but "vim-session" as "session" in the bundle folder, the following error is triggered:
Error detected while processing function <SNR>41_InitEasyTags..<SNR>41_CheckCtags..xolox#misc#os#exec:
line 6:
E731: using Dictionary as a String
Error detected while processing function <SNR>41_InitEasyTags..<SNR>41_CheckCtags:
line 6:
E171: Missing :endif
Error detected while processing function <SNR>41_InitEasyTags:
line 3:
E171: Missing :endif
Error detected while processing /home/daniel/.dotfiles/vim/bundle/easytags/plugin/easytags.vim:
line 121:
E171: Missing :endif
I guess that it is related to easytags using the xolox#misc
functions from the session plugin.
Renaming session
to vim-session
works around this.
When I open a file without a session specified, make a quick edit and then close a file. I expect that when I start gvim with no parameters that it will start back up a default session with that file I was editing.
This does not appear to happen. An explicit SaveSession works great, but not the automatic save.
My pertinent vimrc settings are:
let g:session_autoload = 'yes'
let g:session_autosave = 'yes'
let g:session_autosave_periodic = 2
let g:session_default_to_last = 1
set sessionoptions-=help
Cheers!
In issue #19 @diego898 reports the following two unrelated problems:
Things seem to be working although there is two slightly strange things:
- The current directory on NERDTree is not saved with the session. It always starts on ~/myname/Desktop, the directory I make gvim start out of by the shortcut I use. Vim's cwd changes quickly however, due to things in my vimrc that makes its current directory match that of the open file.
- Upon startup, both nerdtree and the file that is shown (correctly coming over from my last session which is good) are both shown at their very very bottom. In other words, a file with lines 1-30, starts with line 30 at the very top of my screen with vim showing me ~ for 70 lines? NERDTree also starts "too high" as it were. A quick gg fixes it, just found it a little strange.
Since these are new problems I'm closing #19 and using this new issue to keep track of them instead.
Similar to the other BufExplorer and TagBar issues, MiniBufExplorer creates a special -MiniBufExplorer-
buffer that creates problems when restoring sessions. It works fine with bare Vim sessions, so I guess if you just skip saving this buffer it should work?
:RestartVim
stopped working since version 2.3.1 (f1cb34e).
I've tested on Windows with a fresh gVim installation, and after issuing the command this error message is displayed:
session.vim 2.3.2: Saved global session 'default' to ~\vimfiles\sessions\default.vim.
session.vim 2.3.2: Closed global session 'default'.
Error detected while processing function xolox#session#restart_cmd:
line 23:
E371: Command not found
It seems that problem can be traced to commit 5ad0d15, which introduces xolox#misc#os#find_vim()
. The problem is that it is returning an empty string.
The plugin shouldn't save [BufExplorer] buffer made by BufExplorer plugin (https://github.com/vim-scripts/bufexplorer.zip.git). The plugin warns 'The buffer name was [[BufExplorer]] so it was skipped.' when you try to activate [BufExplorer] buffer.
vim-session is currently not working with vim 7.0 because of the missing haslocaldir()
function.
I got it to work by changing the line
if haslocaldir()
to
if exists("*haslocaldir") && haslocaldir()
in autoload.vim.
I call OpenSession as soon as vim starts to resume my previous editing session.
Everything looks OK -- my NERDTree window comes back fine, and my editor pane comes back but my syntax highlighting is not automatically enabled. :set filetype
returns nothing.
If I open a file with vim directly, the filetype does get appropriately set, just not when resuming a session.
in autoload session.vim
if is_all_tabs
call add(a:commands, 'set guioptions=' . escape(&go, ' "\'))
call add(a:commands, 'silent! set guifont=' . escape(&gfn, ' "\'))
endif
please add guioptions and guifont only when gui_running or gui_macvim
in terminal vim save session will lose gui info
and please add macvim when check gui_running by gui_macvim
I installed the plugin with Vundle using Bundle 'xolox/vim-session
in my ~/.vimrc
file, but, since the last time I ran the command to update all the plugins, every time I open Vim, I get this errors:
linha 72:
E117: Função desconhecida: xolox#misc#os#is_win
E15: Expressão inválida: xolox#misc#os#is_win()
linha 86:
E121: Variável indefinida: g:session_directory
E116: Argumentos inválidos para a função fnamemodify(g:session_directory, ':p')
E15: Expressão inválida: fnamemodify(g:session_directory, ':p')
linha 87:
E121: Variável indefinida: s:directory
E116: Argumentos inválidos para a função isdirectory(s:directory)
E15: Expressão inválida: !isdirectory(s:directory)
linha 90:
E121: Variável indefinida: s:directory
E116: Argumentos inválidos para a função filewritable(s:directory) != 2
E15: Expressão inválida: filewritable(s:directory) != 2
linha 96:
E108: Variável inexistente: "s:directory"
It's in brazilian portuguese. The correspondence is:
Error detected while processing /home/agummer/.vimrepo/pathogen/bundle/session/plugin/session.vim:
line 72:
E117: Unknown function: xolox#misc#os#is_win
E15: Invalid expression: xolox#misc#os#is_win()
line 86:
E121: Undefined variable: g:session_directory
E116: Invalid arguments for function fnamemodify(g:session_directory, ':p')
E15: Invalid expression: fnamemodify(g:session_directory, ':p')
line 87:
E121: Undefined variable: s:directory
E116: Invalid arguments for function isdirectory(s:directory)
E15: Invalid expression: !isdirectory(s:directory)
line 90:
E121: Undefined variable: s:directory
E116: Invalid arguments for function filewritable(s:directory) != 2
E15: Invalid expression: filewritable(s:directory) != 2
line 96:
E108: No such variable: "s:directory"
Press ENTER or type command to continue
I normally browse with NERDTree open in the current project folder. NERDTree sits in its own tab (at tab position 0) and I open each project file in a new tab.
Using either :SaveSession
or autosave, I can reload my last session, but one tab is missing--the one next to the NERDTree tab.
If I keep a file open in the same tab as NERDTree, this doesn't seem to happen.
I don't like to remember to much command in different plugin, so my customization is change
Action + 'Session'
To
'Session'+Action
The benefit is autocomplete in console, and rotate the commands. Maybe we can just add some command alias to keep the back compatibility.
Here is my folk :
Not sure if other people have gotten this but using sessions with ConqueTerm it wont work. It'll just leave a blank buffer instead of where I was in the command session. Thanks for the plugins! They rock!
After did the update, whenever I tried to open vim it always gives me this errro:
Error detected while processing /Users/cnbuff410/.vim/bundle/vim-session/plugin/session.vim:
line 72:
E117: Unknown function: xolox#misc#os#is_win
E15: Invalid expression: xolox#misc#os#is_win()
line 86:
E121: Undefined variable: g:session_directory
E116: Invalid arguments for function fnamemodify(g:session_directory, ':p')
E15: Invalid expression: fnamemodify(g:session_directory, ':p')
line 87:
E121: Undefined variable: s:directory
E116: Invalid arguments for function isdirectory(s:directory)
E15: Invalid expression: !isdirectory(s:directory)
line 90:
E121: Undefined variable: s:directory
E116: Invalid arguments for function filewritable(s:directory) != 2
E15: Invalid expression: filewritable(s:directory) != 2
line 96:
E108: No such variable: "s:directory"
I've noticed that this plugin doesn't work well with vimwiki plugin
(http://www.vim.org/scripts/script.php?script_id=2226) - it corrupt some of
the mappings.
Steps to reproduce de fault:
:e temp.wiki -> by default vimwiki will create some normal mode mappings
for some commands, such as 'O' and 'gqq'.
insert some text, save the file and the session with :SaveSession testWiki
either call :RestartVim or close the current instance of Vim and load the
session testWiki
normal 'O' now inserts nmap \wr VimwikiRenameLink"
instead of new line, while 'gqq' doesn't format the line and gives an
error.
Every time I Use the OpenSession command to restore a previous saved session, the last file I used comes as an empty and duplicated file. I have to delete the buffer and select the one that works. Is a little anoying. I'm using buffergator just in case it has something to do.
Thanks
Win7 using GVIM 7.2
I open multiple buffers but only the current one is saved when using SaveSession.
When I look at the sessions/default.vim file I see a line for
silent edit C:\stuff\python\blueslug\blueslug\views.py
vim-session does not currently mark a session as dirty if the working directory changes. This means that if I open a session, 'cd' (or 'lcd') and then close the session, the updated session, with new working directory, will not be saved.
Out of curiosity, what is the reason for the dirty flag? Is it mainly so that users with autosave disabled won't get spurious save prompts?
My current thinking is that this feature may cause more problems than it solves. Dirty checks only check if the buffer list or layout have changed, which misses a lot of options that get saved with the session.
It would be great if g:session_directory
would respect a trailing //
, the same way that the built-in dir
does. That way, I could just keep the sessions for all my projects in a central location, the way I do with swap and backup files.
In case you're not familiar with this option, this is in :help dir
:
For Unix and Win32, if a directory ends in two path separators "//" or "", the swap file name will be built from the complete path to the file with all path separators substituted to percent '%' signs. This will ensure file name uniqueness in the preserve directory. On Win32, when a separating comma is following, you must use "//", since "" will include the comma in the file name.
(This would be an alternative of solving the use case I presented in #22.)
I recall using this command in the past and it doesn't seem to be working now. When I type :RestartVim
in Macvim, the tabs close, an error message blinks in the bottom area and then vim just closes. On the plus side, everything seems to be saving correctly.
I uploaded a gist of the debug output for mvim -v9error.log
. There's more to the log file, but I'm pretty sure this is the part where :RestartVim
is called.
Could you put the MIME type (.zip) into the download URL (currently it just says http://peterodding.com/code/vim/downloads/session
)? That would make it much easier to integrate it in Janus without any special installation scripting. Another solution would be to have the full content on GitHub. As when I just copy those files (autoload.vim and session.vim) it doesn't seem to work.
When open a nerdtree window and save session and quite vim, then open vim open that session, the nerdtree's left window will open, but is a blank window.
Hi,
I found when I opened multiple files for editing, but didn't create a new window or tab, the session wasn't marked as dirty and therefore wasn't saved on exit.
Replacing WinEnter with BufEnter on line 65 of session.vim should solve the problem.
Mark
emacs can do it:)
First of all I'd thank you for this great plugin!
I mainly use this plugin with its default session and option g:session_autoload
set to 'yes'
.
So when I open the first gVim instance the plugin brings the default session, and if I open more instances of gVim the plugin doesn't open any session.
The problem happens when I issue :RestartSession
to restart the default session. The command executes correctly, but when I try to open new instances of gVim they try to open the default session. It seems that RestartSession
doesn't set the session lock. Issuing SaveSession
solve the problem, but it is a little bit annoying.
for example, if I'm at
~/projects/first_project/
vim-session will auto load session from ~/projects/first_project/.vimsession
Hi,
At the moment I set marks with mX
and when reloading the session, these marks are gone :(
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.