Questions about calling external (shell) commands from within Vi or Vim.
Questions tagged [external-command]
232 questions
95
votes
9 answers
How to execute shell commands silently?
:! can be used to execute a command in the shell. But this "takes over" my terminal and fills it with stdout of that particular command.
How do I execute a command in the background that only notifies me on a non-zero exit code?
OrangeTux
- 3,566
- 3
- 20
- 27
34
votes
5 answers
How to use an external command in Vim to modify selected words and lines?
Something I've found useful in other editors is the ability to:
take the selected text
run an external command and pass the selection to its stdin
take the external commands stdout and replace the current selection with it.
This way you can write…
ideasman42
- 3,733
- 3
- 27
- 34
15
votes
2 answers
Use Vim with virtualenv
I do a lot of Python and I use almost all the time a virtualenv along with virtualenvwrapper to keep my modules organised.
But when I want to use those plugin from inside vim, through an external command, it seems that the shell is not aware of that…
nobe4
- 16,033
- 4
- 48
- 81
15
votes
1 answer
How to go to the next grep result?
I'm using grep to find function occurrences in a project.
:grep "set_val" *
Goes out of vim and outputs:
code.py:68: self._device.set_val('Level', new_level)
code.py:84: self._device.set_val("Mode", "Remote")
Press ENTER or type…
TheMeaningfulEngineer
- 279
- 2
- 9
12
votes
4 answers
:read after cursor instead of after line
I use :r !uuidgen frequently to insert a new uuid into the buffer. This works, but I am generally attempting to insert the uuid between quotes, and :r !uuidgen prints the uuid on a new line.
To get around this issue, I am currently using a simple…
user489
11
votes
2 answers
External command on unsaved buffer
Is it possible to pipe an unsaved buffer to an external command and then replace the buffer by the command’s output?
Toothrot
- 3,129
- 13
- 27
9
votes
3 answers
How do I know i am in a shell from vi command :sh?
In vi, I can get a shell terminal with :sh command. And later, I can return to vi by exit shell.
But, if I was using the shell terminal for a long time, and I forgot whether exit will close anything or return me the vi.
Is there any way to check…
hailinzeng
- 197
- 2
- 5
8
votes
2 answers
How to render html file?
I've the following sample html code:
vim http://example.com/
Is there any way to actually render html inside vim editor?
In example using markdown formatting or something similar?
Example scenario: I'm logged on remote machine when I don't have…
kenorb
- 18,433
- 18
- 72
- 134
7
votes
3 answers
separate stdout and stderr of system() command
I can catch the output of running a system command via system() or systemlist(), but that actually gives me the result of stdout and stderr combined.
As I am only interested in stdout (and may use stderr for other purposes), this isn't useful for…
radlan
- 677
- 6
- 15
6
votes
4 answers
How to dump output from external command into editor?
In example, I would like to paste the current time or date into editor by using external commands (such as date) without leaving vim.
How this can be achieved?
kenorb
- 18,433
- 18
- 72
- 134
6
votes
2 answers
how to perform multiple grep passes by using piping in external shell?
When I want to recursively search files for a text pattern I use
:grep -R 'color:' .
Vim then lists the results in a quicklist window for easy access.
But now I need to perform another grep pass to exclude some results.
So far I have tried
:grep -R…
the_velour_fog
- 3,335
- 3
- 22
- 40
6
votes
2 answers
Can I run :make without moving the cursor?
I use the mapping nnoremap m :w \|silent make\|redraw!\|cw which allows me to run make while I am editing a file by pressing m.
It annoys me that if my cursor is in the middle of a line when I run this command, after the command…
sid-kap
- 183
- 4
6
votes
3 answers
`Read` seems to bring an extra line - how to prevent this?
I set up this function in my .vimrc file. It duplicates the current window, moves it to a new tab, reads the output of yapf (a code formatter) run on the current file, sets up a diff between the original file and the formatted file, and selects the…
LangeHaare
- 183
- 5
5
votes
1 answer
How do I execute an external command without jumping out of vim?
I want to execute some external program to format my code.
:silent execute "!eslint --fix -o /dev/null %" | redraw!
But the screen will jump to the shell output screen and shortly back to vim again. How I can avoid this short flash?
Aaron Shen
- 2,519
- 3
- 24
- 37
4
votes
1 answer
Autoreturn after external command
When I run the following command ex:
:! some_command
It's somewhat annoying the message:
Press ENTER or type command to continue
Is there a way to automatically return to current buffer without press ENTER?
sebelk
- 325
- 2
- 10