Live data from Hacker News

Mastering Bash and Terminal

blockloop.io

1–10 of 186 posts

Re: Mastering Bash and Terminal

#2
Rather than temporarily suspend vim to use the terminal you can get vim to suspend and resume itself with the exclamation mark command. This has the benefit of not wreaking havoc on your vim session and allowing you to read data into vim by prefixing with r.

For example

    :!ls
    
will execute ls and show you the result (press enter to return)

    :r!ls
will read the result of ls in for you

More usefully

    :r!sed -n5,10p that/other/file
will read lines 5-10 from that other file.

However you will most often want to

    :!make
    :!up build
    :!git status
    :!git commit -am "Fixed #23"

Re: Mastering Bash and Terminal

#3

Rather than temporarily suspend vim to use the terminal you can get vim to suspend and resume itself with the exclamation mark command. This has the benefit of not wreaking havoc on your vim session and allowing you to read data into vim by prefixing with r. For example :!ls will execute ls and show you the result (press enter to return) :r!ls will read the result of ls in for you More usefully :r!sed -n5,10p that/ot…

You can also install a plug-in like ConqueTerm to devote an entire in-vim buffer to something like a shell session.

Re: Mastering Bash and Terminal

#4

Rather than temporarily suspend vim to use the terminal you can get vim to suspend and resume itself with the exclamation mark command. This has the benefit of not wreaking havoc on your vim session and allowing you to read data into vim by prefixing with r. For example :!ls will execute ls and show you the result (press enter to return) :r!ls will read the result of ls in for you More usefully :r!sed -n5,10p that/ot…

FYI :make also works

Re: Mastering Bash and Terminal

#5

Rather than temporarily suspend vim to use the terminal you can get vim to suspend and resume itself with the exclamation mark command. This has the benefit of not wreaking havoc on your vim session and allowing you to read data into vim by prefixing with r. For example :!ls will execute ls and show you the result (press enter to return) :r!ls will read the result of ls in for you More usefully :r!sed -n5,10p that/ot…

You can also install a plug-in like ConqueTerm to devote an entire in-vim buffer to something like a shell session.

Or you can use tmux (which can be have vim bindings) to run vim in one pane.

Re: Mastering Bash and Terminal

#6

Rather than temporarily suspend vim to use the terminal you can get vim to suspend and resume itself with the exclamation mark command. This has the benefit of not wreaking havoc on your vim session and allowing you to read data into vim by prefixing with r. For example :!ls will execute ls and show you the result (press enter to return) :r!ls will read the result of ls in for you More usefully :r!sed -n5,10p that/ot…

You can also give a range before the ! and it remove the lines in the specified range and pass it to the command.

For example, when reading xml I use xmllint to clean it up:

    :%!xmllint --format -

Re: Mastering Bash and Terminal

#7
For changing directories, you can also use something like z (https://github.com/rupa/z) to jump around:

       Tracks your most used directories, based on 'frecency'.

       After  a  short  learning  phase, z will take you to the most 'frecent'
       directory that matches ALL of the regexes given on the command line, in
       order.

       For example, z foo bar would match /foo/bar but not /bar/foo.

Re: Mastering Bash and Terminal

#8

Rather than temporarily suspend vim to use the terminal you can get vim to suspend and resume itself with the exclamation mark command. This has the benefit of not wreaking havoc on your vim session and allowing you to read data into vim by prefixing with r. For example :!ls will execute ls and show you the result (press enter to return) :r!ls will read the result of ls in for you More usefully :r!sed -n5,10p that/ot…

You can also use the ":terminal" command (":te" for short) in Neovim.

Re: Mastering Bash and Terminal

#9

Earlier quoted context omitted.

You can also install a plug-in like ConqueTerm to devote an entire in-vim buffer to something like a shell session.

Or you can use tmux (which can be have vim bindings) to run vim in one pane.

Tmux is great. I have another writing in progress on my tmux workflow.

Re: Mastering Bash and Terminal

#10

Rather than temporarily suspend vim to use the terminal you can get vim to suspend and resume itself with the exclamation mark command. This has the benefit of not wreaking havoc on your vim session and allowing you to read data into vim by prefixing with r. For example :!ls will execute ls and show you the result (press enter to return) :r!ls will read the result of ls in for you More usefully :r!sed -n5,10p that/ot…

I didn't know about :r in combination with !. That's neat. I typically use :r for reading a file into the current buffer (instead of cp ). Thanks for sharing.

I don't find myself using ! commands when I know there are multiple commands that I need to run (like your last example). That's usually when I'll suspend and then use the command line.

Could you elaborate on "wreak havoc on your vim session?" I wasn't aware that suspending the process and bringing it back into the fg would harm anything.

Post reply on HN