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
1
vote
1
answer
2k
views
`vimdiff` nor `nvim -d` are working as an external diff tool for git
First line says output is not a terminal. The rest of the output looks like term codes aren't being processed.
I use st, with $TERM = st-256color. I just tried it on termite ($TERM = xterm-termite) ...
4
votes
2
answers
284
views
How do I change the ":" symbol in the minibuffer?
When you switch to command-line-mode, with :, you see a ":" symbol identifying that you're indeed in command line mode. Is there any way, other than modifying source code, I can change this symbol?
2
votes
2
answers
129
views
creating a ":KeepCursor" command
I'd like to make a command that works like this: :KeepCursor {cmd} will the given execute ex command string, then restore the cursor's position. A primary example is:
:KeepCursor normal! *
which ...
0
votes
1
answer
44
views
Running previous run command that was run in normal mode using colon
Recently I had to compile a latex file a few times, :!pdflatex filename.tex did the trick. But is there a way in normal mode to repeat commands like these which are in the recent history,but used ...
1
vote
1
answer
288
views
Why will my set langmap in my vimrc not actually make the changes in Vim on macOS?
My vimrc is as follows:
set langmap='q,\\,w,.e,pr,yt,fy,gu,ci,ro,lp,/[,=],aa,os,ed,uf,ig,dh,hj,tk,nl,s\\;,-',\\;z,qx,jc,kv,xb,bn,mm,w\\,,v.,z/,[-,]=,\"Q,<W,>E,PR,YT,FY,GU,CI,RO,LP,?{,+},AA,OS,...
2
votes
1
answer
29
views
':norm dtxdty' works different than '0dtxdty', what's happening?
On line ay, 0dtxdty deletes the a (as I would expect), but :norm dtxdty does nothing, norm! and exec don't change it.
I wanted to use it as part of a command to align as explained here, but to two ...
-1
votes
2
answers
120
views
How to output the result of a command like :scriptnames in a buffer [duplicate]
:scriptnames outputs a (not convenient) list with more at the bottom.
I'd like to have all the output in a buffer so i can search, edit ...
How do i do that?
0
votes
1
answer
290
views
May I have a Vim session report its "Mode" in its "Window Title"?
Clarification of the moving parts
First, let me clarify what I mean by "Window Title", and what I expect to achieve
On Windows OS, GUI programs will have three attributes: its Window Title texts, ...
1
vote
1
answer
656
views
Find and replace in XML file in vi
I have an .xml file which contains many times the following web beacon
<span lang="EN" class="multilang">ANY TEXT TOTO</span>
I would like to make a "Find&Replace": each web beacon ...
2
votes
1
answer
224
views
scroll while writing a substitution
how can I scroll or move around in the code while writing a search or command ?
I want to write a substitution :s/xxx/yyy but I forgot what yyy should be and I need to scroll a little bit to find it, ...
1
vote
1
answer
340
views
Opening up most recent file automatically when vim is started without command line arguments
I have found myself falling into a workflow where I'm often starting vim by running $ vim and then opening up the most recent file once inside.
I was wondering how to detect:
when vim is launched
...
0
votes
1
answer
56
views
Is there a way to stay in the command line window after executing a line?
I find the command-line window incredibly useful for experimenting with my vim environment. But it's annoying to have to type q: every time I execute a line with <CR>. Is there a way to execute ...
0
votes
0
answers
50
views
How to show "/foobar match 1 of " or "E486: Pattern not found: foobar" in commandline when calling `normal! n` in function [duplicate]
I'm calling normal! n in a vimscript function.
If there is a match, I don't get the message /foobar match 1 of 3 in the commandline.
If there is no match, my commandline shortly flickers up and down ...
1
vote
2
answers
138
views
Can I open a file at an arbitrary line and column via the command line?
I'm working on Open::This, which provides a command line utility that acts as a wrapper around vim, emacs and nano. The utility is called ot. It does things like translating ot lib/Foo/Bar.pm:99 ...
0
votes
1
answer
60
views
Is it possible to non-recursively remap a command?
So Fugitive defines :Glog. This is, apparently, aliased to a call to the script-local s:Log() function (according to :command Glog.)
My muscle-memory has been using glog at the command-line, for ...
2
votes
1
answer
2k
views
Commands history for vim commandline and :terminal [closed]
I want a way in which we can access a history of commands in terminal mode (and Vim/NeoVim's internal command line), just like in a normal bash terminal; i.e. if I press the up key it will scroll ...
4
votes
3
answers
4k
views
How to have the echo command process newline characters?
I find that when running :echo message with a message variable that contains newlines, it displays the newline character as ^@. Often I'd prefer it to actually be split on a new line though. Do I ...
2
votes
1
answer
447
views
How to force redraw when returning to command line from command line history window?
Something that's bothered me for about a decade now is that when I switch from command line into the command-line-history window (by pressing <c-f>) and then switch back (by pressing <c-c>)...
1
vote
2
answers
393
views
Make :w automatically run :nohl
I want :nohl to be run automatically whenever I run :w.
How can I set this up?
I tried
autocmd BufWrite * :nohl
in my vimrc but that's not working
Apparently (from comments, thanks D. Ben Knoble)...
2
votes
1
answer
157
views
repeat last command but not write
@: repeats the last colon command I entered, but also seems to include :write
so often I go through this kind of workflow:
:s/foo/bar
:w
Now I go to another line and want to run :s/foo/bar again, ...
0
votes
1
answer
1k
views
FZF --preview in Vim returns zsh shell error
I have been trying out FZF with Neovim. I installed it via a nvim plugin package manager. I have not installed it for the command line.
When trying to see file previews :FZF --preview="head -$LINES {}...
0
votes
1
answer
124
views
Make a command to open c files next to the corresponding header
I would like to have commands like :ce and :ctabe that open a tab with a vertical split with the .c file on one site and the corresponding .h file on the other. How can i accomplish this behaviour?
4
votes
2
answers
531
views
How to edit a file in a new tab?
I want to map :e file.txt to :tabnew file.txt, or the equivalent setting for editing file in a new tab. What do I need to put into my vimrc?
1
vote
1
answer
2k
views
Changing the vim color scheme only highlights lines of text?
I'm a big noob to vim here. I was trying to change the colorscheme of vim by editing the .vimrc file, but as I was playing around with different color schemes (ayu and gruvbox, for example) I noticed ...
2
votes
1
answer
235
views
How can I conveniently close all read-only buffers?
For a longer running vim session, the number of buffers increases. However, often $VIMRUNTIME files, system files and netrw buffers can usually be closed with “closed” eyes. These are typically read-...
0
votes
1
answer
541
views
Sharing vim commands history across different users and computers
I have configured .dotfiles. Eg. see here https://wiki.archlinux.org/index.php/Dotfiles
So now I can do dgit push or dgit pull on whichever computer I want, and I have all my config files (including ....
8
votes
1
answer
1k
views
'<,'> in command prompt
Occasionally when I type : to quit or write my file the prompt already contains the characters :'<,'> without me typing anything. It causes an error if I type w or q. I cannot replicate this ...
1
vote
1
answer
351
views
exiting vim without close tabs or files
I use alias lvim='vim -c "normal '\''0"' for reopen last files in my vim. But the questions is how exit vim without close any tabs or files, When I use :wq it close tab or files.
2
votes
3
answers
1k
views
Is there a setting that hides the last colon-command entered?
Is there a setting I could add to my vimrc file that would hide the last entered colon-command that stays visible on the bottom of the screen after I hit enter?
For example, if I type ":3" to go to ...
1
vote
1
answer
853
views
In visual mode, how do I bind a key so that the selected text generates "%s/<SELECTEDTEXT>/<CURSORHERE>/g"?
In visual mode, how do I bind a key so that the selected text generates
%s/<SELECTEDTEXT>/<CURSORHERE>/g
?
Preferably ; considering I never use it otherwise.
Thanks.
0
votes
1
answer
58
views
How to start recording a macro, using commandline mode?
If I wanted to start recording a macro using command-line mode, how would I do this?
Additionally, if I wanted to bind this action to a key, how would I do that in my .vimrc?
2
votes
2
answers
320
views
Place a string onto the command line without execution
Suppose I have a variable
let g:f_themes="./themes/**"
Suppose I want to map this command to a key:
:execute "vimgrep /".expand("<cword>")."/g ".g:f_themes." | copen"
That works, even ...
0
votes
3
answers
852
views
What command can I use to insert the current directory in the command-line mode?
Currently, I set the following keymap to my .vimrc:
nnoremap <C-z> :NERDTreeToggle ~/Dropbox/jupyter/<CR>
However, I sometimes want to trigger it with different directory, for example:
:...
0
votes
2
answers
471
views
Move/filter to next *blank* line
I'm trying to do two things involving blank lines (empty lines or lines with only white-space on them).
Move to the next blank line (or EOF if none)
Filter (using !) to the next blank line (or EOF if ...
2
votes
1
answer
629
views
How to make vim shell command wait for keypress?
I have assigned the macro !clear && gcc % && ./a.out to the key 'r'.
So when I press '@r', I expect vim to:
Clear the shell
compile the current C file
run the output
The problem is ...
1
vote
1
answer
247
views
Pasting from register to command line inserts ^M instead of new line
Say I want to search for multiple lines (or do anything with them in the command line).
I yank some lines and enter search mode (/).
I press Ctrl + r" to paste what I just yanked, but I get ^M for ...
1
vote
1
answer
436
views
Stay in visual mode when in command mode and pressing escape
Suppose we do the following steps:
Visually select something
Type :some stuff
press escape
when we do the last step, the command mode is exited but also we are left in normal mode - not visual mode....
6
votes
2
answers
3k
views
How do you make the command mode case insensitive?
For example, I might accidentally type something like :WQ and I want it to work like :wq when a hit enter
Another case is where I am typing a longer command name, for example NERDTreeTabsClose. (Note ...
0
votes
1
answer
207
views
"-u {vimrc}" not working as expected
I am trying to set up vim so I can get different functions in with different files (i.e. x.lisp and x.scm) and in the manual it says starting with the option "-u ufile" uses "ufile" as the vimrc
My ...
1
vote
1
answer
245
views
Vim (Spacevim); :!git push == permission denied (publickey)
I have operating system: Windows 7. Git bash works fine for me, and it uses the public key id_rsa.pub.
I can run git commands fine through window's command prompt as well - and it too uses the public ...
1
vote
3
answers
1k
views
How to redirect terminal output to vim or get `vim like` behaviour in terminal output [closed]
How to get vim keybindings at terminal output so I can navigate/operate at terminal output like in vim or get smooth shell command processing in vim. For example I type:
ifconfig
an i want to make ...
1
vote
1
answer
115
views
Command Ordering
I made a user command called Type and would like it to appear first in the list of available commands when I type :t and then hit tab. Currently, the first command is TOhtml, which I've never used.
...
2
votes
1
answer
68
views
:global, how to use matched pattern in the cmd of :g/pat/cmd?
Give a buffer each line contain a filename. how to use r! cmd on the filename, within a :g command?
eg,
BEFORE PROCESSING:
file1.txt
file2.txt
AFTER PROCESSING (with wc -l):
file1.txt
12 ...
8
votes
3
answers
5k
views
How to run zsh aliased command from vim command mode?
I have a bunch of really useful terminal programs which I use often while I am editing or writing. For example, dictionary is a popular one and I have aliased its usage to single character d in .zshrc ...
1
vote
0
answers
225
views
How vim doesn't expand Ex commands in autocmd?
I'm trying to pass a command to 'vim-tmux-runner' on each file save with au bellow.
autocmd FileWritePost,BufWritePost *.py :VtrSendCommandToRunner python manage.py test <afile>:p:h:t
Where:
:...
2
votes
0
answers
195
views
Bash process substitution on vim command line?
I want to be able to show someone a particular file's undo history in vim, remotely. It's a little complicated, so let me explain one step at a time.
For starters, I can set a custom undofile and ...
2
votes
1
answer
658
views
How to automatically select the first entry of the wildmenu without having to tab?
In vim's command-line, after typing the first few characters, when I press the tab key, the wildmenu appears. However, irritatingly, it requires me one additional press of the tab key to select the ...
0
votes
1
answer
46
views
How do I substitute two same words (of different cases) to another two words whilst retaining their original cases?
I am sorry that my English was not good enough to clearly describe the task in the title.
Here is a more descriptive attempt. Let us say I have the following text
\gls{tla}{TLA}
(As a side note, ...
2
votes
1
answer
83
views
Why are two <cr> characters required when executing this highlighting toggle command?
I use this keymapping toggle to highlighting on and off, but when I originally found it, the author did not list two <cr> at the end of the command. I found that if I didn't have two <cr> ...
0
votes
1
answer
46
views
Indentation script does not work for all occurrence
I have following c.vim file:
imap {<CR> {<CR>}<Esc>O
imap [ []<Left>
imap # #include<><Left>
command F %s/\v(\w) ?(\+|-|\*|\/|\>\=|\<\=|!\=|\=|\=\=) ?(\w|-)/...