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
0answers
12 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 ...
2
votes
2answers
236 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
1answer
25 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
1answer
49 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
13 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
25 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
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 ...
2
votes
1answer
34 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
1answer
39 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 ...
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
197 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
74 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
44 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
21 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
43 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 ...
1
vote
1answer
167 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 ...
1
vote
2answers
46 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
1answer
11 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
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 ...
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
60 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
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
61 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 = ... ...
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 ...
2
votes
1answer
61 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 ...
2
votes
1answer
148 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/^...
1
vote
2answers
66 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
43 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
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
97 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
111 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
65 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
43 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
1answer
67 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' ...
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
vote
2answers
35 views

How to remove periods within visual selections in a cmd composition?

I'd like to remove the period between the 6th comma and the 9th comma for the multiple lines of the following texts. Change from: 4,Afghanistan,2,Medium,1951,1951.5,4134.756,3705.395,7840.151,12.009 4,...
2
votes
1answer
69 views

Use feedkeys then do command

I want to write a mapping that does feedkeys(":cd " . getcwd()), waits for me to edit the directory and then press enter, and then runs a command such as :Rg from the fzf plugin. I tried ...
0
votes
1answer
29 views

Can you open two files from command line and go to end?

On Windows I'm trying to start editing two files and check or edit the end of both files. I didn't manage to jump to the end of both files. It only works for the first file: gvim -O "+norm Go&...
0
votes
0answers
32 views

Effect of changing directories in a vim command [duplicate]

When executing a vim command, such as the following: :w!<CR>:!cd %:p:h What is the effect after the command is finished? Is the new cwd the directory that I've cd'ed into? Or does that only ...
-1
votes
1answer
41 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 ...
1
vote
3answers
100 views

Is it possible for a command or function to end in command line mode?

It's possible to configure a mapping such that command line mode is active after the key press. For example, with a mapping :map H :help , pressing H results in command line mode being entered with :...
1
vote
1answer
21 views

Simple way to store additionnal config in the scope of the actual directory [duplicate]

I have my .vimrc with some global/local configurations, but when I am working in a project, I know that I often create configs (settings, mapping, command, abbreviations, etc.) specifically for this ...
1
vote
1answer
694 views

How can I run awk script with in vim?

We know that we can run commands from vim using :!command <args>. For example: :%!awk '{ print $2,$1,$3 }' FS=',' OFS=',' :%!sort I am having trouble running an awk script within vim. I can run ...
4
votes
1answer
66 views

Why do some Ex commands not need a white space before a path argument?

For example, why does this work: edit/home/foo/bar.txt (I had to enter visual to see the changes) I was expecting a whitespace after edit, like: edit /home/foo/bar.txt I couldn't find a reference in ...
-1
votes
1answer
32 views

Delete word or whole line part after cursor in colon-command mode with keybinding

I would like my NeoVim to have Emacs-style keybindings in all "direct input" modes, in particular - Alt+d and Ctrl+k for forward word and line part deleting. I've done it for insert mode as ...
1
vote
1answer
30 views

How to escape the end of a filename in a :read command?

I want to insert a skeleton to .sh files without any plugins. Vim complains that it can't find the file ~/.vim/skeletons/sh<CR><ESC>l. How do I indicate that /sh is the end of the filename ...
1
vote
3answers
428 views

How do I make my own function to insert text in vim?

I have a folder of third party libraries called add-libraries and the location for this specific library is /home/yapjiahong/projects/cpp/add-libraries/plog/include. I want to write a function called ...
3
votes
1answer
115 views

add buffer to vim from the shell command line

I am currently trying to externally add a new buffer to a vim instance from the command line. That means I have already opened vim and I modify the files of interest to me. Then I want to go back to ...

1
2 3 4 5
8