Thursday, May 2, 2024
18
rated 0 times [  18] [ 0]  / answers: 1 / hits: 27895  / 3 Years ago, wed, august 25, 2021, 1:26:37

In vim, when I use



:r !ls somefilename



it inserts output of that command on a new line below the current line.



If I do



let @a = system("ls")



and later



"ap



it still inserts the output on a new line below the current line.



Is there a way to make vim insert output at the current location?


More From » command-line

 Answers
0

You can paste the contents of the clipboard buffer between characters with Ctrl-R * in insert mode (and a similar approach for other buffers). So if you can get the system command into a buffer, you should be set. (Source: https://stackoverflow.com/questions/1491135/paste-multi-line-string-into-gvim-at-cursor-position ).



:let @a=system("ls -l") will put the output of ls -l into register a. You can then paste it (in insert mode) with ^R-a.


[#35946] Thursday, August 26, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
pipeag

Total Points: 489
Total Questions: 107
Total Answers: 115

Location: Iraq
Member since Fri, Jun 5, 2020
4 Years ago
;