Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This will be used for :! and :shell commands.

* :term [prog/args] will open a new special buffer "connected" to a pseudo terminal running prog/args

* any command that would enter insert mode will focus the terminal buffer instead.

* when focused a new mode is entered where all keys are passed directly to the program. The <c-g><esc> combination will return to normal mode.

* new terminal-only mappings can be added with the "t" prefix(eg: tnoremap <c-a> <c-g><esc> exit terminal focus using ctrl+a)

Someone asked: "I really don't know how I would use this feature but it's impressive how well it works."

tarruda replies: "With time, the numerous use cases for this feature will be clear, but here's one idea: This allows another level of integration between text mode programs and Neovim. For example, we'll be able to make gdb respond to nvim mappings and change file/line numbers when a breakpoint is hit(Technically this might be possible with tmux but not without numerous hacks)"

If you want to try this out yourself and have installed neovim with brew, do this:

  brew tap neovim/homebrew-neovim
  brew edit neovim
At the top of the recipe, change the head:

  #head "https://github.com/neovim/neovim.git"
  head "https://github.com/tarruda/neovim.git", :branch => "builtin-terminal-emulation"
And then:

  brew install --HEAD neovim
  -or-
  brew reinstall neovim


This promises to be incredible for all of the use cases where folks currently remote-control tmux windows, etc. When considering things like debugger integration, this cracks the door to some features previously owned well only by GUI IDEs.

I think the killer feature here is not just terminal-in-vim, but the full emulation aspect. When I used to use Emacs extensively, I could never really get into eshell because it ignored terminal emulation. It was OK for some things, but mostly just threw a wrench in my normal shell workflows.


To note: Emacs supports full terminal emulation too, with `ansi-term`. It's a little janky switching between line/char mode, but I use it as my default terminal.

Of course, if you use Vim, this looks great too! I just don't want anyone to be dissuaded from Emacs for this reason ;)


Thanks for the info. It's been many years since I tried shell use under Emacs; I should have figured there'd be a better solution by now!


On debugging, traditional vimmers might want to try Conque GDB: http://vim.sourceforge.net/scripts/script.php?script_id=4582

But honestly, even though I've kept this installed, it still feels foreign enough that I usually just run gdb (or cgdb) in a separate terminal anyway. If I ever make the jump to neovim, I'll be curious to see how much of a native feel can be given to things like this.


> when focused a new mode is entered where all keys are passed directly to the program. The <c-g><esc> combination will return to normal mode.

Is there a mode (planned) that would have local line editing? Something like having a buffer where you can compose your line and then send it to running program. Or can you do that already?


Not neovim tested (I'm an nvi user), but:

[editeditedit]; # <--- on an empty line

<command-mode on your crafted line> 0"ay$ ;# go to start of line, in a buffer named "a" yank to EOL

@a ;# <-- execute the buffer "a"

Example line:

:r!ls -ld <splat>^M

^-- enter ed mode, read contents of command "ls -ld <splat>"[enter]

Is that close (or adaptable?) to what you're thinking of?

EDIT: Test in vim (it works) and change the "[shift 8]" to <splat> (HN html renderer was swallowing the "[shift 8]")


This is, of course, equivalent to curl | sudo sh in terms of security properties.

(Which is not a complaint; I'm pretty okay with curl | sudo sh, because I'm okay with so many other equivalent things, like this.)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: