Questions tagged [sessions]

For questions about vim's sessions feature, which persist an editing session to disk for recovery later.

Filter by
Sorted by
Tagged with
72
votes
4answers
22k views

How to save window, split, and buffer layout?

I have several tasks I am working on in one repository. I would like to create "workspaces" for working on them. One "workspace" or "buffer layout" would have all files I need to work on open in the ...
27
votes
3answers
4k views

Can I open a file in an existing Vim instance from an external command?

Some applications have the notion of a "session", where you can run a command to load a file in an existing instance of an application. For example, when I type: $ firefox http://vi.stackexchange....
14
votes
2answers
5k views

How do I restore a group of tabs? [duplicate]

I just learned about tabs, meaning I can open them via :tabe some/file :tabe yet/another/file :tabe foo and circle them via gt (activate right one) and gT (activate left one). Yet when I close my ...
9
votes
1answer
6k views

Remember previous session [duplicate]

Editors like Sublime Text remember your session, so that whenever you open Sublime Text it is exactly how it was when you last closed it: All of the same files are open Your cursor is in the same ...
8
votes
1answer
2k views

How to share the same buffer between multiple vim instances

I work with two displays. I usually open one instance of Vim in display #1 (let's call it Vim #1), which over time ends up having an open buffer for nearly every file in a project. Now I want to ...
7
votes
2answers
2k views

How can I restore the cursor position when opening a file?

If I edit a file with vim that I have previously edited, I'd like vim to jump to the position I was in when I last closed the file. How can I accomplish this?
6
votes
2answers
2k views

Vim lost custom highlight settings after recovering from sessions

I defined some highlights in the vimrc file and it works well in gvim. However after I mksession and sourced it back, I found that some (maybe all) of the custom highlights were lost and vim used the ...
6
votes
2answers
205 views

Make Vim sessions save alternate files

When saving a session with :mksession and sourceing it back, I noticed that alternate files (accessed via C-^) are not persisted. The docs don't mention anything about persisting alternate files. Is ...
5
votes
1answer
81 views

How do I get rid of <filename>.project.vim files?

It seems like any time I edit a file with gvim it creates a litany of files I don't want or seem to need. I understand the <filename>.~ files are backups of the file before I started editing and ...
5
votes
1answer
97 views

Empty first tab lost when using sessions

I'm creating a session with mksession, and when I restore the session, if the first tab was empty ([No Name]), it's gone in the restored session. Other empty tabs are restored fine; it seems to only ...
5
votes
1answer
235 views

Ignore word spelling on a per-file/buffer basis

I can add a word to the local dictionary or spellfile with zg. I can use zG to add a word to the internal spellfile, but this still affects all loaded files. How can I add spelling exceptions on a ...
4
votes
2answers
5k views

How does one perform a multi-line copy and paste between two sessions in Vim?

I am familiar with the y, p method of copying and pasting a line within Vim; however, I have been unsuccessful in finding a straight forward method for copying multiple lines which have been yanked in ...
4
votes
1answer
154 views

Source vim session file: Track down unexpected sourcing of other file

I often save my session using the following: In vim: mksession! ~/session.vim In gvim: mksession! ~/sessionX.vim However, when I invoke vim with a sourcing of ~/session.vim, I'm finding that ~/...
4
votes
3answers
179 views

Save functions in a session

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? ...
3
votes
2answers
1k views

Make Vim sessions save the content of unnamed buffers

When saving a session with :mksession and :sourceing it back, the content of [No Name] unnamed buffers is lost. I like to sometimes write temporary throwaway code or notes on a unnamed or scratch ...
3
votes
3answers
2k views

How can I read a command-line argument in vimrc?

Here is a situation: I want to manage my working environment on multiple projects separately, and all of them should have its own session (Session.vim) to save and restore. So I would like to launch ...
3
votes
1answer
349 views

Can I retain and restore all the GUI windows and its files on launch on Vim?

I'm currently using the session saving to restore the state when the app (MacVim) is closed. nnoremap <leader>q :mksession! ~/.vim/Session.vim<CR>:wqa<CR> nnoremap <leader>...
3
votes
1answer
976 views

Make vim sessions adopt changes to vimrc file

I've made changes to my _vimrc (windows) file since creating a session. I'm finding it impossible (using :source) to apply these changes to the session; it sticks stubbornly to the values as they ...
3
votes
2answers
629 views

How to have different vim sessions open the same file seamlessly

from some time now I'm using vim very intensively. I'm connecting to my server with different screen sessions, one for my main PC, another for netbooks or mobile phone, tablets, ... All this time ...
3
votes
1answer
653 views

Vim Session keeping terminal state

I am currently using tmux to have two terminals on the left and vim on the right. One terminal is running Django server, and the other one is for general usage. I am trying to find out if I can ditch ...
3
votes
1answer
484 views

How could I preserve netrw :Lexplore in Vim sessions?

I use netrw :Lexplore as my file browser and I also use vim sessions. However, whenever I open a session file, :Lexplore is closed and I have to re-open. Is there a way to keep netrw :Lexplore open ...
3
votes
0answers
65 views

Persisting unsaved changes to untitled buffers in a session [duplicate]

Sublime Text has a killer feature I'd really like to get working in Vim. It's pretty much the only reason why I can't drop it in favor of Vim yet. The feature is that Sublime remembers unsaved ...
2
votes
1answer
157 views

! is required but not allowed for custom command

I'm using Neovim 0.3.7. I have a default session file that loads up a number of files I'm working on at the moment. To save and load the sessions I have the following custom commands defined: let ...
2
votes
1answer
55 views

Using '-c' when calling vim from terminal

My issue is with using the -c while calling vim from terminal like $ vim -c jk I want to be able to open the last session before quitting on typing viml in terminal For this I made a map to save ...
2
votes
1answer
80 views

When opening an existing session and an existing file at the same time, the focus goes to the last opened file in the session

When doing this: vim -S Session.vim OTHER_FILE The shown buffer contains the last opened file in the Session.vim and not the file OTHER_FILE. I find this behavior a bit disturbing, I would have ...
2
votes
1answer
80 views

NeoVim Save BreakPoints to Session

I am using NeoVim for writing go code, for debugging I am using vimspector The debugging works well, however everytime I exit and restart nvim the breakpoints are lost. I tried saving the session ...
2
votes
1answer
137 views

How to preserve options in Vim sessions?

I am using vertical splits to compare two files which cannot be compared with diff. I don’t know how to save specific settings in the session. Here is how I proceed: enable the settings: :set ...
2
votes
0answers
31 views

Save terminal buffer's current working directory with mksession [duplicate]

I usually start vim at the root of my project. Then I open tabs with windows inside. Usually one of the windows has a :terminal. In the :terminal, I usually cd to/some/subfolder. At the end of the ...
2
votes
1answer
134 views

Session - start with buffer 1

Note: Possible fixed bug. See comments. A somewhat minor nuisance, but as the pedantic for these things :P When saving and opening a Session file the Session.vim file does: badd +1 file1 badd +1 ...
2
votes
0answers
48 views

:mksession session file includes nonprintable characters

I have been having some problems using UltiSnips with vim. It seems that :mksession is adding a bunch of nonprintable characters to my session file(s). When this is sourced to restore my session, ...
1
vote
1answer
1k views

Change saved session's working directory

I have a neovim session saved using :mks which by default saves to a subdirectory in my project ~/project/subdir/Session.vim. I want it to save to ~/project/Session.vim, which I can do by running :cd ...
1
vote
1answer
21 views

Simple way to store additionnal config in the scope of the actual directory [duplicate]

I have my .vimrc with some global/local configurations, but when I am working in a project, I know that I often create configs (settings, mapping, command, abbreviations, etc.) specifically for this ...
1
vote
1answer
339 views

what is the purpose of the view folder in the .vim folder?

I got an error when opening my .vimrc with vim saying ".vimrc" 138L, 3781C Error detected while processing /home/fbence/.vim/view/~=+.vimrc=: line 117: E518: Unknown option: termkey= line 118: ...
1
vote
1answer
171 views

Can capitalized marks be saved in session INSTEAD of viminfo?

Marks are saved in .viminfo I would like to have separate marks saved per session. Is there an easy setting to make this switch? I know I could write some vimscript to save my session marks ...
1
vote
1answer
35 views

Why does Vim load buffers from old session when new one is started?

The situation is this: I have 2 sessions: s1.vim and s2.vim. First one was saved with files A, B, C in buffers list. Second one was saved with file A. Next I start vim: vim -S s1.vim. :ls shows A, B, ...
1
vote
1answer
237 views

Update a Vim Session file's loaded plugins without losing window positioning

I have a Vim Session file I created by doing: :mksession Then I quit Vim. I then downloaded a plugin to: ${HOME}/.vim/pack/vendor/start/vim-markdown-folding and then I fired up Vim with the session ...
1
vote
1answer
36 views

Remember spelling settings in session file

I enabled spell checking in a buffer with set spell spelllang=en which works. If I save the session with mksession! and later source it back with vim -S Session.vim, spellchecking is no longer enabled....
1
vote
1answer
484 views

Colorscheme Errors (E185) with vimrc and sessions

I have a couple of things which suggest there's an issue with the way I use colorscheme with my vimrc file. Errors when running source ~/.vimrc The colorscheme used when opening a vim session ...
1
vote
1answer
343 views

Persistent conceal settings through Vim / Neovim restarts

I can successfully toggle between different conceal levels in Neovim, which is rather handy when working with markdown documents. Also, when working with with multiple documents in a Neovim session, ...
1
vote
1answer
211 views

How do you open a session in an existing server?

I'm using the server mode in vim and already have an instance open with a couple of files in. I'd like to add the contents of a session file to this. However doing vim --servername vim -S ...
1
vote
0answers
35 views

Save :Man window in session

TL;DR: I want to persist :Man windows in sessions I am obsessed with sessions, and use tpope's vim-obsession for managing them. Coupled with a scripted tmux, sessions make for a perfect "quit, go ...
1
vote
1answer
83 views

How to save modifiable and readonly states in session file?

I can’t find how to save modifiable and readonly states with :mksession. Is it even possible?
0
votes
1answer
86 views

Remapping of j as gj etc in .vimrc is not applied in a session

My .vimrc contains: noremap <buffer> <silent> $ g$ noremap <buffer> <silent> 0 g0 noremap <buffer> <silent> j gj noremap <buffer> <silent> k gk I've ...
0
votes
1answer
44 views

Is there a `:browse oldfiles` for vim sessions?

It seems to me it would make more sense to have a :browse oldfiles for the last n sessions you opened up / saved in vim. Is there such a thing?
0
votes
1answer
43 views

How to identify the script that's calling a user command?

I have a problem: I need to pass « any » caller-session trace into a user command… Was trying with: command WantToKnowWhosCalling call Impl("\<SID>", \ expand("<SID>&...
0
votes
1answer
160 views

Can a vim session use environment variables to specify the path to a file it opens?

Can you edit a vim session, so that it opens a file based on the value of an environment variable instead of an absolute path to a file?
0
votes
1answer
64 views

How to NOT create a view and session file when viewing man pages

I recently discovered the world of vim session files, and they are awesome for working with multi-file code projects. However, when opening a man page I don't need a session file created for viewing ...
0
votes
1answer
222 views

Do not reopen buffers of last session

When Vim starts, it always opens buffers of last session too. That is to say, when I leave Vim by closing all windows, but do not explicitly close buffers (by :bd), those buffers will be opened next ...
0
votes
1answer
74 views

How can I save a session in a directory owned by root?

I quite often open linux system configuration files with vim and sometimes have a session with lots of tabs, splits, quicklists etc that I want to save to a session and restore again later. The ...
0
votes
1answer
29 views

Prevent vim from exiting in case of error during autocommand

I'd like to save my session before vim exits. Here's what I have so far: function SaveSession() let l:new_session = trim(inputdialog("Enter new session name: ", v:this_session, -1)) ...