Hacker News new | past | comments | ask | show | jobs | submit login

Been using vim since 1998 and rarely stray unless I'm typing notes for something unimportant and them I use Nano.

Back in the day when I was a Unix admin, we often worked in full screen terminals and when editing a config file didn't like having to close the vim instance to go look at something, so learned about this little gem:

:sh (go back to shell and do your thing and leave vim running)

Ctrl-d to return to intact and running vim instance.

As an aside, if you decide to use nano to edit config files, make sure you use nano -w (no wrap), otherwise you may find yourself with a non-bootable OS instance.

Or just CTRL+z and then 'fg' to go back.

This is one of the many things I learned from the destroyallsoftware screencasts [0] so many years ago. Before that I used vim in a gui (MacVim). Along with moving to tmux this completely changed how I work.

[0]: https://www.destroyallsoftware.com/screencasts

That's what I do in Emacs. I always run it from a terminal (currently using Terminator).

This is exactly what I do all the time and works nicely.

Does that work in all shells?


I haven't used many esoteric environments, but wikipedia says it "exists in most modern Unix shells" and the timeline for first adding it was the late 70s early 80s.

Job control was first implemented in csh, another Bill Joy invention, although I believe that particular feature was added by someone else.

> :sh (go back to shell and do your thing and leave vim running)

In nvi (at least), one can also open a buffer and :script to run a shell inside vi and have all the yank/paste/navigation/all-the-things features of vi. Mind you need to i[nsert] or a[ppend] after the prompt to issue your commands.

Been using vim for almost a decade and embarrassed to not have known about how to go back to vim after doing `:sh` , so thanks for sharing that. I use tmux all the time so I tend to switch to a pane running bash and `ctrl-b z` to toggle the pane fullscreen

I wouldn't even use nano for typing notes; I'm so used to vim that I don't see why I wouldn't want its powers, even for something as simple as writing notes. I might very well want to reorder the notes, for instance: that's very easy in vim with dd/p. nano might have some Ctrl-key combo that does the same thing, but why bother learning that when I already know vim?

The worst thing is when you start typing Vim commands in programs that are not Vim.

You can also do

    :! ls -a
to execute a shell command and see the results from within Vim.

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