GNU/Linux >> Linux の 問題 >  >> Linux

現在のVimセッションの状態を保存して後で復元しますか(バッファ、スプリットなど)?

古いVIMユーザーとして、そもそもそれに惹かれていました。特に、非常に高速に動作できる単純な正規表現の置換のために、VIMにそのような機能があるとは思っていません。しかし、一体何なのか、私は何かまたはいくつかの目新しさを見落としたのかもしれません。

vimの方法を知っていますか 、画面サイズに合わせたn-column-splitモード(以下のbashコマンド/エイリアスを参照)でファイルの膨大なリスト(つまり、プロジェクトのすべてのcpp / hソースファイル)を再度開くと、以前の開いている/選択された/アクティブなバッファーがあります表示されているバッファ全体で最初のn個のファイルにリセットする代わりに戻ってきますか?開いているファイルの状態を保存することで、IDEと少し似ています。

# 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 )) \{} \+'

承認された回答:

そのために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.

Linux
  1. ターミナルタブを保存して復元しますか?

  2. grpck コマンド – /etc/group および /etc/gshadow ファイル内の破損したエントリまたは重複したエントリを削除します。

  3. /etc/crontab と crontab -e の違い

  1. 複数のファイルを編集し、バッファを使用してVIM内のファイルを切り替える方法

  2. Linux – Xセッションを保存する方法— Archlinux + openbox?

  3. 再起動時に端末を保存して復元する

  1. 現在のBashセッションで開いているファイル記述子(およびそれらが参照するファイル)を一覧表示するにはどうすればよいですか?

  2. PostgreSQLでデータベースをバックアップおよび復元する方法

  3. アクセス許可を保存および復元するスクリプトを作成することはできますか?