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
votes
1answer
36 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
494 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
132 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 ...
0
votes
2answers
54 views

How to insert a blank line above another line

I have these lines; Question1. Is this true? a. Yes b. No Question2. How is the weather a. Good b. Bad Question3. The sky is a. Dark b. Blue I wanted to change it to; Question1. Is this true? a. Yes ...
0
votes
1answer
22 views

Can I create a file and read in shell command output in one line?

I want to create a file and read in function declaration to be able to edit it further. e() { echo $FUNCNAME } vim FILE < <(declare -f e ) but that doesn't seem to work and the filename expands ...
2
votes
1answer
227 views

Disabling relativenumber in Command Mode

I have au InsertEnter * set norelativenumber au InsertLeave * set relativenumber So that I have relativenumber in normal mode but not insert mode. I want to extend this to command mode. I tried ...
2
votes
1answer
85 views

Print bound autocmds to a file

I would like to print all of my current autocmds to a file so that I can grep through and do further analysis. From within vim, the list of autocmds can be found with :autocmd, but this prints to a ...
2
votes
1answer
97 views

Define w< command

I often type :w< instead of :wq, so I wanted to redefine it (in order to avoid the creation of a < file) as following: command! w< w But it seems to not be allowed: Error detected while ...
-1
votes
1answer
48 views

Remove right text (line numbers , ALL) in command line

I am using neovim and i want to remove the indicated text (0,0-1 ALL).
0
votes
1answer
60 views

Disable command but allow to write in command mode

I have fzf.vim installed, and therefore I have a :W command. I prefer working with buffers, so I save a lot with :w. However, accidentally using a capital W invokes :W which annoys me. I tried ...
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
1answer
263 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
90 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
30 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
211 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
24 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
264 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
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 ...
1
vote
1answer
181 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
49 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
311 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
55 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
45 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
31 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
914 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
171 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
71 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
51 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
45 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
89 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
29 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
73 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() ...
4
votes
1answer
286 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
26 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
74 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
71 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
739 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
71 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
121 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
584 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
1k 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
63 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
209 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
1k 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
31 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
574 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
35 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 ...
2
votes
1answer
153 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
2
3 4 5
8