top | item 20482195

(no title)

stirfrykitty | 6 years ago

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.

discuss

order

Syssiphus|6 years ago

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

pselbert|6 years ago

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

TheGrassyKnoll|6 years ago

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

SEJeff|6 years ago

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

stirfrykitty|6 years ago

Does that work in all shells?

bch|6 years ago

> :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.

miguelmota|6 years ago

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

magduf|6 years ago

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?

passthejoe|6 years ago

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

Zelphyr|6 years ago

You can also do

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