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
-1
votes
0
answers
34
views
How do I align columns in a CSV file?
I'm using this csv plugin to view my csv file. I use command :67,68ArrangeColumn to align my file, but it does not align well.
The manual mentions a command like :[range]ArrangeColumn[!] [<Row>]...
1
vote
1
answer
63
views
How can I echo a variable and redirect it to a file, register or the clipboard?
I'm using a colour scheme which makes some text unreadable in the vim terminal. Therefore I want to alter g:terminal_ansi_colors.
:echo g:terminal_ansi_colors
This shows me the value of the variable, ...
2
votes
1
answer
102
views
Vim command-line just say 'saved' upon save
In Vim, at the the bottom.
There is statusline.
And below it there is, I think, the command line.
When I press save, this command line, displays something like:
"index" 160 lines, 2097 ...
-2
votes
1
answer
55
views
MacVim: how to prevent :[range]!say to remove text? [duplicate]
I am writing some prose and I find very useful to hear what I wrote from an external voice. I found the command say which I guess is only available on MacOsX (perhaps other OS have some equivalent).
...
1
vote
1
answer
79
views
Put the mutiple search or replace results into different split window
Dsecription
I am using :g/regex to do global search and it always list --More-- So I need to click Enter or Space to see the full results, it takes too much time.
I found one way to achieve my goal ...
1
vote
1
answer
49
views
How to save the files when global replace completed in one command line
I have so many huge size of files and always need to do search and replacement
so I map the command as nnoremap aa :let i=1 \| g/regexp/ s/^/\=printf("%1d. ",i)/g \|let i =i+1\|:w! 1.txt
...
1
vote
1
answer
128
views
Vim command-line mode encoding error when using global search in autocmd
Update
Found the issue due to souce the menu this cause encoding=utf-8 and fileencoding=cp936 in _vimrc but in txt files it shows encoding=utf-8 fileencoding=utf-8
The way to fix is reset fenc=utf-8 ...
0
votes
1
answer
19
views
Convert sequence of external commands to a Vim custom command
To reformat Markdown tables, I use the following sequence of external commands (e.g. after visually selecting my table lines):
:<,>! sed 's/[[:space:]]\{1,\}\|/\#\|/g'
:<,>! column -t -s '\...
1
vote
1
answer
50
views
List Vim arguments options
Is there a way to list the command line arguments showed by vim -h or vim --help from within Vim?
Besides :r!vim -h which seems to be a workaround to achieve this.
2
votes
1
answer
231
views
How to obtain Vim's command line?
I want to see what shell command line were used to start Vim. For example, I used command
vim -S Session.vim
argv() and argc() don't show switches and it's parameters.
Command
:echo tr(join(readfile(&...
0
votes
1
answer
60
views
NeoVim - Interact with the thing that pop ups when you type in a command
Questions
How can I type something in there?
What even is the name of this thing?
Problem
If you type in for example
:!echo 'Hello World'
This kinda terminal thing pops up
I want to interact with ...
0
votes
4
answers
53
views
How to repeat substitution on the consequent lines?
Say I want to fix a mistake in the following php code:
$line1 = intval($line[$1]);
$line2 = intval($line[$2]);
$line3 = intval($line[$3]);
and do substitution on the first line with:
:s/\$\(\d\)/\1/
#...
2
votes
2
answers
604
views
Applying commands to buffer from Neovim command line with complex plugin managers
I come from the following problem:
I'm using Neovim (0.8.3) with AstroNvim as plugin/everything-manager.
I've successfully set up multiple LSP servers from within that, which use the right servers, ...
1
vote
1
answer
70
views
Map to for loop
How can I make a mapping that includes a for-loop?
xnoremap <leader>y :for i in [1, 2, 3, 4] | echo i | endfor
errors E121: Undefined variable: i
and
xnoremap <leader>y :for line in ...
0
votes
2
answers
71
views
How to open files from terminal in desired pattern (tabs, vertical and horizontal splits on desired files)
So, I wrote next bash script:
#!/bin/bash
if [ "$#" -gt 1 ]; then
path=$1
else
path=$(cat subject.txt | tr -d '\n')
fi
nvim -p 1 "setup/$path/body.tex" -p 1 preamble/...
0
votes
0
answers
12
views
Why recording typed characters by "qa" into reg a has different behavior for typed <M-Z> vs. <M-z>?
Case 1:
In Excmd line I give
qa to begin recording.
I type \Alt Z
(upper case Z)
error message:
E11: Invalid in command-line window:\<blank\>:q<CR> closes the window
I give q for end ...
1
vote
1
answer
30
views
Why does the command ":g x" show all lines matching the last search?
I accidentally stumbled on a solution for a problem I had: I wanted to get an overview over all occurrances of the word under the cursor, after I used # to find them individually.
For some reason I ...
1
vote
1
answer
81
views
Multiple "1 line >ed" messages
When I perform multiple shift :> operations, vim shows me a notification for each line that's shifted. Is there a way to avoid these multiple notifications?
For example, I'm currently editing a ...
0
votes
1
answer
80
views
How in Vim to visual select lines from command mode?
In vim we can move, copy or delete lines from command line
Copy from 12 to 14 code and paste here:
:12,14t.
Move code from lines 14 - 16 to 20:
:14,16m20
But how to make visual selection from line ...
1
vote
0
answers
348
views
How to create a (lua) function to run a particular command in the shell on the currently open file, within neovim
If I'm working on a file I might want to run a particular command which uses the file within the shell.
Example - running black (python formatter) on an open file.
Ideally I'd like to be able to enter ...
1
vote
2
answers
46
views
Make ":w" command throw an error on filenames starting with a colon ":"
From time to time I accidentally create files with names like ":w" or ":q". This happens when instead of writing :wq I type :w:q and sometimes, for some reason, even :w:w or :w :w. ...
0
votes
1
answer
327
views
How to get the total lines of a file before it's loaded into a buffer?
As title.
My target is to disable a plugin before it is applied to a buffer that will be loaded with the content of a file.
I can get the file name before it is loaded.
The file to be opened is ...
1
vote
1
answer
109
views
How to add action before "gf"?
I'm using NVIM 0.8.2
I'd like to replace the default gf command (goto file under the cursor) to do something before and after the action.
For example:
echo "do something before"
goto file/...
1
vote
2
answers
110
views
Ignore/map case in command prompt :edit fileName
I would like to use case-ignoring completion in the file arguments I pass to (n)vim in the internal command prompt:
For example, :edit case<tab> should suggest caselower.txt and Caseupper.txt.
...
1
vote
1
answer
99
views
ci" or ci' doesn't work in vim key bindings for zsh command line editing [closed]
I have vim keybindings enabled for command line editing by bindkey -v. When I am trying to use ci", ci', di" or di' it doesn't work.
For example: If I have a command echo "hello" '...
0
votes
0
answers
9
views
Why Neovim has different color than Vim [duplicate]
I just installed Neovim and when I execute for example this command
nnoremap <leader>gd :!clear<CR>:!git diff<CR>
I'm getting this output for Neovim:
and this output for Vim:
How ...
1
vote
1
answer
38
views
@: does not work to repeat the :qa command
I open the diff files between 2 code revisions using git difftool. I can use :qa to close the current diff and go to the next one. Rather than pressing :qa repeatedly, I would like to use @:, but I ...
0
votes
1
answer
54
views
How do I use variables with the delete command? (i.e., how to expand/reference variables for command arguments?)
I'm using variables for line numbers, and I want to delete a range of lines using these variables. How do I do that?
let x = 5
let y = 20
" I want to delete the range of lines from x ...
0
votes
1
answer
69
views
Stop flushing the last command when hitting enter
Suppose I wrote this command:
command! -nargs=1 E echo ' -> <args>'
and when user feeds an argument,
:E abc
I intend to see the following effect as they hit Enter:
:E abc -> abc
Of ...
0
votes
1
answer
60
views
NeoVim runs part of mapping while starting
I am using a Raspberry Pi for learning C. I use NeoVim and Mingw-GCC on the Pi over SSH.
Building is done with a custom script named build. Initial builds were done by calling ./build from the command ...
1
vote
1
answer
461
views
In neovim, can I use Enter to accept a command completion instead of executing the command?
Using neovim (v0.8.1 on Fedora 37) with its default configuration in my home directory, when I type :e <tab> the completion menu pops up, the first entry (here Desktop) is highlighted and the ...
0
votes
0
answers
160
views
How to tab autocomplete in command-line and search using CoC?
How can I have autocompletion in the colon command-line and during / search just as autocomplete works in my buffers?
1
vote
2
answers
178
views
Vim fill command line with currently highlighted word in substitution
I have incsearch on, so when I type :s/thingS it will highlight the thingS part of thingSoFar in the below text
see, this thing is the thingSoFar thing
When I am typing that command line with my ...
1
vote
4
answers
52
views
Programatically enter Command line window
I have bind q to :qa that hides q:.
Is there a command to enter the Command Line Window that is not q:?
How to access the Command Line Window without typing: q:?
0
votes
1
answer
43
views
vert command works but v doesn't
To open a buffer in a vertical split, you can use the word "vert".
For example :
:vert term #it opens a terminal in a vertical split
:vert sb1 #it opens the buffer 1 in a vertical split
...
1
vote
0
answers
56
views
Completion for ++flags in command-line mode
Is there any way to turn on tab completion for the various ++[flag] flags that some commands take?
For example, :e ++ff=unix whatever.txt overrides fileformat to unix for whatever.txt, but :e ++<...
1
vote
2
answers
95
views
Shorter way to call specific plugin function
In the middle of a Vim session, I need to call a particular plugin's function via:
:call UltiSnips#RefreshSnippets()
When from normal mode I type :call UltiS<Tab>, it auto-expands to ...
1
vote
1
answer
28
views
vim in FCEDIT=...vim... does not work with more than one option
When I write in a bash commamd line
vim -u /root/.vimrc -c "set textwidth=0"
this works as expected.
When using same in FCEDIT= it does not work:
FCEDIT='vim -u /root/.vimrc -c "set ...
1
vote
1
answer
97
views
Neovim E276 - Command works in Vim but Not in Neovim
Question
Thanks to the comment from @martin-tournoij on one of my other questions. He gave me this piece of code:
:%s/0x[a-fA-F0-9]\+/\=submatch(0)->str2nr(16)/
which looks for every hex-number ...
0
votes
1
answer
38
views
How to prevent an extra newline from being appended to macros ending with a newline? [duplicate]
If I save a macro by typing:
:let @s='/{<C-v><C-m>'<Enter>
which looks like:
:let @s='/{^M'
the macro that is actually saved is /{^M^M,
with an extra linebreak (that I did not type)...
0
votes
2
answers
280
views
Normal mode command in Command-line mode
I'm in the process of mapping MacOS keybindings (Cmd/Alt + arrows/backspace/delete) to Vim commands, and the only thing remaining is to make the movements in normal mode (such as b or e) work in the ...
3
votes
2
answers
123
views
How can I reuse parts of the last command / history
I'm looking for a fast and efficient way to re-use the parameters of the last command in a new command. For example, in a Bash shell you can use the $1 placeholder to reuse the 1st argument of the ...
1
vote
0
answers
36
views
how to pass all open windows to command line in vim [closed]
I want to run clang-format on all open windows.
What I currently do, is:
for each open window:
:!clang-format --style=file -i %
I have 2 issues:
the clang-format runs in shell, so it doesn't ...
1
vote
1
answer
30
views
Why rhs of cnoremap (used as a rhs of another cnoremap) can be <c-s> but not <space>?
If you execute this
cnoremap <expr> <silent> <C-S> execute(':cnoremap <c-s> ctrl-s')
and then hit /Ctrl-sCtrl-sCtrl-sCtrl-s, you'll see the search command be populated by /...
1
vote
0
answers
38
views
How to to get commmand completions for selection from a keymap?
The idea is to have a keybinding, which executes a lua/vimscript function to paste yanked text into the command line and then have the command completion showing suggestions or directly get the ...
0
votes
1
answer
30
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 ...
4
votes
1
answer
103
views
How to get autocomplete for :set?
E.g. I am trying to change foldmethod to syntax:
:set foldmethod=s^I^I
When I press tab after typing s, I get ^I instead of auto-completing to syntax. Only possible options are manual,indent,expr,...
0
votes
0
answers
21
views
Entering command-line window from quickfix window opened by YCM results in inconsistent Vim state
I think I'm supposed to file a bug report, however I'm not sure if for Vim or for YCM, so I'm asking this question to better understand what is really happening.
YCM has the :YcmCompleter ...
0
votes
2
answers
348
views
How to remove 2 characters from the beginning of a string after using filename-modifiers?
How to remove 2 characters from the beginning of a string after using filename-modifiers?
So assume that I have a files that looks like this:
/home/drskoolie/projects/examples/ex40.c
/home/drskoolie/...
3
votes
2
answers
97
views
What is the pattern matched against for events CmdwinLeave and CmdwinEnter?
More in general I'm always in doubt about what's the meaning of the {aupat} argument of autocmd for a given {event}.
From :help :autocmd I read (my emphasis)
Add {cmd} to the list of commands that ...