Сохранить текущее состояние сеанса vim и восстановить его позже (, например. буферы, разделители и т. д.)

Поместите закрывающий ], который вы хотите сопоставить, сразу после отрицания ^, где это не будет неверно истолковано. Вы можете использовать \+в конце регулярного выражения, чтобы заменить несколько символов одной точкой (, спасибо @Rakesh Sharma):

$ echo 'Some Movie Name! (2015) [1080p]' | sed -e 's/[^][A-Za-z0-9()]\+/./g'
Some.Movie.Name.(2015).[1080p]
2
19.04.2021, 17:55
1 ответ

Для этого можно использовать сеансы vim. Просто беги:

:mksession mysession.vim

и в текущем каталоге (будет создан файл с именем mysession.vim ). Когда вы в следующий раз откроете vim, вы можете сделать:

 :source mysession.vim

(или как бы вы его ни называли )и вы вернетесь в состояние, в котором вы были, когда вы создали файл сеанса (все разделения будут там и т. д. ).

Из справки:

This is introduced in sections 21.4 and 21.5 of the user manual.

:mks[ession][!] [file]  Write a Vim script that restores the current editing
            session.
            When [!] is included an existing file is overwritten.
            When [file] is omitted "Session.vim" is used.


The resulting file, when executed with a ":source" command:

1. Restores global mappings and options, if 'sessionoptions' contains
   "options".  Script-local mappings will not be written.
2. Restores global variables that start with an uppercase letter and contain
   at least one lowercase letter, if 'sessionoptions' contains "globals".
3. Closes all windows in the current tab page, except the current one; closes
   all tab pages except the current one (this results in currently loaded
   buffers to be unloaded, some may become hidden if 'hidden' is set or
   otherwise specified); wipes out the current buffer, if it is empty
   and unnamed.
4. Restores the current directory if 'sessionoptions' contains "curdir", or
   sets the current directory to where the Session file is if 'sessionoptions'
   contains "sesdir".
5. Restores GUI Vim window position, if 'sessionoptions' contains "winpos".
6. Restores screen size, if 'sessionoptions' contains "resize".
7. Reloads the buffer list, with the last cursor positions.  If
   'sessionoptions' contains "buffers" then all buffers are restored,
   including hidden and unloaded buffers.  Otherwise only buffers in windows
   are restored.
8. Restores all windows with the same layout.  If 'sessionoptions' contains
   "help", help windows are restored.  If 'sessionoptions' contains "blank",
   windows editing a buffer without a name will be restored.
   If 'sessionoptions' contains "winsize" and no (help/blank) windows were
   left out, the window sizes are restored (relative to the screen size).
   Otherwise, the windows are just given sensible sizes.
9. Restores the Views for all the windows, as with |:mkview|.  But
   'sessionoptions' is used instead of 'viewoptions'.
10. If a file exists with the same name as the Session file, but ending in
   "x.vim" (for eXtra), executes that as well.  You can use *x.vim files to
   specify additional settings and actions associated with a given Session,
   such as creating menu items in the GUI version.
2
28.04.2021, 22:53

Теги

Похожие вопросы