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
26 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
29 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 ...
0
votes
1answer
15 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
1answer
19 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 ...
0
votes
1answer
43 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
56 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 ...
0
votes
1answer
19 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
26 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
106 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
49 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
40 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
17 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
144 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
54 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
85 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
27 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
34 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
46 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
34 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
34 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
87 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
21 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
100 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
16 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
63 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
44 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
294 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
48 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
37 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
29 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 ...
1
vote
2answers
220 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
96 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
50 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
33 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
29 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
49 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
21 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
63 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
83 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
20 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
31 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
39 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
469 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
29 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
42 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
109 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
549 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
42 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 ...

1
2 3 4 5
8