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.
464
questions
2
votes
1
answer
731
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
2
answers
160
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
1
answer
55
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. :...
1
vote
0
answers
260
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 <[email protected]>
2 fewer lines; before #526 7 seconds ago
"somefile" 190L 6771B written
0
votes
0
answers
302
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
1
answer
187
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
2
answers
224
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 ...
3
votes
2
answers
310
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
1
answer
53
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
1
answer
102
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
vote
2
answers
41
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,...
3
votes
1
answer
210
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
1
answer
66
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
0
answers
33
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
vote
1
answer
257
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
3
answers
195
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
1
answer
25
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
1
answer
4k
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
1
answer
83
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
1
answer
65
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
1
answer
36
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
3
answers
1k
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
1
answer
438
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
2
answers
419
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
1
answer
76
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
1
answer
318
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
1
answer
141
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
1
answer
125
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
1
answer
129
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
1
answer
393
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
1
answer
108
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
1
answer
836
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
1
answer
226
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:...
5
votes
1
answer
88
views
Tweak command-line position and size [duplicate]
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:...
5
votes
1
answer
534
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
1
answer
65
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 ...
5
votes
1
answer
556
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
1
answer
115
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
1
answer
856
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
1
answer
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
2
answers
448
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
2
answers
115
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
1
answer
227
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
0
answers
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
1
answer
44
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
2
answers
2k
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 ...
11
votes
1
answer
397
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 ...
4
votes
0
answers
104
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
1
answer
85
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
1
answer
101
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 ...