Oeasy teaches you to play with VIM – 76 – # key combination map

Time:2022-2-25

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:loadviewTo 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

  • IfWith this function

    • It must be:mkviewnearby
    • Let’s go to the scene first
  • :h mkview

Oeasy teaches you to play with VIM - 76 - # key combination map

  • viewThe inside can include

    • parameter list:args
    • Current file
    • viewoptions

      • Map map
      • Abbreviation abreivate
      • options
    • fold
    • Scroll position and cursor position
    • Current folder
  • andviewoptionThere is one relatedsessionoptions
  • < C -] > go in and have a look

sessionoptionsSession options

Oeasy teaches you to play with VIM - 76 - # key combination map

  • This conversationsessionInclude the following options

    • blnakBlank window
    • buffersAll caches
    • curdircurrent directory
    • foldsfold
    • globalsglobal variable
    • localoptionsLocal options
  • Return the guy, isn’t that basic:mkviewHave you done all your work
  • as long assessionoptionsHave these above
  • :mksessionYou can finish it:mkviewWork of
  • Besides, what else is in the session

sessionoptionsSession options

  • Can givesessionoptionsAdd more options

    • :set sessionoptions+=resize
    • optionsAll optionsoptionAnd mappingmap
    • resizeRows and columns of the window
    • sesdirThe directory where the session file is located
    • This folder will become the current directorycurdir
    • IfsesdircurdirIf not

      • Absolute paths are usedabsolute path
    • slash

      • unixThe backslash in the file name becomes a slash
    • In fromwindowsreachunixlikeUseful
    • tabpagesTab page
    • terminalCommands stored in the terminal
    • winposwinsizewindowwindowSize and location of

Oeasy teaches you to play with VIM - 76 - # key combination map

  • There’s everything here
  • fromtabsreachwindow
  • Fully meet the demand

Save session:mksession

  • :mksessionSave session
  • Where did you save it?

Oeasy teaches you to play with VIM - 76 - # key combination map

  • :echo this_session

    • The answer is saved in the current directory
    • be calledsession.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]

Oeasy teaches you to play with VIM - 76 - # key combination map

  • 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 oeasySession.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
  • 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~/sessionCreate 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
  • 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:mksessionTask

    • :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

Oeasy teaches you to play with VIM - 76 - # key combination map

  • When you want to load a session

    • :source ~/oeasy/oeasy.vimYou 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

Oeasy teaches you to play with VIM - 76 - # key combination map

  • order

    • VIM must have existed first:mkviewSave window view
    • Later:mksessionSave entire session
    • This shows that VIM becomes more powerful
    • More suitable for multi-threaded concurrent environment
  • 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
    • :mksessionReplaceable:mkview
  • But in the last paragraph, he said

    • viewandsessionAllviminfoA useful supplement to??!
    • What do you mean?
  • Let’s summarize firstSession

summary

  • This time we definedsession

    • :mks
  • You can also load sessionssession

    • :source Session.vim
    • vim -S Session.vim
  • Basically established:mksessionCan replace:mkview
  • Who knows, another one came outviminfo?!😨
  • 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)