1

When we execute any system command and get the output, it prints in next line. But I want it in current line, next to the cursor or in place of cursor (not at the start of the current line)

Example:

:r! ls

Prints the list of files in the current folder.

But this prints the output in next line. Is there any way to print the output in the current line, next to the cursor?

Some example situations:

  • listing of files inside quotes
  • executing a perl/external program and getting its output pasted here.
5

In normal mode press double !, then enter the command, or just type the following:

:.!ls
| improve this answer | |
2

One can execute any external command in command line using the system function:

:let @a = system("ls -ltr")

And when you want to paste, press Ctrl+R and immediately a to paste the content next to cursor.

@a is the register name. You can use whatever register you want.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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