Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use VIM to remember open files between sessions?

Tags:

file

vim

unix

I use VIM as my main text editor here at work and I often have 10-15 files open at once in a couple of Windows with several tabs, each of which has its own split Windows. I love using VIM, but I hate having to re-do my entire set-up every time the dev server gets bounced or my machine crashes.

Is there a way to get VIM to remember a setup, such as the "project" features in many IDEs? Or am I stuck having to open all the files in the same way each time?

like image 601
daveslab Avatar asked Jul 30 '09 19:07

daveslab


People also ask

How do I quickly switch between files in Vim?

Switch between files Here, N is capital (Type SHIFT+n). Start editing the files as the way you do with Vim editor. Press 'i' to switch to interactive mode and modify the contents as per your liking. Once done, press ESC to go back to normal mode.

How do I save and quit all tabs in Vim?

:wa - save all tabs / unsaved buffers. :xa / :wqa - save all tabs / unsaved buffers and exit Vim.

Does Vim load entire file into memory?

Yes, Vim loads the whole file into memory.

How do I use tabs in Vim?

To directly move to first tab or last tab, you can enter the following in command mode: :tabfirst or :tablast for first or last tab respectively. To move back and forth : :tabn for next tab and :tabp for previous tab. You can list all the open tabs using : :tabs. To open multiple files in tabs: $ vim -p source.


1 Answers

Have a look at the :mksession command.

A Session keeps the Views for all windows, plus the global settings. You can save a Session and when you restore it later the window layout looks the same. You can use a Session to quickly switch between different projects, automatically loading the files you were last working on in that project.

like image 145
Greg Hewgill Avatar answered Oct 23 '22 23:10

Greg Hewgill