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
26 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
26 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
48 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
306 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
85 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
30 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
53 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' ...
3
votes
1answer
47 views

Open command-line-mode from VimScript function

How to reproduce this mapping: nnoremap <Leader>a :DoSomething <C-r>=do_something_arguments()<CR> ..in a function? The desired effect is to open command-line mode with some text ...
1
vote
1answer
18 views

Showing external command output only if not empty

Is it possible to silently run an external command, but show the output on the prompt only if there was any?
3
votes
2answers
981 views

What is the difference between normal mode and command line mode?

Normal mode is also called command mode, and is different from command line mode. It seems both can be used for : commands, but what is the difference?
5
votes
2answers
439 views

How to highlight matching string while typing a regular expression?

While I enter a regular expression on the vim command line, I would like to see what matches the partial expression I already wrote. For example, while writing the command :%s/regular all words ...
2
votes
3answers
48 views

How can I prevent Vim from centering the line under the cursor on `:edit`

Each time I want to save my work while editing a text file, I enter :write to save the file, and :edit to reload the file, with the side effect of resetting the undo/redo buffer. However, an unwanted ...
0
votes
1answer
48 views

Wildmenu for command line history

While there is <up> and <down> that tries to complete the line, sometimes one wants to recall all the commands that start with what was typed, on a (wild)menu. Is this possible somehow?
1
vote
1answer
101 views

Is it possible to have vim run a command every time save `:w` is invoked?

I am editting typescript now, and I'd like to be able to have it so, whenever :w is invoked, the shell runs tsc compiling my new save. This beats having to !tsc every time. Does something like this ...
0
votes
1answer
61 views

I want to save my typescript file, and immediately run tsc myfile.ts from inside vim. What is the best way to accomplish this?

I am building a daemon, and nodemon currently monitors a file called server.js, which is compiled from the file I am working on, server.ts In order to compile server.ts, after saving with :w, I need ...
3
votes
1answer
126 views

How do I use a variable or return value in option, command, or mapping?

I have a variable foo with let foo='value', and a function F like function F() return 'value' endfunction and I want to use them in an option: :set option=foo, :set option=F(); or in a command: :...
0
votes
0answers
40 views

How to remove blank line at the very bottom of the UI

To make things easier to explain, please see below a screenshot of VIM running on my computer. How can I get rid of that blank line at the very bottom, i.e. below the "n lines, p characters written" ...
3
votes
1answer
33 views

search for pattern and insert text that precedes the pattern from pattern1 to pattern2 exclusive

basically I have a bunch of lines of code that all match the format .\module.variable (), .\module.variable2 (), I want to take everything between the backslash and the space, before the parentheses ...
0
votes
3answers
1k views

How to restart vim from within vim?

Here's how I restart vim: $ vim :q $ vim Is there a way to restart vim so that there is no need to type the second vim in the shell?
3
votes
1answer
126 views

How to show completion menu when typing EX-command?

When I use MS Windows version gvim, when typing EX-command, I can press TAB then there will show a completion candidates menu. For example, if I type :colorscheme then a space then press TAB, gvim ...
1
vote
1answer
143 views

How to get the names of all open buffers?

I can use % to get the name of the focused window for commands. How can I get a space-separated list of all buffers for use in a command? For example, I would like to call :!cat [all] where [all] ...
2
votes
2answers
16 views

How to open one file as “read only” but the others as writable using command line?

Here is what I am doing now: vim + $1 -c "set titlestring=$title guioptions-=m guioptions-=r lines=66 columns=239" -c ":source .vim_map" -c "sp .help.txt" -c ":wincmd j" I would like to open the ....
2
votes
3answers
277 views

How to repeat the last : command for a visual selection instead of whole buffer?

Say I've done the command: :g/^.\{1,50\}$/m$ To move all lines with 50 or less characters to the bottom of the file. Then I realise I actually didn't want to do that for the whole file, but for ...
1
vote
4answers
545 views

How to change word under cursor to upper case in command mode with shortcut?

I want to set up a shortcut to make word under the cursor upper case in the command mode. I know that you can get the word under the cursor with expand("<cword>"). But I am not sure how do I ...
0
votes
1answer
81 views

Changing PYTHONPATH from inside VIM

Today I was writing code in VIM and wanted to change the PYTHONPATH and so I ran: :!echo $PYTHONPATH;export PYTHONPATH="/home/oli/git/published_libraries/computer_communication_framework";echo $...
1
vote
1answer
71 views

Line mode command to delete from column X to end of line?

Using gvim on a file with 30K lines, I want to use ex mode to delete from column 130 to end of line, making each record no longer than 130 characters. I want to do this for the entire file. My macro ...
0
votes
1answer
61 views

Is there a way to enter command line mode for a single command directly from insert mode?

I'd like to go directly into command line mode from insert mode, enter a single command (say :r !date which inserts the date) and then go immediately back into insert mode. Basically something ...
0
votes
1answer
41 views

Print Command Without Hitting Enter

Suppose I map a key to enter a command in the command buffer, but without hitting enter: function! BuildSystemTask() if inProject() "generic function that checks if I am in a buildable project ...
0
votes
1answer
407 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
2answers
232 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
2answers
103 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
1answer
27 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
1answer
66 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
1answer
26 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
2answers
40 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
1answer
89 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
1answer
158 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 ...
0
votes
1answer
71 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
1answer
61 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
1answer
23 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
0answers
29 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
2answers
55 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
1answer
27 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 ...
1
vote
1answer
606 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 ...
2
votes
1answer
1k 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 ...
1
vote
1answer
72 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
2answers
161 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
1answer
101 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, ...

1
2 3 4 5 6