People who code: we want your input. Take the Survey

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

while the normal command doesn't seem to work normal must always return to Normal. It is considered normal in Vim. I am trying to do something like this, from a function Not really useful for this simple example, but, in general, there are many situations one may want it. Simply make use of :h map-expr (or, alternatively, the expression register), like ...


6

This is one of the very rare cases in which feedkeys() is actually called for. Doing :call feedkeys(':!python %') should work, since feedkeys puts stuff directly on vim's input buffer.


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

In Vim line continuation is done with a backslash on the new line. Like: noremap <C-F12> :!bash -c ' \git rev-parse --show-toplevel \\| xargs -I {} \ ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q {}' \<CR> Another point is the usage of | in the command line, as it is a command ...


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

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

: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

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.


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 ...


1

Contrary to what I inferred from a too-quick perusal of the help, setting the verbose option to 5 lets me see the command that is issued by vim when shelling out. By then, however, I had already banished the problem by upgrading all Cygwin packages and re-installing vim. So I will probably never really find out what the pathology was in shelling out. ...


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