Questions tagged [shell]

Question about the functionality that let Vim interact with shell command typically triggered Cia the :! command.

Filter by
Sorted by
Tagged with
0 votes
0 answers
46 views

Shell commands in Vim vs. Neovim?

When I run a shell command in Neovim like :!ls the results come up in a little minibuffer. In Vim, the Vim instance is temporarily closed and the results are printed to the terminal without my ...
Vinn's user avatar
  • 627
2 votes
1 answer
41 views

:.w !bash a temporarily modified line and executing it in the shell

#!/usr/bin/env bash # scp /tmp/abc.sh SERVER1:~/bin && ssh SERVER1 "~/bin/abc.sh" echo "Hello Stack Exchange" echo "thanks for the help I would like to be able to use ...
Aaron Burda's user avatar
0 votes
0 answers
40 views

neovim: pwntools process automatically stops when trying to invoke interactive shell

I'm using python pwntools. I'm using python 3.10.x This line of code should open a shell for me: io.interactive() But while running this file from vim using !./% it doesn't open the shell doesn't ...
NobinPegasus's user avatar
0 votes
2 answers
706 views

Change default shell to powershell in Neovim

Currently the default shell nvim uses is cmd.exe I tried changing it by setting shell to powershell in my nvim config but that didn't work, so I tried this command in the nvim command line: :let &...
Rohith Nambiar's user avatar
0 votes
2 answers
175 views

Selecting text from shell in neovim

I like to execute my scripts in the shell using :! % But once I do, I can't select the text from the shell in the output. I'm currently using neovim. When I click into the shell to select the text, I ...
pepperdreamteam's user avatar
0 votes
1 answer
62 views

Put word count of lines into variable

I can get a word count of a range of lines, by doing something like this: :1,20w !wc -w (where that gets lines 1 to 20, writes (w) them to the external shell command (!) wc -w, and outputs the result ...
markling's user avatar
  • 319
1 vote
1 answer
79 views

Determine if a bash script is called within vim

Is there a way for a bash script to determine if it's being run from within vim? I'm writing a small bash script that is only useful if called within vim. I'd like to assure that it only does its ...
MDeBusk's user avatar
  • 363
1 vote
0 answers
71 views

set shell = powershell. But I want to use the Anaconda powershell

Is there any way to use the Anaconda powershell instead of the standard Windows powershell? In my .vimrc I have set shell=powershell set shellcmdflag=-command Running on Vim 9 for Windows.
Barzi2001's user avatar
  • 438
0 votes
1 answer
26 views

Setting a filetype for piped input

Is it possible to set filetype when starting vim? I would like to get C highlighting when doing something like: $ echo 'int main(){return 0;}' |vi -R - from a shell. I have tried adding --cmd 'set ...
Petr Skocik's user avatar
1 vote
2 answers
418 views

How to use value under cursor in the shell command?

Is it possible to use word under cursor in shell command? Say: Elvis ^ cursor here then :r! echo <word_under_cursor> and get "Elvis" read in.
l00p's user avatar
  • 243
1 vote
1 answer
283 views

How to recognize Azure pipeline template expressions in bash?

When I work with Azure DevOps pipeline files (yaml), I don't get any syntax highlighting in script or bash blocks: That's why I have installed inkarkat/vim-SyntaxRange and configured it to recognize ...
MaxGyver's user avatar
  • 229
2 votes
1 answer
105 views

Execute a shell command over a visual range with a user input prompt?

In my Markdown notes, I would like to: Select a few lines with V Encrypt those lines, externally, with :!gpg Prompt for a password rather than store it, possibly with input() I tried executing over ...
Luke's user avatar
  • 123
1 vote
1 answer
167 views

What factors control the color scheme in a terminal?

I am trying to use VIM through new "Windows Terminal" app on a Windows 10 operating system. The VIM app is installed inside a debian WSL app. I can't wrap my head around how the entire color ...
Asad Munir's user avatar
1 vote
0 answers
72 views

gVim ':terminal' accents don't work

I am using gVim in Xubuntu 20.04. My version is vim 8.2.4295. If I use a regular terminal, like xterm, and open Vim and then type ':terminal', I can use accents, e.g., íàê, etc. while in the vim-...
Carlos's user avatar
  • 11
1 vote
0 answers
27 views

False indentation after line continuation in if-else clause for `sh` filetype

I have shell script file (filetype=sh) like if [ -f filename ]; then echo "file exit" | \ cat - else echo "file not exist" fi When I select the block and apply ...
auditory's user avatar
  • 170
1 vote
0 answers
390 views

How to view the full shell error from a vim script?

I have been using vim/nvim for years on my desktop, and one of the most useful libs I have is the FZF vim plugin, specifically the command that lists the tags from the current buffer: :BTags [QUERY]: ...
abbood's user avatar
  • 633
0 votes
1 answer
33 views

Help in troubleshooting strange behavior when resuming Vim from background

Latest update I start to think that the problem is not due to Vim in the first place. See this. Previous update I think I've almost tracked it down. The issue seems to be due to either command-t or ...
Enlico's user avatar
  • 2,162
1 vote
0 answers
76 views

How to customize how neovims "shell command buffer" is shown?

I am wondering about the behavior of the buffer that appears in the bottom of the terminal when running a shell command in neovim. How can I make it appear the right side instead? How can I make the ...
mama's user avatar
  • 123
1 vote
0 answers
49 views

How can I launch interactive terminal programs in neovim just like I can do in vim? [duplicate]

I'd like an easy way to switch from neovim to vim for the reason of, some plugins are not compatible with neovim (Ultisnips). I hope'd I could just run :!vim however that doesn't work - errors appear: ...
Chris Stryczynski's user avatar
2 votes
2 answers
1k views

Make `!` work with powershell (neovim)

I want to use ! with powershell. I use neovim natively on windows. I tried these settings set shell=powershell.exe set shellcmdflag=-NoProfile\ -NoLogo\ -NonInteractive\ -Command set shellpipe=| set ...
eyal karni's user avatar
  • 1,016
2 votes
2 answers
143 views

Make `%!` work in windows

I am on windows natively with neovim-qt . I tried to use %!python -m json.tool on a valid json file . It says Expecting value: line 1 column 1 (char 0) . In powershell : cat .\graphs.json | python -m ...
eyal karni's user avatar
  • 1,016
1 vote
0 answers
72 views

Using inline cmdline expressions in windows

I wondered if I could use inline cmd expression like in the example :args ``find -iname *.py`` So, I wanted to either use WSL expressions(same as above) or powershell (Get-ChildItem C:\temp | Select-...
eyal karni's user avatar
  • 1,016
1 vote
1 answer
457 views

How can I create a shortcut that saves the file and executes a sequence of shell commands?

I know that I can create shortcuts on a vimrc file like the following: :map <C-W> :w<CR> However, let's say I have some different commands that I can execute on my shell: notify-send &...
raylight's user avatar
  • 505
0 votes
1 answer
59 views

Shell script runs multiple times, I want it to run only once

I use vim pretty extensively for latex compiling. I've a function which automatically compiles the current tex file. I use pdflatex as a compiler, which creates a bunch of different files that it ...
nikinbaidar's user avatar
0 votes
2 answers
476 views

how to run a shell command in the same shell process that vim was started

I want to source a file in the same shell process vim was started, from within vim as an ex command. As far as I know, vim creates a new subshell and run commands. In addition to that, If I source a ...
Ali's user avatar
  • 151
3 votes
1 answer
1k views

Using the execute shell command (:!) on Windows and MSYS2

I'm new to neovim (and vim in general), and I'm trying to use it on Windows with MSYS2. I noticed they have a package for vim, but not for neovim. I used the neovim installed through chocolatey ...
Bodhi Daruma's user avatar
1 vote
1 answer
45 views

Issue with makeprg Shell Script $? Variable

I have the following .vimrc: let &makeprg="./run-tests" The contents of run-tests: #!/bin/sh error_file=$(mktemp) coverage run --source "$PWD" --branch -m pytest tests/ >&...
Edward Chamberlain's user avatar
0 votes
1 answer
219 views

Vim8 && in :terminal's [command]

When running the vim command :!echo A && echo B the result is as expected A B Press ENTER or type command to continue However when I try to do the same thing with the new integrated terminal ...
Fraser's user avatar
  • 103
0 votes
2 answers
66 views

How to execute a shell script from a line in a file with `%` in it

I have a shell script on a line alone in a file which I would like to be able to easily execute from vim. Normally I could simply use Y:!^R", but this particular script has % in it, which is ...
Iiridayn's user avatar
  • 193
8 votes
3 answers
1k views

See what Vim `:!` executes

Between :%! exe "!..." exe "!bash -c" shellescape(...) I'm getting quite confused as to what exactly Vim invokes. And I suspect at some point it invokes bash -c bash .... Is ...
usretc's user avatar
  • 345
1 vote
3 answers
198 views

How can I open a file, edit it and save its output to a shell variable?

I know that I can open a file through a pipe with vim with the following command: cat myfile.txt | vim - I also know that I can edit files on vim directly from the command line as the following: vim -...
raylight's user avatar
  • 505
2 votes
2 answers
624 views

How to execute shell command and show result right inside vim similar to when execute command through autocmd?

The main objective of this question is I want to get the shell command's execution result to show in small split window right inside vim while I'm editing the file; the same result I would get when I ...
haxpor's user avatar
  • 121
0 votes
0 answers
982 views

"Inappropriate ioctl for device" and "no job control in this shell" bash error

I am getting a bash|1 warning| Inappropriate ioctl for device when Ale runs lint on cpp files with gcc/g++. Using gcc/g++ to compile manually in the terminal works fine. Otherwise the linting of cpp ...
Tiseno's user avatar
  • 1
11 votes
1 answer
2k views

Why is it not possible to kill Vim using the TERM signal from inside Vim itself?

Out of curiosity, I tried to kill Vim from inside vim --clean. I tried: :!kill $PPID :call system('kill ' . getpid()) However, nothing happens after running the commands above. The commands give no ...
Flux's user avatar
  • 991
6 votes
1 answer
1k views

How to color VIM ":!{cmd}" output?

I'm trying to get the same setup as the guy in this video, so that when :!pytest % gets called, the output is colored. I've tried with various vanilla colorschemes, with no luck... I'm using Neovim, ...
eltbus's user avatar
  • 171
2 votes
2 answers
121 views

How to turn this piped bash command into a vim map?

I have a bash command that will align text into a tabular form. If I have input such as this: A | B | C Alpha | Beta | Gamma 12 | 34.56 | 78.9 I can run cat test.txt | sed -e 's/|/'$'\001''|/g' | ...
Roxy's user avatar
  • 177
1 vote
1 answer
218 views

Can't use the usual !!foo in vim // gvim on Windows 10 - missing tmp files

I'm running vim // gvim 8.2 (fresh off of vim.org, and was before---just re-installed to do so as administrator, per instructions I'd missed before). I've been getting this since getting this Windows ...
GTbrewer's user avatar
0 votes
1 answer
225 views

How to pass custom arguments to the shell invoked by :terminal?

I would like to specify the startup command to run on the :terminal shell. E.g. bash -c ls. The shell can be specified with set shell=bash, but how to specify the arguments? In another use case, I ...
tejasvi88's user avatar
  • 390
0 votes
1 answer
1k views

Send command to :terminal buffer in Vim?

I used :term to open a new integrated split terminal window. The problem is, using :! <cmd> opens a new buffer which takes the entire screen, runs the shell command, then waits for me to press ...
daedsidog's user avatar
  • 153
0 votes
1 answer
97 views

Shell syntax, how to patch bad highlight groups

The neovim syntax for shell scripts doesn't check if keywords like echo, done, exit etc.. are surrounded by blank spaces or if they're part of a bigger Word. This results in the following bad ...
noibe's user avatar
  • 179
2 votes
1 answer
223 views

Is there a filetype in Vim when opening the a file containing output/errors from g++ so that I can see those files with the original coloring?

Sometimes, when faulty outputs from compilations of C++ files/projects are to long, I like to redirect that output to a file, so that I can inspect it side-by-side with each of the offending files in ...
Enlico's user avatar
  • 2,162
0 votes
1 answer
2k views

Vim function : how to expand vim variable in shell command?

I'm trying to write a vim function to update ctags and cscope databases. I'm trying to save the vim variable projectRoot in environment variable then expand this enviroment variable in the find ...
Salahuddin Ahmed's user avatar
0 votes
1 answer
89 views

Running Vim in shell script opens rest of shell script in a buffer

I've got Vim starting in a shell script to install some plugins. I'm using nvim --headless +PlugInstall +qall, but when Vim opens, it has the rest of the shell script (cd $HOME/.config/coc/extensions &...
twlscnds's user avatar
  • 103
1 vote
1 answer
420 views

In vim8.2, is there any difference between using :term vs :shell?

In vim 8.2, is there any difference between using :terminal versus :shell to run commands on shell? Or are they identical? I would like to know if there are any specific use-cases for using :shell vs :...
avimehenwal's user avatar
0 votes
1 answer
154 views

What is :silent !echo doing? Why does it get the cursor to the top?

This question on StackOverflow triggered my curiosity. What does :silent !echo doing? The first time I saw something like :excommand !shellcommand was when I was looking for a way to save a read-only ...
Enlico's user avatar
  • 2,162
3 votes
1 answer
67 views

Repeating command for running external script?

I have a script called lorem.sh which takes in the number of paragraphs(first argument) and number of lines in each paragraph(second argument) and prints random text of that format to standard out. I ...
First User's user avatar
1 vote
2 answers
955 views

Pass visually-selected text as argument to script

I am trying to write a command that passes selected text to a shell script. The command works fine when there is no \n character in the selected text (using Visual mode). :vmap <Leader>tts 0y:...
Tony Barletta's user avatar
5 votes
2 answers
430 views

How to put partial command in command bar?

I am trying to do something like this, from a function: nmap <F5> :!python % Pressing F5 in this case causes the command :!python % to be left in the command line. This is preferred for me, ...
thesilican's user avatar
1 vote
0 answers
703 views

Vim: How to have YouCompleteMe autocomplete shell script variable names and functions from "source"d files?

I use macvim with YouCompleteMe (YCM), which I recently updated and recompiled. I followed the YCM instructions for OSX. I'm also using iterm2, tmux and zsh, all of which are installed with brew and ...
Life5ign's user avatar
  • 111
1 vote
1 answer
189 views

vim/gvim freezes when shelling out, how to trace events?

NOTE: This underlying problem was solved by an update of Cygwin packages and re-install of vim. However, the question of how to trace errors in shelling out remains, so answers along that front would ...
user2153235's user avatar