vifm

is it possible to nmap two consecutive commands to the same pane in vifm?


I would like to create an nmap that would first cd to a particular directory and then edit a file in that directory. For instance, this would allow me to open a LaTeX file and edit it, but then exit from that file and be in the directory to pull up the pdf file that LaTeX created. I have tried the following:

nmap b :cd /path/to/directory/ <cr> :edit file.tex

This almost works and will suffice if it is the only way to do it. What happens is that the left pane changes to the correct directory and the file is opened in the right pane. Then when I quit I only need to move between panes to get to the other files. However, it would be simpler/cleaner if I could get both commands to happen in the same pane.

Is this possible?

Thanks


Solution

  • The reason why two commands happen in different panes is that RHS of your mapping contains a space in normal mode (right after <cr>). You should either remove it or don't switch between modes at all by performing two commands in a row (which should be separated by a bar/pipe):

    nnoremap b :cd /path/to/directory/ | edit file.tex<cr>