Questions tagged [command-line]
Questions on ex- or colon-commands. For questions about command-line options used to launch the editor, use the [invocation] tag.
464
questions
0
votes
1
answer
856
views
Passing a count to a user command with neovim's Lua API
vim.api.nvim_create_user_command("TestCommand", function(opts)
print(opts.count)
end, { count = 1 })
vim.keymap.set("n", "<C-x>", "<cmd> TestCommand ...
0
votes
1
answer
191
views
How to repeat a command in command-line mode
I need to repeat the delete of matching lines in vscode-vim. Unfortunately the g has not been implemented yet, so I'm trying to figure out a way to repeat the same change in command-line mode using ...
0
votes
1
answer
452
views
Show command prompt including commands issued before entering neovim
I've been using vim for a long time and got used to issuing:
:!
to peek at the command prompt behind the vim "window" working on Terminal.app in Mac OS where I can see old commands and ...
1
vote
2
answers
40
views
Where's the documentation for Ctrl-C while in [Command Line] buffer?
Long ago I discovered that q: opens a [Command Line] buffer where I can enter and edit an ex command line using all the power of Vim.
Next, some time ago, I discovered that I can access that mode even ...
2
votes
1
answer
178
views
How to :edit executable from path?
Environment: Linux
I apologize in advance if this question already exists somewhere and has a proper answer.
It is just so difficult for me to search because the keywords are all so generic.
Put ...
5
votes
1
answer
547
views
How to use -complete=lua for command-completion?
If you check the help for :command-completion, there is a line that reads:
-complete=lua Lua expression
But it does not give further instructions about how to use it, or how to provide a Lua ...
3
votes
2
answers
437
views
The way to excute same command in command-line mode multiple times
I'm recently working on a project in vim, and I need to execute the same command in command-line mode multiple times to different files which are in the same folder.
like
:%s/V1/V2/g
Is there a ...
0
votes
1
answer
42
views
!v command UNIX - relation to Vi or vim [closed]
Whenever I type !v command in the UNIX terminal, in a particular directory, my vim editor opens with the file "hello.txt" which I have never created in that same directory or anywhere.
What ...
0
votes
1
answer
117
views
How to delete all lines in a command script without provoking error?
I'm trying to write a Vim command script (a file containing Ex commands) that removes all existing lines in a file (and then read in some new text, and do some further editing operations). I use the ...
2
votes
1
answer
102
views
Is it possible to keep folds saved when I copy from one file to another?
I've recently discovered I can fold blocks of code with Vim by using zf.Then I can open and close them with zo and zc... I've also seen this solution on StackOverflow that has a vimrc configuration ...
0
votes
2
answers
73
views
How to get nnoremap <buffer> to work in different buffers?
I have a hotkey that runs python of the first buffer when I press F8 and outputs the outputs to the bottom.
However, this hotkey does not work when I switch buffers... it only works when I am on the ...
0
votes
0
answers
254
views
Call custom bash function from Vim
I have created a bash function, in its own .sh file, which I want to use from within Vim, and later use if from within the lightline config file. I have tried many ways, but I cannot make it work.
...
-1
votes
1
answer
62
views
how to disable the new popup file-picker on :w
If I try to write a file under a new name, instead of being able to edit an existing name provided by file-completion, I get a pop-up that only lets me select an existing one.
I saw a description of ...
1
vote
1
answer
20
views
:.!python3 cannot be used with input()
:.!python3 command is one of my favourites. But it cannot be used with input() function. Is there an alternative method?
0
votes
0
answers
46
views
calling vim with mpiexec says "Warning: Output is not to a terminal / Warning: Input is not from a terminal"
My question is a bit technical.
For specific reason, I need to call vim after mpiexec.
Example :
mpiexec -n 1 vim mytext.txt
But this gives the following warning message:
Vim: Warning: Output is not ...
1
vote
1
answer
497
views
Enabling Autocompletion for a Custom Command
I have the following lines in my vimrc:
command -nargs=1 Compare call Compare(<f-args>)
function Compare(file)
execute "vnew " . a:file
setlocal nomodifiable
wincmd h
...
5
votes
1
answer
255
views
Starting vim with a command typed in, but not executed (i.e. waiting for argument)?
I know I can start vim with a command by executing vim +"MyCommand", but if MyCommand takes a parameter it would be nice to start vim, as if I already typed :MyCommand but not actually ...
3
votes
1
answer
127
views
How to input <CR> into ex command from script or commandline?
I recorded a macro, that has an enter in it ggd/{<CR>Gdd but of course is ^M. What I want to do is run this on a bunch of files from the commandline which I guess would be something like
ex +&...
4
votes
4
answers
295
views
Delete non-consecutive lines in command mode
When I edit some code, I have a repl aside which gives me useless imports/includes, and I'd like to remove them in one command.
To be concrete, I have the following text:
import A
import B
import C
...
3
votes
1
answer
197
views
Sort tab-completion suggestions (files first, then directories) in vim command line
When i go to command mode, type :e and press tab, i get like this
Excuse the file, directory writings on the right side (used for explanation)
A.cpp file
Adamwathan/ directory
...
5
votes
1
answer
334
views
Opening multiple files on specific line numbers in vim
I would find it useful to open several files at the same time on specific lines.
I know I can open a single file on a specific line with:
vi +123 ~/.zshrc
And I can open multiple files with:
vi ~/....
1
vote
1
answer
31
views
Apply next non-blankline function as one part of multi-part user-command
Why do I seem to get different results when I apply this function from the vim command line than when I apply it as part of a user-command?
" advance to next non-blank line only if current line ...
2
votes
2
answers
253
views
How do I prefill the vim command line with a function and then edit the result?
Got this function:
function! TaskAnnotateWithFile()
let uuid = GetUUID()
:!task
echo uuid . ' '
annotate -- ~/
endfunction
The idea here is a I want to prefill the command line with ...
0
votes
1
answer
128
views
Git mergetool with three tabs
I would like to configure a git mergetool setting with vanilla Vim 8.2 to open up three tabs:
Tab A: The merged file (the file that is supposed to be edited)
Tab B: Diff between base and local file
...
1
vote
1
answer
88
views
How to expand a value to place it in the ex command?
The goal is to create a mapping that will:
create a mapping for the user --> remap does the trick
that gets the current expression under the cursor --> expand('<cexpr>') will do the trick
...
0
votes
0
answers
21
views
When I run :LanguageToolCheck, the output is the java -jar command in a new buffer
I've been trying to utilize Vim to do more writing so I tried to install LanuageTool and a related vim plugin: https://github.com/dpelle/vim-LanguageTool/
However, even after specifying the location ...
6
votes
2
answers
3k
views
How to run multiple commands sequentially in nvim?
What I have referenced in my .zshrc file:
nvim --headless -c 'LspInstall tsserver | qall'
This doesn't work. The qall is regarded as an argument of LspInstall while I didn't mean to. The LspInstall ...
0
votes
1
answer
38
views
How to delete all user-defined commands starting with XYZ?
How can I delete all user-defined commands where names share a common prefix (e.g. XYZSomeCmd, XYZAnotherCmd, ...)?
Found myself with a lot of dead commands while writing a plugin and changing prefix ...
1
vote
1
answer
169
views
What is the `:'<,'>` in the command line?
When I press : from visual mode, the command line is pre-populated with :'<,'>. It seems to affect how my substitutions work.
What do the characters mean and why are they inserted?
How does :'&...
0
votes
0
answers
560
views
Mouse navigation not working in VIM
I started using VIM today and I found out that we could use the mouse pointer to go to a line in vim using set mouse=a
But unfortunately, it is not working
here is the config file
https://pastebin.com/...
0
votes
1
answer
123
views
Dump output with command line in vim with placeholder
I use
:enew|pu=execute('scriptnames')
for dumping output into a buffer.
How do I write a mapping with this command line?
For example, I press <F6> and it auto write the command line and jump to ...
2
votes
1
answer
172
views
How to move marked line to current location
Say I put a mark down somewhere with ma. Then I jump somewhere else, GG3k. I want to move what's at my mark to the current line.
I could have just dd'd it if I'd had some forethought, but is it ...
3
votes
1
answer
374
views
Using Quickfix list, how to add a line/string to a certain line number of each file
Scenario: I've got 4 files in my Quickfix list and I want to add a new line, "status": "not started", onto line 5 of each of them.
I tried this:
cfdo norm 5GO"status": &...
0
votes
1
answer
251
views
Make 'cabbrev' work from command-line but not search prompt?
I am using NeoVim, and I automatically define an abbreviation for the string W every time the commandline mode starts.
However, it seems that commandline mode includes the search modes as well.
I do ...
2
votes
1
answer
238
views
Delete from cursor position until end of line in command-line mode
I am trying to emulate readline keybindings in insert and command-line modes (for example, <C-u> for deleting from cursor position to beginning of the line, or <C-w> to delete previous ...
1
vote
1
answer
408
views
Why does this vim command fail?
I'm trying to process large error logs and part of that is filtering out lines I don't need to see. Here's what I'm running in vim:
:g/.*rsync: stat.*/d | %s/\(.*mkstemp "\)\(.* \/\)\(.*$\)/\2/ | ...
1
vote
1
answer
182
views
Cannot string together multiple “-c” options using vim from the terminal
I execute a set of handy commands I need to do often on a standard type of file using the -c (or equivalently, the +) option from command line using vim. However, after an update to the remote system'...
0
votes
1
answer
245
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 ...
1
vote
1
answer
29
views
In command-line mode, how to avoid delete key erasing last character?
On command-line mode, Delete key erases next character, but if cursor is at end of line, it acts as Backspace, erasing previous character. Can I disabled that?
0
votes
2
answers
67
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 ...
4
votes
1
answer
1k
views
Can the command-line be edited/navigated using Vim commands?
How can I edit the text of a Vim command I've started typing out in the Vim command line?
Example:
If I type out a long search and replace command and realized I made a mistake. Now I want to move ...
1
vote
2
answers
166
views
Can I navigate backwards by word (not WORD) in command-line mode?
If I'm in command-line mode in vim, and I have the current command line entered (cursor position shown with |):
:somecommand somefilename.txt|
I'd like to navigate backwards so that the cursor is ...
1
vote
1
answer
565
views
How to get current line string without visual selection?
I'm usually working with a file list for sorting/deleting/etc files, and I like to sometimes run arbitrary command on those files (which have either a full path or already present in current directory)...
3
votes
1
answer
45
views
Curious behavior of :%normal g_lD (remove trailing spaces in file)
This is a noob attempt of mine, to remove trailing spaces in a file. The first attempt is:
:%normal g_lD
It worked, and I was happy. Then I tried it on a single line where there was no trailing ...
0
votes
0
answers
37
views
JavaScript equivalent of :perldo?
Is there a JavaScript equivalent of :perldo that allows writing one-liners that perform inline replacement of the file (or file lines) based on small, ad hoc JavaScript programs?
For example, this ...
2
votes
1
answer
358
views
Passing arguments function with --argument or -a format
Is it possible to pass arguments to Vimscript functions with the --argument or -a format, similar to arguments in the command line?
I am writing a command that submits a job in a remote machine. I ...
0
votes
0
answers
28
views
How to use `<count>` and `-count` to make command repeatable?
I am trying to use <count> and -count to make a command repeatable. This is the command I have right now:
command! -count=1 Hello :d <count>.
But I got this error instead when I run :...
1
vote
2
answers
293
views
How to call a plugin in a mapping?
I'm doing a project-wise refactor and I want to change variable names from camelCase to snake_case. I have YCM and vim-abolish installed. Let's say I have the following source file:
dueDate = ...
...
4
votes
3
answers
124
views
How to recover colon command removed by <C-U>?
In terminal, the command of the line of the input prompt can be cleared with <C-U>, and is recoverable with <C-Y>.
In vim, the colon command can be cleared with <C-U>, but it is not ...
2
votes
1
answer
168
views
How do I center in search and replace?
Everytime I do this:
:%s/```sh/```ctags/gc
I end up with hidden code blocks at the bottom of the screen that I can't see. I tried 'zz' but it does not work. I did read this and this but that's for ...