Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

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
3 votes
2 answers
329 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 ...
user avatar
0 votes
1 answer
27 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 ...
user avatar
1 vote
1 answer
30 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 ...
user avatar
  • 111
1 vote
1 answer
32 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 ...
user avatar
  • 375
0 votes
2 answers
15 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 ...
user avatar
  • 25
0 votes
0 answers
26 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. ...
user avatar
  • 165
0 votes
0 answers
11 views

Is there an hightlight group for the command line?

I'm referring to he line where an ex command is entered, right after I press : from normal mode. Just to give an example, let's say I want the background of the ex line to be permanently red.
user avatar
  • 1,572
-1 votes
1 answer
48 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 ...
user avatar
1 vote
1 answer
18 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?
user avatar
  • 153
0 votes
0 answers
15 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 ...
user avatar
1 vote
1 answer
38 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 ...
user avatar
  • 13
5 votes
1 answer
174 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 ...
user avatar
  • 399
3 votes
1 answer
54 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 +&...
user avatar
  • 399
3 votes
4 answers
195 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 ...
user avatar
3 votes
1 answer
92 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 ...
user avatar
  • 111
3 votes
1 answer
84 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 ~/....
user avatar
  • 33
1 vote
1 answer
30 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 ...
user avatar
  • 211
1 vote
2 answers
146 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 ...
user avatar
  • 1,237
0 votes
1 answer
47 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 ...
user avatar
  • 111
0 votes
1 answer
30 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 ...
user avatar
0 votes
0 answers
14 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 ...
user avatar
4 votes
2 answers
729 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 ...
user avatar
  • 731
0 votes
1 answer
29 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 ...
user avatar
1 vote
1 answer
58 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 :'&...
user avatar
0 votes
0 answers
62 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/...
user avatar
0 votes
1 answer
35 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 ...
user avatar
2 votes
1 answer
68 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 ...
user avatar
  • 199
2 votes
1 answer
84 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": &...
user avatar
  • 197
0 votes
1 answer
76 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 ...
user avatar
  • 121
1 vote
1 answer
57 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 ...
user avatar
  • 255
1 vote
1 answer
237 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/ | ...
user avatar
  • 199
1 vote
1 answer
103 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'...
user avatar
  • 13
0 votes
1 answer
73 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 ...
user avatar
  • 103
1 vote
1 answer
24 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?
user avatar
0 votes
2 answers
51 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 ...
user avatar
  • 173
1 vote
1 answer
509 views

VI mode when using colon (:)

I was wondering how can I enable VI normal mode when typing a colon (:) cmd in VIM or NeoVIM. For example: If I type a long search and replace cmd and realized I made a mistake now I want to move back ...
user avatar
  • 13
1 vote
2 answers
61 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 ...
user avatar
1 vote
1 answer
57 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)...
user avatar
3 votes
1 answer
44 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 ...
user avatar
0 votes
0 answers
32 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 ...
user avatar
  • 101
2 votes
1 answer
143 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 ...
user avatar
  • 255
0 votes
0 answers
25 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 :...
user avatar
1 vote
2 answers
107 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 = ... ...
user avatar
  • 113
3 votes
3 answers
78 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 ...
user avatar
2 votes
1 answer
83 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 ...
user avatar
  • 223
2 votes
1 answer
236 views

Why Vim is slow when I execute vim commands without a terminal?

I want to edit files by executing Vim commands from inside node.js as the following: const child_process = require("child_process"); child_process.execSync(`time vim /home/user/file -c ':%s/^...
user avatar
  • 375
1 vote
2 answers
94 views

How to prevent cnoremap taking effect for "/" searching?

I have created the following mapping for Ex mode to prevent having to enter :FZF capitalized to invoke FZF: cnoremap fzf FZF The problem is that this key mapping also affects "/" searching, ...
user avatar
  • 995
0 votes
1 answer
51 views

Why does the cursor end up on the wrong line when <Esc><Esc> is mapped to something?

In vim --clean, I insert these lines: One Two Three Four Five Six Then I do: :set mouse=a :nnoremap <Esc><Esc> <Nop> (From my observations, the mapping could be to anything. :...
user avatar
  • 801
0 votes
0 answers
29 views

How do I disable messages like "written" and "2 fewer lines"?

How do I disable these messages. In the messages I always see: Messages maintainer: Bram Moolenaar <Bram@vim.org> 2 fewer lines; before #526 7 seconds ago "somefile" 190L 6771B written
user avatar
  • 223
0 votes
0 answers
200 views

Map left command key to left control key in terminal only?

I've asked this question over on AskDifferent without any luck. I'm using neovim to edit code and am needing to create a mapping to bind to <cmd-w> to <C-w>. How would I go about this on ...
user avatar
  • 101

1
2 3 4 5
9