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
1answer
12 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 ...
0
votes
1answer
49 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 ...
0
votes
1answer
23 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 ...
12
votes
2answers
686 views

Can I search through 'oldfiles' with a specific name or extension?

I use the oldfiles and browse oldfiles commands all the time. I find them extremely useful, because it's easier to hit my leader mapping, scan through the files really quickly, and hit q<number>...
1
vote
1answer
67 views

Different word boundaries in command mode

I very commonly use CTRL-W to adjust a previous path in the command line, like I'll bring up the directory of the current file or perhaps a previous :e ... command from history that's close, and use ...
2
votes
3answers
602 views

Is there a setting that hides the last colon-command entered?

Is there a setting I could add to my vimrc file that would hide the last entered colon-command that stays visible on the bottom of the screen after I hit enter? For example, if I type ":3" to go to ...
0
votes
0answers
13 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 ...
0
votes
1answer
26 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 ...
0
votes
1answer
49 views

Changing cpoptions only work in commandline

So i tried to change the setting from cpoptions, so i did: set cpoptions=aABceF on the commandline, where s for the star is missing (on purpose) and it seems to work fine but only if i do it in the ...
7
votes
1answer
612 views

Switching arrow key mappings for wildmenu tab completion

When wanting to edit another file, I'm a big fan of typing :e then tab (or a few characters before) to see the wildmenu pop up. Problem is that the way it works, arrows keys up and down go 'down' ...
2
votes
2answers
298 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 ...
3
votes
3answers
72 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 ...
1
vote
1answer
50 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
0answers
18 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
1answer
27 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 ...
102
votes
7answers
124k views

How can I easily move a line?

What is the command (or shortcut) to move a line up or down in vim? My current workflow is to yank (copy) the line and than delete that line and than to put (paste) that line.
2
votes
1answer
63 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 ...
1
vote
1answer
202 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 ...
2
votes
1answer
41 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": &...
1
vote
1answer
46 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
1answer
206 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
1answer
82 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
1answer
46 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
1answer
22 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
2answers
45 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 ...
3
votes
1answer
43 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 ...
1
vote
2answers
47 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 ...
27
votes
6answers
12k views

Easiest way to switch git branches

Right now I'm using fugitive to manage almost everything git related, but I can't find a good workflow to quickly visualize and switch between available branches. I can do :Git checkout <branch-...
1
vote
1answer
15 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)...
10
votes
3answers
654 views

How to output highlighted source code into a file to use outside vim

At my workplace, I want to do a presentation of a custom language I've developed for solving some problems we had. For easier development, I created my own vim syntax file for this particular language....
0
votes
0answers
31 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
1answer
69 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 ...
20
votes
6answers
12k views

How to go to previous open buffer from Vim command line?

I am trying to write a Vim function which should make the window go to the previous open buffer. How can I do it from the command line? My first idea was to find out some CTRL-O command line ...
0
votes
0answers
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 :...
1
vote
2answers
67 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 = ... ...
2
votes
1answer
155 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/^...
2
votes
1answer
63 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 ...
1
vote
2answers
71 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, ...
0
votes
0answers
22 views

How to read the starting/ending line number of my visual selection?

So what I would like to achieve is when I selected a block of texts using shift-v, is it possible to read the starting and ending lines' line number within command mode? (Something like we could read ...
0
votes
1answer
46 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. :...
0
votes
1answer
44 views

How to pass argument to a ex command after chaining it with <bar>?

I'm trying to make my life easier with vim fugitive and ex command line, by creating an abbreviation to a frequent task, which is switching to develop, pulling it and creating new branch. That's my ...
0
votes
0answers
24 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
0
votes
0answers
117 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 ...
0
votes
1answer
58 views

Open vim with vsp and tabs on startup

I want the following configuration: Tab1: file 1 || file 2 Tab2: file 1 || file 3 I can open vsp with vim using vim -O file1 file2 I can open tabs with vim using vim -p file1 file2 Can I combine the ...
1
vote
2answers
115 views

Copy to clipboard or save to file substitution command

I'm trying to answer a vim question in U&L, which involves a very complex and long regex substitution. I would like to copy to clipboard the command, or save it in a file, so I don't have to make ...
1
vote
2answers
67 views

Is there any way of copying a macro inside a register to a different register?

I've discovered I can execute vim macros from the command line using the following command: vim myfile -c "argdo norm @aZZ" This command executed from the command line will execute a macro ...
0
votes
1answer
68 views

Intercepting & modifying commands

Is it possible to intercept incoming user commands? For example, if the user executes :echo 'hello', then I would like to compare the string and the command, and change it to execute :echoerr 'hello' ...
-1
votes
1answer
43 views

How to pass custom arguments to the shell invoked by :terminal?

I would like to specify the startup command to run on the :terminal shell. E.g. bash -c ls. The shell can be specified with set shell=bash, but how to specify the arguments? In another use case, I ...
6
votes
5answers
24k views

How do I copy and paste between two vim instances - shared clipboard?

I use gnu screen and I run vim file1.txt and vim file2.txt in two windows. How can I copy part of the text from file1.txt and paste it to file2.txt without using temporary files or opening two files ...
0
votes
0answers
26 views

How to automatically show suggestions while typing in command line?

Is there any inbuilt switch to enable this? Another approach is using :cnoremap <on text change trigger autocomplete (<C-Z>)> but :cnoremap doesn't have enough info for me to get started. ...

1
2 3 4 5
8