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
1
vote
1answer
29 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 ...
1
vote
1answer
21 views

How to display a list of all folds?

How can I show a list of all folds? e.g., maybe a list something like: 1-3 12-18 13-16 where <start-line>-<end-line> are the starting and ending lines of the fold. Is there a command-line ...
0
votes
1answer
18 views

why does vim insert a range when we press a number before pressing colon to go to command line mode?

I was trying to make a mapping to run a command that takes a count, something like the following: nnoremap gb :execute('buffer ' . v:count)<CR> When I run the mapping, I see the following error:...
4
votes
0answers
22 views

Tweak command-line position and size

The command-line is obviously a very convenient tool in vim. However, especially when working with splits, it can feel uncomfortable to have to look back and forth between window and command-line (e.g:...
3
votes
1answer
59 views

Any ways to display lolcat output in Vim?

I known lolcat for a while now, and wondered if it was possible to display the text that it output, inside of Vim correctly. So i tried: :%! lolcat But while it update the buffer, the text doesn't ...
2
votes
1answer
20 views

Substitute: previous match with confirm

If I do a replace like this: :%s/May/June/gc afterward I keep hitting y or n as needed. But sometimes it hit n on accident and need to go back. I read that you can use N for this purpose, but it ...
4
votes
1answer
72 views

How can I write all named buffers?

I would like a command that saves every buffer that has a filename. :h :wall gives this: *:wa* *:wall* :wa[ll] Write all changed buffers. Buffers without a file ...
0
votes
1answer
15 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 ...
1
vote
1answer
50 views

How to perform an action on search matches?

How can I visually select all text highlighted by a search in order to run a command on it? And if it's possible, how can I capitalize the selection?
2
votes
1answer
42 views

text replace problem when target contains '&' symbol

I tried to replace if(cond1) with if(cond1&&cond2) in vim, so I typed the command :%s/\Vif(cond1)/if(cond1&&cond2)/g but the result is if(cond1if(cond1)if(cond1)cond2) and not if(...
5
votes
2answers
284 views

How to put partial command in command bar?

I am trying to do something like this, from a function: nmap <F5> :!python % Pressing F5 in this case causes the command :!python % to be left in the command line. This is preferred for me, ...
3
votes
2answers
43 views

How to pre-process command line arguments provided to vim?

I want to add support for various formats of filenename with linenumber for vim to understand. E.g. I get output from git grep <keyword> like this: first/foo.py:123: first/bar.py:333: second/foo....
1
vote
1answer
36 views

Why does this mapping require hitting enter?

I've written a "script" to highlight all lines that begin with n (for a todo list): syn region dash start=/^n/ end=/$/ oneline | highlight link dash String And mapped it to ; in my init.vim:...
0
votes
0answers
11 views

Opening multiple files both vertically and horizontally from the command line [duplicate]

I'm trying to open vim in a format like this, from the command line. |----------------| | | 2 | | |------| | 1 | 3 | | |------| | | 4 | |----------------|...
2
votes
1answer
27 views

Options from external commands in vim?

If I run from the vim terminal :! zathura foo.pdf It opens foo on top of the terminal and when I exit I go back to the vim file. If instead I try: :! zathura --fork foo.pdf The intended behaviour is ...
0
votes
2answers
61 views

Vim command to open zathura immediately after a latex compile?

I have the following line in my nvim configuration file: map <leader>c :w! \| !compiler <c-r>%<CR>\| !zathura $(echo %:r".pdf") && disown<CR><CR> The ...
9
votes
1answer
86 views

Why does `<Bar>` behave like `|` in the `:command` command in Vim?

Here is the list of experiments I performed that shows that <Bar> is treated as literal <Bar> in some commands but it is treated as | in the :command command. I am trying to understand why ...
3
votes
0answers
47 views

:tabonly does not close all unmodified tabs if there is a modified tab in the way

Create some test files, touch a b c d and open each in a tab, vim -p a b c d Modify file b. Go to tab c and issue :tabonly. Expected behavior: a and d tabs are closed. b is not closed because it is ...
1
vote
1answer
31 views

How would I make this into a keybinding?

When I want to find out what might be causing lag within vim, I use the following commands :profile start ~/profile.log | :profile func * | :profile file * <do actions that cause lag> :profile ...
1
vote
1answer
25 views

Shortcut to open a particular website

I'm using neovim on mac os, in case that information is of use. In the shell I have some aliases such as alias g='open HTTP://google.com For sites that I access regularly, I would like to be able to ...
0
votes
1answer
46 views

Delete N lines after cursor that contain a specific pattern

It is possible to delete all lines matching a pattern using :g/pattern/d. Using the following command, you can replace words matching a pattern, 20 lines after where the cursor currently is: :s/...
0
votes
1answer
20 views

Tab to view files in directly?

Is it possible to press tab or some other operator to view the available files in a given directory path? For example: For example, in the unix shell I can do something like [tab] to get: After ...
0
votes
2answers
60 views

Define a new ex command active only in specific filetype (C++)

I would like to define a new command for C++ files/buffers (ft=cpp). I shall explain the requirements through the example below. The newly defined command :stripdbg should strip the surrounding dbg() ...
2
votes
1answer
63 views

How to change the command line status message color and font?

I would like to change the color of part of the command line, the stuff that's echo'd from vim scripts. I know it can be different since when your search hits the bottom it prints a message in red ...
0
votes
0answers
19 views

Command (e.g. `g++`) does not point to the same binary when run from the terminal or from (neo)vim

I have NVIM v0.4.3 on macOS Mojave version 10.14.6 I have different version of g++ compilers on my machine and made the following alias in my .zshrc file: alias g++="/usr/local/bin/g++-9" ...
0
votes
1answer
29 views

Prevent commands from populating command-line history

I would like some commands to not be registered in the cmdline history. Is there a way to do this? I can't seem to find anything about it in the doc. The story: I accidentally deleted a file with :...
0
votes
1answer
36 views

How can I set a variable for a single Vim Ex command only?

I often set or modify a shell variable in Bash for the scope of a single command only: $ FOO=BAR <command> Is it possible to set or modify a variable in Vim for the scope of a single Ex ...
0
votes
2answers
412 views

How can I exit Bash from Vim?

Can Vim kill its parent process? I know a child could not kill a parent process in Linux, but how can I achieve :!exit in Vim? I would like to exit directly from Vim out of the terminal without semi-...
0
votes
1answer
26 views

prevent printing control-character in insert mode and command line

When in insert mode, if no mapping is associated to a sequence, Vim will print the character corresponding to the signal. For example, typing <c-b> will input ^b as a character. It is more ...
1
vote
1answer
38 views

Autocomplete on command-line search pattern returns strange symbols of <09> and ^I

Using Neovim v0.4.3 on a just recently upgraded Linux Mint 19.3. Problem Description: After the upgrade, when typing / followed by first characters of any word below the cursor, in the buffer, and ...
1
vote
1answer
87 views

How to paste command into vim command line easily

I am using latest available version of NeoVim v0.4.3 and latest Arch build with kernel 5.6.4-arch1-1. To paste onto the vim command line I am using : ctrl+r " to paste the " register Is there an ...
2
votes
3answers
398 views

How to run multiple commands in command line, & place 1 comma at the end of each line and join all the lines

I am using latest available version of NeoVim v0.4.3 and latest Arch build with kernel 5.6.4-arch1-1. I'm having a problem with the following command in the NeoVim command line: 1 ...
2
votes
1answer
36 views

Having current filename in the command line

Some time ago I completely got rid of the status line. Vertical space is a scarcity in the modern HD world. The only thing I missed from it is an ability to see what file I'm working with. So I'm ...
0
votes
3answers
37 views

How to go to the beginning of a command

If I am editing a command, for example: :set paste And my cursor is between the p and a: :set pa|ste I can go to the end of the command text by doing ctrl-e. However it doesn't seem like ctrl-a ...
2
votes
2answers
221 views

FZF showing error on preview

I have fuzzy file finder (FZF) set up and working: And when I do :History it also shows a preview of the file: I've been able to do a find with passing an "empty" preview to it: :FZF --preview 'cat'...
2
votes
0answers
28 views

Chaining user-defined commands [duplicate]

Assuming I have defined 2 commands in .vimrc MultipleEmptyLinesToOne RemoveExcessiveSpaces I can run them in command-line mode: :exec "'<,'>MultipleEmptyLinesToOne" | exec "'<,'>...
0
votes
1answer
65 views

g! vs v in vim command

Is there any difference between doing the following two commands: :1,19g!/let/d And: :1,19v/let/d Or is v an alias for g! ?
0
votes
1answer
22 views

How to always show a command

When I enter a search it shows me the input in the command bar, for example: However, when I enter in a command from the command history, for example clicking enter on line 50: It doesn't shown ...
1
vote
1answer
32 views

How to check whether a command is run with range or not?

For example, I have the following code command! -range Test call TestFunc() function! TestFunc() abort " if run with range " get selected content " else " get current word under the ...
1
vote
0answers
28 views

Why does Gvim treat ansi escape codes differently than Vim in python code?

The following python code uses ansi escape sequences to clear the terminal screen and change the text color to red. It then prints "Hello from Vim." print ('\033c\033[31m Hello from Vim.') In Vim I ...
3
votes
1answer
59 views

How do I run a shell command using the current selection as arguments?

An example: A visual selection of: echo -e "hello \bworld" followed by :w !bash prints: hello world How can I get the same result if my starting point is: hello \bworld More details: I ...
1
vote
1answer
35 views

Why does `.,.+[count]` appear in command box when typing [count+1] before :

For example if in normal mode 4: is pressed, in the command line there will be :.,.+3. What does this mean and what is it used for?
1
vote
1answer
117 views

Commands to write text to a buffer

I'm writing a plugin that often needs to write text to specific buffers. My current solution is to make the script execute normal commands that open a split with the buffer, write the text and then ...
1
vote
0answers
29 views

Why is the command line not like a mini buffer in normal mode? [closed]

When typing in the command line, and one wishes to make a correction, I am aware one can press ^f to bring up a cmdline mini buffer where one can use normal and insert mode. But this make me wonder, ...
1
vote
2answers
53 views

`a` append to buffer commands

Similar question, yet not duplicate of: How can I reload all buffers at once? If :wa writes all, would not :ea be expected to reload all? How could one script :ea to behave this way? What are the ...
4
votes
3answers
338 views

How do I use the contents of the buffer to save some typing/autocomplete on the command line?

When editing a buffer and initiating a search-and-replace, I use :s/oldword/newword/g Now the word 'oldword' will be in the buffer I am editing, and sometimes it is a long word. It would be helpful ...
2
votes
1answer
51 views

Difficulty with regular expressions

I'm trying to wrap my head around this line of code: :execute "normal! gg/for .\\+ in .\\+:\<cr>" I understand that it's executing in normal mode (ignoring remappings) the command that starts ...
3
votes
1answer
228 views

Problem remapping key bindings in command line mode

To make it easier to edit my ~/.vimrc file, I set up the following: :cnoremap ev :<C-u>vsplit $MYVIMRC<cr> So, to open ~/.vimrc in a split I just enter command mode and enter ev. However,...
1
vote
1answer
40 views

Are there comments in command-line mode?

Does VIM support comments in command-line mode? I have tried the most popular variants including .VIMRC comments but neither worked: :echo "hello" // echo usage :echo "hello" /* echo usage */ :echo "...
2
votes
1answer
165 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' ...

1
2 3 4 5
7