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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
28 views

Printing (file) information at the bottom line

I'd like to print some file information on vim's bottom line upon pressing a keyboard shortcut, sort of like Ctrl+G but with different info (modification timestamp). How can I output there? My current ...
Petr Skocik's user avatar
0 votes
0 answers
25 views

How to get/print all max-nested non-empty subdirs starting from some path(dir)?

How to get/print all max-nested non-empty subdirs starting from path(dir)? I found a random option to do this on Linux (bash): find ~/.config/nvim -type f | sed 's%/[^/]*$%%' | sort -u But I'm ...
cuc's user avatar
  • 1
0 votes
1 answer
56 views

How to open the last modified file at startup?

As every user in this community understands, launching Vim using the command line without using any arguments or flags will edit a blank buffer with the :intro screen. Some distributions and utilities ...
KhodeNima's user avatar
  • 131
3 votes
1 answer
69 views

How can I rename the current buffer to the current time?

I have tried :file strftime("%H%M") But this sets it to literally "strftime("%H%M")". My motivation for this is that I have a mapping for :term cmake and I end up with a ...
KangarooChief's user avatar
1 vote
0 answers
27 views

How can I handle whitespace of the path with nvim_buf_get_name?

I am using Neovim and I use this code to get the full path of the current file. local currnetPath=vim.api.nvim_buf_get_name(0) I want to use this variable for opening the current HTML file, so I need ...
mohamadi_arch's user avatar
2 votes
2 answers
113 views

Can't stop the global command using subcommand :substitute (:s) with the check flag (c)

I'm trying to use the global command :g with :substitute to find and replace some string and also with check. So the command like: g/\d/s/.*//gc but the check behavior is not same as in :s I can't ...
M_Sea's user avatar
  • 157
5 votes
2 answers
195 views

Autocomplete ^X^F mode in another directory

I notice when I launch Vim, the ^X^F completion works in the current directory I launch Vim in, not where the current file is. For example, if I use vim /path/to/foo/file.txt instead of vim file.txt, ...
mrjpaxton's user avatar
1 vote
1 answer
81 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, ...
paradroid's user avatar
  • 367
2 votes
1 answer
105 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 ...
john-jones's user avatar
-2 votes
1 answer
59 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). ...
Barzi2001's user avatar
  • 498
1 vote
1 answer
89 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 ...
M_Sea's user avatar
  • 157
1 vote
1 answer
56 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 ...
M_Sea's user avatar
  • 157
1 vote
1 answer
145 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 ...
M_Sea's user avatar
  • 157
0 votes
1 answer
23 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 '\...
gjherbiet's user avatar
1 vote
1 answer
95 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.
ranemirusG's user avatar
2 votes
1 answer
251 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(&...
hobo-mts's user avatar
  • 123
0 votes
1 answer
72 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 ...
Bog's user avatar
  • 457
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/ #...
l00p's user avatar
  • 253
2 votes
2 answers
791 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, ...
Marcus Müller's user avatar
1 vote
1 answer
78 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 ...
minseong's user avatar
  • 2,291
0 votes
2 answers
99 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/...
Vladyslav Rehan's user avatar
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 ...
Anton Wessel's user avatar
1 vote
1 answer
31 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 ...
mkrieger1's user avatar
  • 135
1 vote
1 answer
89 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 ...
Keith Thompson's user avatar
0 votes
1 answer
114 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 ...
serii 's user avatar
  • 77
1 vote
0 answers
396 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 ...
baxx's user avatar
  • 1,025
1 vote
2 answers
48 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. ...
Karolis Koncevičius's user avatar
0 votes
1 answer
473 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 ...
NeoZoom.lua's user avatar
  • 1,392
1 vote
1 answer
135 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/...
Lai32290's user avatar
  • 275
1 vote
2 answers
131 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. ...
mcint's user avatar
  • 113
1 vote
1 answer
122 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" '...
gmtek's user avatar
  • 145
1 vote
1 answer
46 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 ...
Abhilash's user avatar
  • 113
0 votes
1 answer
61 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 ...
Rob Bednark's user avatar
0 votes
1 answer
71 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 ...
Futarimiti's user avatar
0 votes
1 answer
64 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 ...
Supragy Mishra's user avatar
1 vote
1 answer
672 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 ...
Quappas's user avatar
  • 63
1 vote
2 answers
222 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 ...
minseong's user avatar
  • 2,291
1 vote
4 answers
56 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:?
Dominik Teiml's user avatar
0 votes
1 answer
55 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 ...
floupinette's user avatar
1 vote
0 answers
58 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 ++<...
rampion's user avatar
  • 201
1 vote
2 answers
110 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 ...
Tryer's user avatar
  • 247
1 vote
1 answer
29 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 ...
Anton Wessel's user avatar
1 vote
1 answer
105 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 ...
Bog's user avatar
  • 457
0 votes
1 answer
42 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)...
ban_javascript's user avatar
0 votes
2 answers
386 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 ...
Dominik Teiml's user avatar
3 votes
2 answers
141 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 ...
chiborg's user avatar
  • 130
1 vote
0 answers
38 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 ...
CIsForCookies's user avatar
1 vote
1 answer
33 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 /...
Enlico's user avatar
  • 2,194
1 vote
0 answers
42 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 ...
Jay-Pi's user avatar
  • 123
0 votes
1 answer
34 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 ...
Petr Skocik's user avatar

1
2 3 4 5
10