New answers tagged

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

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.


2

There's no inline, rich command-line editing within Vim in the way many might expect (i.e. like Bash command-line editing with "vi-mode") but you can edit commands with a feature that is arguably even better than that; a feature that even lets you yank/put parts of earlier commands into your in-progress command. I'm talking about the command-line ...


1

Since you don't mind a mapping, we can use cnoremap <S-Left> <C-f>bb<C-c> This remaps <S-Left> to the behavior you described, using <C-f> to switch to edit the command line in normal mode. <C-c> then switches back to command line mode. For details, refer to :h cmdline-window


4

I don't think there is a built-in way to do it with bare cmdline accroding to :h cmdline.txt. But if you are into heavy edit of the command line I suggest to use :<C-f> or q: to open command-line window where you can edit it with 'normal' vim commands. See :h cmdline-window for details.


Top 50 recent answers are included