Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

1
vote
0answers
21 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
0answers
7 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
21 views

What does & mean in an external command (using :!)? [on hold]

There is a line in Vim User Manual (usr_30.txt - Editing programs) I can't entirely understand: :!make | &tee /tmp/vim215953.err I know that by using ! you can execute followed by command (or ...
0
votes
0answers
14 views

How to show “/foobar match 1 of ” or “E486: Pattern not found: foobar” in commandline when calling `normal! n` in function

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
38 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
31 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
18 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
37 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
47 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
25 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
59 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
85 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
69 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
33 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
68 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
64 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 ...
1
vote
1answer
60 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
75 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
998 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
88 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
37 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
28 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
32 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?
0
votes
0answers
28 views

Is it possible to set up vim to autocomplete from a file in command mode

I have the following function: function s:Test() { let l:build_dir = $HOME.'/path/to/repo/.build' let l:node_modules = l:build_dir.'/node_modules' let l:bin_dir = l:node_modules.'/.bin' ...
0
votes
0answers
37 views

Neovim command-line mode strange behaviour

I've just moved from vim to neovim to discover it. When I hit : in normal mode, it goes to command-line mode. Then I hit the first letter of the command, nothing appears beside the :. Then I hit the ...
2
votes
2answers
68 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
3answers
53 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
2answers
56 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 ...
1
vote
0answers
38 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
1answer
26 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
1answer
55 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....
1
vote
1answer
194 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
1answer
45 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 ...
0
votes
0answers
40 views

gx doesn't work on visually selected text

I have a link to a pdf file in my vim which contains spaces. I'm trying to open it with external app. While with gf I can visually select the text (e.g. a b.pdf) and open the pdf as a text file but ...
0
votes
1answer
65 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
3answers
204 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 ...
0
votes
1answer
36 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
1answer
43 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 ...
3
votes
3answers
333 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
0answers
52 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
0answers
52 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 ...
1
vote
1answer
47 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
1answer
33 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, ...
0
votes
0answers
14 views

Help completion appended with @en

Help completion has started showing @en after each choice. So, I get this after typing :help :set[tab][tab] :help :set+=@en I'm not sure when this started. Can anybody identify what it is so I ...
2
votes
1answer
63 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
1answer
32 views

Indentation script not works for all occurence

I have following c.vim file - "imap ( ();<Left><Left> imap {<CR> {<CR>}<Esc>O imap [ []<Left> imap # #include<><Left> "imap " ""<Left> " ...
0
votes
1answer
132 views

Call vim command from shell, and suppress output while it operates

I'm setting up a vim environment install script. I'm using vim-plug for plugin management. What I'd like to do is, from the install.sh, run vim and call PlugInstall to trigger plugin download and ...
0
votes
1answer
38 views

Combining shell commands with :terminal

I have two shell commands which I want to run. However I only want to run the second one if the first one was successful. For simplicity let the commands be ls and ls. I can call then once at a time ...
2
votes
2answers
120 views

sending variable commands in vim-slime

I am relatively new to vim and have started using the vim-slime plugin. One thing I use it for is to run python scripts, for example :SlimeSend1 python ~/myPythonFile.py I now would like to automate ...
1
vote
1answer
37 views

Can I move to the start of the line on command-line mode?

I would like to move to the start of the line on the command-line mode with Ctrl + a. Right now I have the following setting on my ~/.vimrc, which is effective on insert mode: inoremap <C-a> &...