10

One big difference of neovim and Vim is that neovim includes a terminal emulator that works asynchronously.

However, I fail to see how can I profit from this feature. For what can I use it? Can you give some use cases for neovim's terminal feature so that I understand how I can use it to its best extent?

In normal Vim I normally use :read !{command}, :write !{command}, Ctrl+Z and fg as well as tmux split windows.

  • One problem with <C-z> is that the Vim process is suspended by the OS: it's not doing anything (including responding to server commands). – Martin Tournoij Sep 4 '15 at 15:15
  • Would it help to use :shell with exit instead or is vim suspended here too? – cbaumhardt Sep 4 '15 at 15:18
  • 1
    @Carpetsmoker, what do you expect your text editor to do when you are not using it? – romainl Sep 4 '15 at 15:35
  • @romainl Well, for example I have a script which will focus the Vim session editing a particular file; this will hang on suspended Vim processes... – Martin Tournoij Sep 4 '15 at 15:39
  • 1
    That's not a problem with <C-z>, that's a problem with your script. – romainl Sep 4 '15 at 15:56
10

Running a terminal inside Vim allows you to use Vim commands on the input and output to the programs that you run in that terminal. You get search, copy-paste, macros, syntax coloring, etc. Using :read !{command} and :write !{command} gives you that for one-shot commands, but asynchronous input/output becomes useful when you want to submit input to an external program piece by piece.

The typical use case is a read-eval-print loop (REPL), which is provided by many high-level programming languages. You type a stanza in your source code, then feed it to the REPL for immediate feedback. Since the REPL keeps running from one submission to the next, the submitted code snippet are executed in context.

6

I think the option to create terminal-only mappings is valuable, and extends the options you've got in other terminal emulators, e.g. mapping t to run unittests with specific configuration, which you can only achieve through complex aliases or bash functions.

4

The most obvious use case I can think of is programming. Have you ever wanted to run tests inside VIM, or compile, or use any console tool? I know people use Tmux, but know that you can do it inside NeoVIM I have to say. This is pretty awesome !!!

If you use buffers you can add, remove, hide and show terminals as you please. That's the profit ;)

Running a shell inside NeoVIM

3

The best use case I can think of is the original one-an ADM-3a on a 110 bps line! Sometimes there's really no substitute for looking at things side-by-side, and :!r doesn't cut it.

  • 3
    Good luck getting anything done in two 39x12 (or 39x24!) windows ;-) – romainl Sep 5 '15 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.