0

I am writing a script.

When I select an option it needs to basically run the ls -l command.

How would I get that format in the vi editor as a line command?

closed as unclear what you're asking by muru, user79743, Jeff Schaller, vonbrand, cuonglm Mar 7 '16 at 3:34

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Sorry, but your question is unclear. Could you try to rephrase it? – techraf Mar 7 '16 at 2:04
2

Entering system commands in vim is easy. Just preface it with the ! character. So for example, if I wanted to run ls -l inside of vim, I would execute !ls -l in vim.

If you wanted to then capture it into the buffer, you can use the read command. :read !ls -l.

  • There is a shortcut for capturing it into the buffer: :.!ls -l – user1794469 Mar 7 '16 at 2:49
  • or even just !!ls -l to replace the current line with the output of ls -l – cas Mar 7 '16 at 4:11
  • @user1794469. It's :r!ls -l to add the output of ls -l under the cursor. :.!ls -l or !!ls -l would replace the current line with the output of ls -l – Stéphane Chazelas Nov 28 '16 at 14:17

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