0

I want to create a command in vim which opens the currently open file in a new viw session which is inside a new tmux session.

Something like this:

Open vim with test.c -> Execute given command -> Exit vim -> Start tmux -> Go to the working directory where vim was -> Open the file which was opened

I have an idea how to make a script which opens tmux and vim on a given file, but I don't know how to make a command which first exits from vim and then runs a command automatically.

1 Answer 1

0

The Vim feature that allows you to save the currently edited files and reopen them in a different or later Vim instance is called sessions. See :help views-sessions for details. This requires a separate session file to pass around, but can store many options and several files.

A simpler alternative to reopen the current file is the list of previously opened files stored in the viminfo file. :help oldfiles-variable has more information. You can simply access the last edited file via mark 0. For example:

$ vim -c "normal! '0"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .