Hot answers tagged

17

A process can block, ignore, or catch signals. You can see how a given process handles signals with this shell command: $ cat /proc/PID/status | grep -E '^Sig(Blk|Ign|Cgt):' │ │ │ │ │ └ caught signals │ └ ignored signals ...


10

When you use ! or :! Vim builds the invoking command based on whatever is specified in the various 'shell...' settings (i.e. 'shell', 'shellcmdflag', 'shellquote', to name three). On Unix systems the defaults for the first two are usually the default shell ($SHELL) and -c so if I'm using Bash and I do :!foo bar the call Vim makes will look like: /bin/bash -c ...


6

Just use :vertical terminal and then just map it to a key or something. Also, I have this in my vimrc: map <Leader>t :set mouse=a<CR>:vertical terminal<CR> That enables me to switch between split windows with my mouse since you wont be able to use :wincmd (h,j,k,l) to switch back and forth split windows cause youre in the terminal. You can ...


6

Is there a way to see exactly what shell command is being called out? To see what exactly is run, :echo getpid() will show vim's PID, e.g. 1234, with which you can then in another terminal run: sudo strace -fe trace=execve -p 1234 then in vim you can use any shell-invoking command like: :!echo foo and in the terminal running strace see something like: [...


4

An easy check is :!foo that (probably) will print something like bash: line 1: foo: command not found. Also see :h job_start() (or :h jobstart() for Neovim) and so on. To summarize: :! always uses &shell (as well as &shellcmdflag, &shellquote, &shellxqoute and so on); :h system() and :h systemlist() use &shell in Vim; in Neovim it ...


4

The main issue that needs fixing here is that the | character is special here, it is used as a separator for Ex commands and is not passed verbatim to your mapping. In order to fix it, you need to either use <Bar> or \| here. See :help map-bar for more details. Additionally, you'll probably want to add a <CR> at the end, to actually execute the ...


3

Based on :help v:count: *v:count* *count-variable* v:count The count given for the last Normal mode command. Can be used to get the count before a mapping. Read-only. Example: > :map _x :<C-U>echo "the count is " . v:count<CR> < Note: The <C-U> is required to remove the line range ...


2

:terminal spawns a new shell in a Vim window, so you can see a program compiling or producing some output at the same time you edit another normal buffer. Also, by pressing <CTRL-W>N, Vim can operate on the read-only terminal buffer, with yanking, Vim navigation, etc. :shell also spawns a new shell, but this is a full terminal window shell (it is not ...


2

:! runs the command in a (usually non-interactive) shell. See chapter 21 of the user manual and :h :! for more information. This is different to :term which runs an interactive terminal in a vim window. This is a relative new feature which vim needs to have been compiled with, the details of which can be found at :h terminal. If you want to type in the ...


2

This behavior is happening because your 'iskeyword' did not include "_" as a valid keyword character when the syntax was first loaded. The syntax for sh (among many other languages) use the :syn keyword command to define syntax based on keywords, and where the keywords are recognized (regarding the delimiters around them) depends on the 'iskeyword' ...


2

The video shows Vim, not Neovim. In Neovim the output of "bang" is not colorized. If you like long stories you can read this and this and so on. TL;DR they think it's not a big deal, but fixing "bang" may be too hard, so just use :terminal instead.


2

Like @Mass's comment suggested, you can create a columnize.sh file... #!/usr/bin/env bash set -euo pipefail sed -e 's/|/'$'\001''|/g' | column -t -s $'\001' (Make it executable of course chmod +x columnize.sh.) And then in .vimrc map it: vnoremap <leader>t :!columnize.sh<CR>


2

I found a solution to this issue on this answer from StackOverflow. The following line does what I expected in my question: var=$(cat myfile.txt | vim -e -c ':g/./normal osleep 0.5' '+%p' -escq! /dev/stdin) Honestly, I don't fully understand the syntax '+%p' -escq! /dev/stdin... But adding it on the pipe works to continue pipping values through Vim.


2

The problem you're having here is that the test command with a single argument will by default check whether or not that's an empty string. So, in your case, it's taking the 0 and looking at it as a "0" string, which is not empty (it has one character), but the same with a fail error code, like 1, which it sees as "1" and it's also non-...


2

One way to do this is to use fnameescape: Y:!<C-r>=fnameescape(@")<CR> But it may not be perfect if the command has spaces. You could also try split(@")->map('fnameescape(v:val)')->join(' ') in the expression, or some combination of shellescape()/escape(…, '%#'), etc.


1

The comments by B layer and Ben Knoble were both helpful in finding the answer. Vim correctly set the shell based on the $SHELL variable, but did not set shellcmdflag appropriately, and that was what the /s was, the default shellcmdflag for cmd.exe, as stated in the :help 'shell' file. Setting it to -c in my init.vim seems to have solved the problem, and a ...


1

Possible answer derived from https://vi.stackexchange.com/a/10211/8846 - doesn't function in quite the same way, but :.w !fish does send the text to a new shell literally and returns the correct answer. It also makes it easier to write short python or other language programs instead of shell script, which would be an advantage.


1

As a slight workflow adjustment, I would use :make (or possibly :Make from the dispatch plugin) to build. Then I would run :terminal ./overlay & for the program part. This gives you a window running exactly that command. (There’s also :Dispatch, and maybe :Start/:Spawn, from the dispatch plugin. All are async when possible and come with foreground and ...


1

What you're describing can be easily achieved with vim-altscreen. Based on the screenshots in your post and the short description of what you want at the top of it, this seem to match what you seek.


1

It is not quite answering the question, but you can run :make to compile from vim, and will allow you to jump to the location of the first error. Then, you can run :cwindow to display the quickfix window, to have the list of errors in a split. The quickfix will have some color highlight: Bringing your cursor on an error line and pressing return will make ...


1

The :execute command will assemble an Ex command from strings and evaluate it. Here, in this case, it's actually breaking your command, since it's expanding the g:projectRoot string and forming a string that is an invalid Ex command, since the quotes around the path are now missing. That command is actually equivalent to: let ProRoot=/mnt/hgfs/projects/...


1

Well, there's :silent: :sil[ent][!] {command} Execute {command} silently. Normal messages will not be given or added to the message history. and there's :! :!{cmd} Execute {cmd} with the shell. See also the 'shell' and 'shelltype' option. Your hunch is mostly correct; I'm not sure why the cursor goes to ...


1

Since I posted this the title of the question was changed to explicitly reference arguments. Just in case someone gets the idea that I have reading comprehension issues... ;) To send multiple lines of Visually selected text to a shell command I'd do it this way: :vnoremap XXX :w !<shell command> <CR> If you enter : when text is selected you'll ...


Only top voted, non community-wiki answers of a minimum length are eligible