Session session
Recall the details of key combination mapping
-
Last time we defined a series of composite keys
- Mainly with the CTRL key
-
Quick jump window
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-h> <c-w>h
map <c-l> <c-w>l
-
Quick jump tab
map <c-left> :tabn<cr>
map <c-right> :tabp<cr>
-
You can also work in line
map <c-s> :%s/5.1/5.2/g<cR>:wnext<cr>
-
Finally, pay attention to the small details of the notes
:unmap a|" unmap a
-
The combination key is the same as the function key FN
- Can do all kinds of mapping
- Mapping map and abbreviation abstract are the same as folding and local options
- Can pass
:mkview
、:loadview
To save the read - But if there is a tab in my environment
- There are also various windows with good segmentation in the tab
- When you wake up, you have to cut it again
- We have to start again
:tabnew
- I want to store the status of multi tab tabs and multi window windows
- Is it possible?
Search process
-
If
With this function- It must be
:mkview
nearby - Let’s go to the scene first
- It must be
:h mkview
-
view
The inside can include- parameter list
:args
- Current file
-
viewoptions
- Map map
- Abbreviation abreivate
- options
- fold
- Scroll position and cursor position
- Current folder
- parameter list
- and
viewoption
There is one relatedsessionoptions
- < C -] > go in and have a look
sessionoptions
Session options
-
This conversation
session
Include the following optionsblnak
Blank windowbuffers
All cachescurdir
current directoryfolds
foldglobals
global variablelocaloptions
Local options
- Return the guy, isn’t that basic
:mkview
Have you done all your work - as long as
sessionoptions
Have these above :mksession
You can finish it:mkview
Work of- Besides, what else is in the session
sessionoptions
Session options
-
Can give
sessionoptions
Add more options:set sessionoptions+=resize
options
All optionsoption
And mappingmap
resize
Rows and columns of the windowsesdir
The directory where the session file is located- This folder will become the current directory
curdir
-
If
sesdir
、curdir
If not- Absolute paths are used
absolute path
- Absolute paths are used
-
slash
unix
The backslash in the file name becomes a slash
- In from
windows
reachunixlike
Useful tabpages
Tab pageterminal
Commands stored in the terminalwinpos
、winsize
windowwindow
Size and location of
- There’s everything here
- from
tabs
reachwindow
- Fully meet the demand
Save session:mksession
:mksession
Save session- Where did you save it?
-
:echo this_session
- The answer is saved in the current directory
- be called
session.vim
- This is like saving a workspace in the root directory of the project
- Let’s see what this thing is?
Session content session
git clone http://gitee.com/overmind1980/oeasyvim.git`
vi -o oeasy.java oeasy.css oeasy.html
- Then create some tabs
:mks[ession]
-
You can see this in the sessionoption
- tab
- buffers
- window
- All of them
- 1000 + lines in total
- Saved the current state
-
When you want to recover, just
:so[urce] session.vim
- It all recovered
Switch project workspace
- You can create two sessions
- Then copy oeasyvim and call it oeasy
-
So we have two working folders
- For example, oeasyvim is task a we don’t want to do
- Oeasy is Task B we want to do
cd ..
cp oeasyvim oeasy
cd oeasy
vi -o oeasy.java oeasy.css oeasy.html
-
Plus some tabs and so on
- again
:mksession
- This time, it is established under the project folder of oeasy
Session.vim
- We can see these two projects
- Each has its own engineering documents
- That is, each has its own blue cotton curtain
- You can even share the workspace status online
- again
-
Others will use your layout to open your project
vim -S Session.vim
-
Or after entering VIM
:source Session.vim
- You can also make different faceted conversations for the same project
Project workspace folder./sessions
-
:mks ~/sessions/oeasy.session
- You can specify the location
~/session
Create project directory under -
All project documents are stored in the project directory
~/sessions/oeasy.session
~/sessions/o2z.session
~/sessions/o3z.session
-
In this case, I can go directly to the project directory to find the project
ls ~/sessions/
vim -S ~/sessions/oeasy.session
- You can specify the location
-
advantage
- Centralized management of each project
- You can also set these session files
-
In fact, there are other ways to prevent session files from appearing in the project directory submitted by GIT
- Use Gitignore can solve this problem
-
shortcoming
- To delete a project, you need to delete it in two places
- Engineering program material and engineering work area are not together. It’s troublesome to copy and paste
Function key mapping
-
I want you toF2Can execute
:mksession
Task:map <F2> :mks!<cr>
-
I want to save the file before I save the workspace
:map <F2> :wa<Bar>mks!<cr>
-
I want to save the file first, and then save the workspace to the current session file
:map <F2> :wa<Bar>exe "mksession! " . v:this_session<cr>
- Where V: this_ Session is the current session
- sure
:echo v:this_session
-
When you want to load a session
:source ~/oeasy/oeasy.vim
You can also specify a function key:map <F3> :source ~/oeasy/oeasy.vim<cr>
-
WhenF3When
- The session is saved
- The two map maps are saved in the session
View and session
-
order
- VIM must have existed first
:mkview
Save window view - Later
:mksession
Save entire session - This shows that VIM becomes more powerful
- More suitable for multi-threaded concurrent environment
- VIM must have existed first
-
Relationship between the two
- Projects with single tab and single window can be used
:mkview
- Multi tab multi window window project is best used
:mksession
:mksession
Replaceable:mkview
- Projects with single tab and single window can be used
-
But in the last paragraph, he said
view
andsession
Allviminfo
A useful supplement to??!- What do you mean?
- Let’s summarize first
Session
summary
-
This time we defined
session
:mks
-
You can also load sessions
session
:source Session.vim
vim -S Session.vim
- Basically established
:mksession
Can replace:mkview
- Who knows, another one came out
viminfo
?!😨 - These two brothers have become a useful supplement?
- What happened?
- Next time!
[GitHub address](https://github.com/overmind19…)
[gitee address] (overmind1980 / oeasyvim)
[blue bridge experimental building invitation code fjwyimgb] (oeasy teaches you zero foundation to play with editing artifact vim_linux blue bridge cloud course)