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
2answers
383 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 ...
13
votes
7answers
6k views

How to search for lines matching current line in vim

I usually search for words by :/string, but if I have to search entire current line, how to do that. event: 1 beacon: 0x02 //line 1 event: 19 beacon: 0x02 //line 2 event: 1 ...
1
vote
1answer
105 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
313 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....
0
votes
1answer
164 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
1answer
179 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 ...
3
votes
3answers
118 views

remap ':' to maintain last command, and erase all char if any key other than <CR> was pressed

As the title stated, remap ':' to maintain last command, and erase all char if any key other than <CR> was pressed. possible use cases: I have typed a long command, and I may or may not ...
1
vote
3answers
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 ...
2
votes
1answer
61 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 ...
7
votes
3answers
4k 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 ...
13
votes
2answers
2k views

How to work with command-line mode the vi way?

Is there a way to interact with the command-line mode while always remaining in the home position? In particular, the following two actions are cumbersome, requiring moving the fingers away to the ...
1
vote
0answers
175 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
150 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
1answer
439 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
42 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
1answer
167 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 ...
4
votes
2answers
430 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
127 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> &...
1
vote
0answers
192 views

What encoding does :! use?

I'd like low-level control over exactly what bytes I send and receive from a process spawned from some vimscript. What encoding is used for communications with commands started with :!foo? Can I ...
0
votes
1answer
353 views

Is it possible to make the tab completion on command-line mode case insensitive?

When I try to type in my directory to open my file, for example ~/Desktop, the tab completion doesn't work at the point of ~/d, since the completion only works on the capital letter. I already wrote ...
5
votes
1answer
2k views

Using colon-commands inside ternary expression

I have the following lines in my .vimrc let g = 0 inoremap <silent> <C-g> <C-o>:let g = !g<CR> inoremap <expr> <C-_> <C-o>(g == 0 ? :undo : :redo)<CR> ...
0
votes
1answer
1k views

my ag shortcut chokes on spaces

I got this in my .vimrc: set grepprg=grep\ -nriI\ --exclude=tags\ --exclude-dir=vendor " The Silver Searcher if executable('ag') " Use ag over grep let &grepprg = "ag --nogroup --nocolor --...
0
votes
1answer
154 views

opening multiple files in order of last changed

Suppose I want to look through a lot of files, one by one, using vi *. Is there an easy way to look a these files in non-alphabetical order, for example in order of newest or oldest first?
1
vote
2answers
796 views

vimscript: set text of command line in command mode?

How can one set the text of the command line in command mode? So when it is not in use? Same as the message that appears when writing a file? I'm looking for a solution for vim and/or nvim, preferably ...
1
vote
1answer
104 views

How do I move cursor around on unix shell using VIM commands? [closed]

I'm a vim user and forgot to grab my csh/vim settings before leaving my prev company. Basically, when tooling around my unix shell, I used vim commands (eg go back and forth using VIM quick-keys, ...
0
votes
0answers
92 views

Is it possible to copy block (given by range) multiple times in a single command?

Is there a way to copy a few times a given block from command-line mode, e.g. with the :t command? For example, how to copy the two lines (block) above the cursor -2,-1 to the current position ., 3 ...
2
votes
2answers
871 views

cnoreabbrev do not expand abbreviations in command history

Is it possible to configure vim to store commands in your command history without abbreviations expanded? For instance I have the following command (to make it easy to switch back and forth between ...
0
votes
2answers
110 views

Using -c command line option for Vim 7.4 on Windows produces errors

The following commands work fine when I issue them from the command mode in Vim: :%s/\(^\s\+\)\(\S\+.*)\s*\){$/\1\2\r\1{/g :g/^\s*\/\/$/d But when I run the above commands as a script as below: ...
2
votes
1answer
39 views

Can I change the command mode (: ...) so that I can have vi shortcuts?

Basically my question is this. On my terminal I have vi mode enable. It saves me lots of time editing command line arguments and zooming throught the file system. I would like to have a similar mode ...
2
votes
1answer
1k views

Creating mappings for command-line mode

I have made a few mappings for my personal configuration file, and I think I am getting a hang of it, however, I am wondering if there are any particular tricks to create mappings for command-line ...
1
vote
1answer
6k views

I'm stuck in Vim; I see "Command Line" at the bottom and nothing makes Vim respond

I pressed :wq to write and quit. Except now I see a Command Line at the bottom and nothing I do makes vi respond (Enter, Esc, Ctrl+c, :, q, etc.). How do I get back to civilisation from here? If you ...
1
vote
1answer
228 views

Send one-liners from vim to R

As the title said, I would like to select and send to execute lines from my vim script to the statistical software package R (say an instance of it open in a different terminal). While there is a ...
6
votes
1answer
1k views

How to navigate using vim keybindings in command line mode?

When using vim in commandline mode, I have to navigate using only arrow keys. I can't use the native vim bindings because when I key <esc>, it exits commandline mode. For example, if I was ...
2
votes
2answers
1k views

How to create multiple files?

While working on something like laravel, I end up creating the same view files index.blade.php, create.blade.php, show.blade.php within different folders like views/articles, views/comments, etc using ...
2
votes
2answers
467 views

Any recommendations to enforce use of keybindings rather than equivalent command mode commands?

Context: I learned about the :[v]split command long before I learned the shortcuts Ctrl-w+[s|v] and as a result I find myself typing these commands often. Is there a way to break this habit ? (as a ...
10
votes
4answers
1k views

Can I use "gf" (or similar) to open a file and jump to a search term?

Is there a way to get vim's gf command (or something similar) to recognize a +{cmd} argument for file-paths? One can start vim and go directly to a search term by doing: $ vim +/coding_effort ~/...
1
vote
2answers
228 views

Contextual text processing

I would classify my mathematics pdf collection in folders named by the MSC 2010 Classification (just the 2 top-level). My approach is creating a file which will contain all path and uses mkdir in a ...
3
votes
1answer
476 views

I've just installed (g)Vim, how do I get arrow keys to access command history?

So the problem is that I've installed (g)Vim and the arrow keys are moving around rather than going through command history. It's a little complicated by the fact that there was an old version of vim ...
3
votes
2answers
621 views

The meaning of "= in Vim

I was solving a problem on Vimgolf (you can take a look at this) where I stumbled upon this solution. djgJ.V"=[<C-R><C-A>]<CR>pZZ Could you please walk me through the meaning of ...
1
vote
1answer
437 views

Checking if Makefile exists before executing autocmd

I want Vim to execute build the project automatically after I write the buffer to a *.c or *.cpp file. Here is what I've done: autocmd BufWritePost *.c,*.cpp make This one works as expected (but the ...
87
votes
2answers
58k views

Close and unload a buffer without exiting Vim

Often, I'll load some information into a temporary buffer, and then close it with :clo!. But this hides the buffer rather than unloading it entirely, even though I have nohidden set. I find this ...
10
votes
2answers
4k views

How to write whole buffer to standard output from the command line?

I would like to write whole buffer into standard output (/dev/stdout) instead of the file and the following command works as expected while editing the file: :w >> /dev/stdout Hint: Press ...
9
votes
1answer
660 views

Wrong encoding while calling shell

I was experimenting with a DOT diagram and tried to do the following: :! dot -Tpng -oFab.png % I got an error because my filename has a special character ("ó" in "Fabricación"): C:\windows\system32\...
1
vote
2answers
414 views

User command with modified 'path' completion?

I'm trying to write a wrapper command around :edit or :find specifically to open either my vimrc or a subpath of ~/.vim/ (e.g. ~.vim/autoloads/foo.vim). If I run the command with no arguments, it ...
3
votes
3answers
2k views

Execute external command in split window

Is there a way to get the following in Vim: If I execute a command in Vim like !make c, I would like to have a frame/split that pops up like in syntastic instead of switching to terminal view. That ...
7
votes
1answer
582 views

How to make command-line abbreviations that only trigger at begining of line

I have a custom save function, and bound it to :w by using an abbreviation: cabbrev w call SaveBuffer() This works, but I ran into issues when I wanted to reference window local variables because w: ...
1
vote
2answers
733 views

How to add inline comment for the echo command?

I've tried the following syntax: :echo 123 " comment but it failed with E15 and E114 errors. Is there any way to put the inline comment right after the command, so it can be ignored?
3
votes
1answer
542 views

How to delete blocks of text which contain a specific string?

I have a file which has the following structure From: foo@example.org Subject: Bar Date: 2017-06-27 Mailbox: /some/dire/ctory <CR> Such a block always contains of four lines followed by an ...
2
votes
1answer
2k views

source the current file

I know that to source my current file I need to do this: :so ~/.vimrc But is it possible to source the current file without mentioning its name?
2
votes
1answer
450 views

Issue with using ex commands

I asked a question a few days ago in the Linux/Unix SE about how to copy a block of text from one file to another in a way that I could use for a script of many similar files. I thought I came up with ...

1
4
5
6 7 8