Using Vim or Emacs for dual-monitor development workflow

Hi all,

I would like to follow up on the topic I posted here. Unfortunately, it seems that VSCode is not able to do this for me, so maybe I should try some other editor.

I am playing with the idea of using Vim (NeoVim, SpaceVim) or Emacs (Spacemacs) for development for quite long time already, so maybe now is the time to do it.

The only thing I am not sure about is the usage of Vim or Emacs on multiple monitors.

My idea of development workflow is to have the file tree + source + test on the main monitor and the terminal on the secondary one. Then with focus on the test file, run the test on current line (or run all tests in current file, or all tests in a project) with a keyboard shortcut and see the results on the terminal on the second monitor. Also switch between the terminal and the sources quickly with a keyboard shortcut, etc.

My monitors are not the same resolution, so a “solution” to just maximize one instance of editor across two monitors would not work for me.

From all the articles I read, I guess maybe tmux could help or using vim in a client/server mode, but honestly, I have no idea how to achieve something like I mentioned above.

I assume my idea of workflow is not unique and lot of you here are already doing this. I would really appreciate some of your knowledge in this area or your experience setting up this kind of workflow. I hope I described my situation clearly.

Thanks a lot. :slight_smile:

1 Like

Vim user here. What I usually do is to start a terminal in a separate window (or terminal split if working on a single screen) and use something like mix-test.watch to run relevant tests whenever I save a file.

That tends to be much simpler to configure and versatile than other possibilities.

2 Likes

I do pretty much the same as described by @lucaong. Though I use emacs.

Depending on the terminal emulator you use you could even send clicks on filename:line:column: to Emacs.

Alternatively just start a single Emacs demon, connect 2 clients to it, each in it’s own “frame”.

How you then switch between those frames is more a problem of your window manager rather than the editor.

Personally I live to use awesome-wm, though after a reinstall of my system, I haven’t yet found the time to set it up again…

3 Likes

BTW: I am using MacOS, if that helps somebody. :slight_smile:

I use Vim here with multiple monitors. If I want something on the 2nd monitor, I open a 2nd terminal. I do use tmux, which makes it easy to attach multiple terminals to the same session but look at different tmux windows independently on each monitor.

I also use vim-test to automatically run tests under the cursor or file controlled by hotkeys. Personally I have it configured to open the output in a Vim split but there’s a configuration option in vim-test to make it open in a different tmux window so what you want to do shouldn’t be much different.

My dotfiles are public if you want to see how it’s all wired up: https://github.com/nickjj/dotfiles

I haven’t pushed the vim-test specific config but I pasted it below. I have it configured to work with Docker, so your commands will likely need to be adjusted. The test strategy is also how you can have it launch in tmux too instead of vim. Check vim-test’s docs for how to do that.

" .............................................................................
" janko/vim-test
" .............................................................................

let test#strategy='vimterminal'

let test#python#runner='pytest'
let test#python#pytest='docker-compose exec web py.test'

let test#elixir#exunit#executable = 'docker-compose exec -e MIX_ENV=test web mix test'

nmap <silent> t<C-n> :TestNearest<CR>
nmap <silent> t<C-f> :TestFile<CR>
nmap <silent> t<C-a> :TestSuite<CR>
nmap <silent> t<C-l> :TestLast<CR>
nmap <silent> t<C-g> :TestVisit<CR>
3 Likes

Thanks a lot. This looks promising. I will try your config tomorrow. :slightly_smiling_face: