GNU/Linux >> Znalost Linux >  >> Linux

Uložit aktuální stav relace Vim a obnovit jej později (např. vyrovnávací paměti, rozdělení atd.)?

Jako starý uživatel VIM, kterého to přitahuje především kvůli jeho přímým substitucím regulárních výrazů, které umožňují pracovat opravdu rychle, opravdu neočekávám, že VIM bude mít takovou funkci. Ale, sakra, možná jsem něco přehlédl nebo nějakou novinku.

Neznáte náhodou způsob pro vim , při opětovném otevření velkého seznamu souborů (jmenovitě všech zdrojových souborů cpp/h projektu) v režimu n-column-split přizpůsobeného velikosti obrazovky (viz příkaz bash/alias níže), aby byly dříve otevřené/vybrané/aktivní vyrovnávací paměti vrátit se místo resetování na n prvních souborů přes viditelné buffery? Trochu jako by to udělalo IDE uložením stavu otevřených souborů.

# check the window size after each command and, if necessary,                   
# update the values of LINES and COLUMNS.                                       
shopt -s checkwinsize                                                           
alias vimcpp='find . \( -name '\''*.cpp'\'' -o -name '\''*.cc'\'' -o -name '\''*.cxx'\'' -o -name '\''*.c'\'' -o -name '\''*.hpp'\'' -o -name '\''*.hh'\'' -o -name '\''*.hxx'\'' -o -name '\''*.h'\'' \) -exec vim -O$(( ( ( $COLUMNS - 1 ) / 80 > 0 ) ? ( ( $COLUMNS - 1 ) / 80 ) : 1 )) \{} \+'

Přijatá odpověď:

K tomu můžete použít vim sessions. Stačí spustit:

:mksession mysession.vim

a v aktuálním adresáři (nazvaném „mysession.vim“) se vytvoří soubor. Když příště otevřete vim, můžete:

 :source mysession.vim

(nebo jak jste to pojmenovali) a ocitnete se zpět do stavu, ve kterém jste byli, když jste vytvořili soubor relace (budou tam všechna rozdělení atd.).

Z nápovědy:

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.

Linux
  1. Jak zálohovat a obnovovat databázi v PostgreSQL

  2. Příkaz grpck – Odstraňte poškozené nebo duplicitní položky v souborech /etc/group a /etc/gshadow.

  3. Získejte aktuální čas v hodinách a minutách

  1. Linux ext4 obnovit přístupová práva k souborům a adresářům po špatném zálohování/obnovení

  2. Jaké je spojení mezi adresáři /etc/init.d a /etc/rcX.d v Linuxu?

  3. Jak `/etc/hosts` a DNS spolupracují při překladu názvů hostitelů na IP adresy?

  1. Jak upravovat více souborů a přepínat mezi soubory ve VIM pomocí vyrovnávacích pamětí

  2. Linux – Jak uložit X Session – Archlinux+openbox?

  3. Uložit a obnovit své karty terminálu?