4

I am currently studying Write yourself a Scheme.

I love vim and want to use :split to have my top file be my Haskell file, and the bottom split to be ghci, repl.

However, split just opens files. Is this true? How do I open my top split and my Haskell file and my bottom split as ghci?

Jonathan Dewein
  • 984
  • 3
  • 16
  • 34

1 Answers1

6

You can use the :terminal command (thanks, @PeterRincker!) to create a terminal emulator split. Add the command you want to run; e.g. :terminal ghci.

My previous advice, which was predicated on the non-existence of :terminal (and should therefore probably be ignored), is included below for completeness rather than helpfulness.

If you actually mean vim (and not gvim), you can use tmux or similar. This vim plugin might be nice for automating interactions between the two tmux panes.

Otherwise you'll need to use a plugin for doing terminal stuff from within gvim. vimshell and conque look relevant in this space.

Daniel Wagner
  • 145,880
  • 9
  • 220
  • 380
  • 4
    Newer Vim (8+) and NeoVim both support the `:terminal` command. In Vim you can bring up a terminal window/split with `:terminal ghci`. See `:h terminal` & `:h :terminal` – Peter Rincker Feb 14 '18 at 19:18
  • On the topic of Conque, I'd look specifically at https://github.com/vim-scripts/Conque-GDB. It includes a forked version of Conque that included improvements to the Conque side such as allowing the conque shell to scroll even when it is not the active buffer. And then also has the benefit of having GDB integration. – Christian Gibbons Feb 14 '18 at 19:18
  • @PeterRincker :terminal ghci is pretty much exactly what I was looking for, thanks! – Jonathan Dewein Feb 14 '18 at 19:25
  • 1
    @PeterRincker Nice, I didn't know about that! I'll add it to the answer. – Daniel Wagner Feb 14 '18 at 19:26
  • @PeterRincker I hadn't realized that was added in vim8. I'll have to experiment with that as Conque can be quite finicky (still like it for GDB, though). – Christian Gibbons Feb 14 '18 at 19:27
  • @DanielWagner You could probably put your previous answer as a "pre-Vim8 solution" rather than "should be ignored". – Christian Gibbons Feb 14 '18 at 19:29
  • 1
    @ChristianGibbons, You may want to take a look at `:Termdebug` for GDB, which is shipped with Vim 8+ as well. See `:h terminal-debug` – Peter Rincker Feb 14 '18 at 19:30
  • @PeterRincker I'll do that, thanks. Always looking for ways to improve my workflow in vim. – Christian Gibbons Feb 14 '18 at 19:33
  • One more thing: How do i change the order of the windows? For example, if I want my Haskell file on top, and my ghci session on bottom? There is a nice series of commands for moving vim windows: https://stackoverflow.com/questions/4556184/vim-move-window-left-right – Jonathan Dewein Feb 14 '18 at 19:36