Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

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
32 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
61 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
29 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
46 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
27 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
27 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
304 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?
2
votes
1answer
32 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
62 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
12 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
112 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
276 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
40 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
48 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
44 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
28 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
0answers
126 views

What is this gibberish text showing in my command-line and how do I remove it?

My command-line shows some gibberish text whenever I open a file in Vim. Is it because of this lightline.vim extension that I am using? What does that text mean and how do I get rid of it? But the ...
0
votes
1answer
167 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
227 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
98 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
26 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
51 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
30 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
70 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
95 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
46 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
49 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
22 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
24 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
54 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
0answers
45 views

Why does not Vi buffer operation "n (double quote) work in Vim?

I have read from a book that, vi allows the following commands: "ayy, which means yank the current line into buffer named a. "dP, which means paste the content in buffer named d before the cursor. ...
0
votes
1answer
24 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
374 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 ...
1
vote
1answer
528 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
52 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
139 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
98 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
1answer
407 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
1answer
62 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?
3
votes
2answers
121 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?
0
votes
1answer
590 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
1answer
77 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
1answer
158 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
1answer
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
1answer
99 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.
1
vote
1answer
81 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
1answer
33 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
1answer
39 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
2answers
119 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 ...