https://github.com/devwurm/autosession.vim
Vim (Neovim) plugin for automatically load the last layout setup in the project
https://github.com/devwurm/autosession.vim
Last synced: 4 months ago
JSON representation
Vim (Neovim) plugin for automatically load the last layout setup in the project
- Host: GitHub
- URL: https://github.com/devwurm/autosession.vim
- Owner: DevWurm
- License: mit
- Created: 2016-05-27T16:51:46.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-06-10T00:50:02.000Z (almost 10 years ago)
- Last Synced: 2025-10-10T21:38:36.237Z (8 months ago)
- Language: VimL
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# autosession.vim
Vim (Neovim) plugin for automatically loading the last session setup in the project.
autosession.vim enables a more fluent behavior of Vim when used in real projects (not just single file editing) by storing the whole session setup of vim (including layout, buffers, configuration, history, etc.) in the current directory, so Vim can be restored exactly as it was when is was opened the last time.
autosession.vim **doesn't store the session by default** (because this would bloat your whole system with session files, everytime you use vim to edit a file somewhere). It just **looks automatically for previous sessions** in the current directory, when Vim is invoked without a file specified. With some [command configurations](#custom-command-setup-commands) you can include the creation and not-creation of session files in your workflow flawlessly.
## Installation
### Plugin repo
```
'DevWurm/autosession.vim'
```
### Plugin manager
Of course you can install autosession.vim with your favourite (Pathogene-compatible [like most of them]) plugin-manager.
With (dein.vim)(https://github.com/Shougo/dein.vim) you add this to your plugin configuration:
```VimL
dein#add('DevWurm/autosession.vim')
```
However you will know best how to install it with your plugin-manager.
### Manually
Clone the Plugin repo
```
git clone https://github.com/DevWurm/autosession.vim.git ./autosession.vim
```
#### Vim
You can install the plugin manually, by copying the `./autosession.vim/plugin/autosession.vim` file in a subdirectory of your plugin directory (typically `~/.vim/bundle/autosession.vim/` or `~/.vim/plugin/autosession.vim/`) and adding this subdirectory to your Vim runtimepath
```VimL
set runtimepath^=~/.vim//autosession.vim
```
After that you have to copy the `./autosession.vim/autoload/autosession.vim` file into the `~/.vim/autoload/` directory.
#### Neovim
In Neovim you can install the plugin manually, by copying the `./autosession.vim/plugin/autosession.vim` file in a subdirectory of your plugin directory (typically `~/.config/nvim/bundle/autosession.vim/` or `~/.config/nvim/plugin/autosession.vim/`) and adding this subdirectory to your Vim runtimepath
```VimL
set runtimepath^=~/.config/nvim//autosession.vim
```
After that you have to copy the `./autosession.vim/autoload/autosession.vim` file into the `~/.config/nvim/autoload/` directory.
## Usage
Using autosession.vim is pretty straightforward. autosession.vim saves the current session in a file called `.session.vim` in the current working directory. When Vim is started in this directory the plugin will recognize this file and reload the session from it.
### Saving the session
autosession.vim doesn't save sessions automatically to prevent the bloating of your system with undesired session setups.
To save the current session in the working directory as `.session.vim` the plugin provides the
```VimL
:SessionSave
```
command.
To remove a project setup, just remove the `.session.vim` file in the directory you want to start vim in.
#### Custom command setup
You can specify some custom commandline commands to include the saving of the session into your workflow. E.g. insert the following lines somewhere into your `.vimrc`/`init.vim` or into a file sourced there to enable the `:Q` (as well as the `:Q!`) command as session-saving equivalent to `:q` (respectively `:q!`) and the `:WQ` (as well as the `WQ!`) command as session-saving equivalent to `:wq` (respecively `:wq!`):
```VimL
" execute the SessionSave command of the autosession.vim plugin and close vim when executing :Q
" and enable the use of ! to force closing even if buffer is not saved
command -bang Q :SessionSave | if 0 | q! | else | q | endif
" execute the SessionSave command of the autosession.vim plugin and write +
" close vim when executing :WQ and enable ! to force write-close
command -bang WQ :SessionSave | if 0 | wq! | else | wq | endif
```
#### Automatically save session when closing vim
Of course you can also configure vim to store the session everytime you close vim (even if I don't recommend it [because of bloating your system]). To do so, just add the following lines into your `.vimrc`/`init.vim` or into a file sourced there:
```VimL
" execute the SessionSave command of the autosession.vim plugin everytime closing vim
autocmd VimLeavePre * SessionSave
```
### Loading the session
Loading the session is pretty easy. If Vim is invoked without a file specified (`vim` and not `vim some.file`) autosession.vim searches a `.session.vim` file in the current directory. If there's one present it restores the session, otherwise it doesn't. Thats it. Nothing else. No rocket science.
#### Loading the session manually
You can load a session from the invokation directory during runtime by calling the following command provided by autosession.vim:
```
:SessionLoad
```
Of course you can bind this command to other commands or keys. To include it perfectly into your workflow.
##Access
You can access the current (developement) source on GitHub. The
current stable version is provided in the latest GitHub Release.
##Documentation
There is no documentation yet. (Email me if you have any questions)
##License
'autosession.vim' is offered under MIT License (Read LICENSE). USe it! :)
Copyright 2016 DevWurm
##Collaborating
I really appreciate any kind of collaboration!
You can use the [GitHub issue tracker](https://github.com/DevWurm/autosession.vim/issues) for bugs and feature requests or [create a pull request](https://github.com/DevWurm/autosession.vim//pulls) to submit
changes. Forks are welcome, too!
If you don't want to use these possibilities, you can also write me an email to
devwurm@devwurm.net.
## Contact
If you have any questions, ideas, etc. feel free to contact me:
DevWurm
Email: devwurm@devwurm.net
Jabber: devwurm@jabber.ccc.de
Twitter: @DevWurm