Questions tagged [ex-mode]

Vim's ex mode is similar to the command line mode which is designed for Batch processing.

Filter by
Sorted by
Tagged with
1 vote
1 answer
62 views

Is it possible to do an "inline" insertion of text with ex

So I'm reading the ex spec and came across the following section under Command Line Parsing in ex: Otherwise: a. If the command was a map, unmap, abbreviate, or unabbreviate command, characters up to ...
0 votes
1 answer
26 views

rightbelow not exhibiting the correct behavior

I am not seeing the correct behavior when I use the rightbelow command. If I run :vertical term then a terminal opens in a vertical split (terminal on the left, existing pane on the right), but the ...
0 votes
1 answer
32 views

Specify the path of a different buffer than the current one in an ex command?

I know I can use :!echo % to echo the name of a file in the current buffer. What can I do if I want to do that for a different buffer that I have open?
0 votes
2 answers
62 views

Completely remove "messages maintainer:" from Vim?

I don't want to see this messages maintainer: message every time I open :messages. Is there a way to remove the messages maintainer: line from messages?
0 votes
1 answer
39 views

exim incorrect substitution count?

I'm having strange bevahiour with Vim 9.0 $ ex --version | head -3 VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Sep 30 2022 03:09:54) macOS version - x86_64 Included patches: 1-270 $ VIM_POSIX='...
20 votes
2 answers
4k views

What does :open do in Vim?

Vim's documentation has this to say about the :open command: This command is in Vi, but Vim only simulates it: *:o* *:op* *:open* :[range]o[...
8 votes
4 answers
9k views

How to delete a multi-line match?

For testing purposes I've opened the following file: vim http://example.com/ And I'm using the following command to delete a highlighted multi-line pattern: :/<body\_.\{-}body>/d which ...
0 votes
2 answers
1k views

Add a line after 1 line after match in Ex mode

I need to search for a string in a file, then I need to some text after one line following the first match. I need to perform this for a number of files in a script. I am trying to use vim ex mode ...
1 vote
2 answers
42 views

Where's the documentation for Ctrl-C while in [Command Line] buffer?

Long ago I discovered that q: opens a [Command Line] buffer where I can enter and edit an ex command line using all the power of Vim. Next, some time ago, I discovered that I can access that mode even ...
5 votes
1 answer
255 views

Is the colon of the {cmd} argument to autocmd optional?

I know it's a dumb question, but I don't find the explicit answer in the docs. Learn Vimscript the Hard Way's chapter 12 is about autocmds. Here are a few examples: :autocmd BufNewFile * :write :...
1 vote
0 answers
428 views

How does .vimrc relate to ~/.config/nvim/init.lua?

When I heard neovim had a "native language client", I wanted to trying moving it. Previously, I was using a language server loaded through vim-plug. This was always problematic. When I ...
3 votes
1 answer
1k views

Is the goal of Lua in neovim to replace Ex, and if not what is it?

I am a new user to neovim, and a moderator on this site said You seem to imply that you expect there should be a native way to run [filetype] (and to some extent every Ex command) directly in Lua. ...
2 votes
2 answers
194 views

Prepare a range for an ex command without visual mode or line numbers

Background: I can pipe a paragraph through an external command using !ip and the cursor goes to the end of the following prompt: :.,.+5! If I want to use the built-in sort or center functions I ...
193 votes
9 answers
82k views

Does Ex mode have any practical use?

Vim has an Ex mode that can be entered by entering Q, and a command line mode that can be entered with q:. A common complaint amongst new vim users is that they enter these modes accidentally when ...
2 votes
1 answer
33 views

Vimscript - Prevent Column From Moving When Using a Count

When you use a count to a key mapping it goes down count number of times and resets to column 1. Actually it already resets to col 1 when entering the function if there is a count. So I can save the ...
3 votes
1 answer
141 views

How to input <CR> into ex command from script or commandline?

I recorded a macro, that has an enter in it ggd/{<CR>Gdd but of course is ^M. What I want to do is run this on a bunch of files from the commandline which I guess would be something like ex +&...
3 votes
1 answer
157 views

Inserting the content of a register where a macro is recorded results in control characters becoming unicode characters

If I hit Ctrl+V and then Escape while in insert or ex mode, I get ^[ as a single character. If I hit qqEscapeq and then go see :registers, I see that q contains ^[<80><fd>a, which are ...
1 vote
1 answer
44 views

Find definition of ex command

Normally when I try to trace back a setting to where it was set in my vim config (or plugins) I use something like: :verbose set undodir undodir=~/.vimundo Last set from ~/.vimrc line 62 To ...
4 votes
1 answer
305 views

How to reference a register in an ex command

I'm trying to write what I thought would be a simple macro to take some values that have been yanked into some registers (a & b) and use bc to do some addition with those values. Here is the ...
3 votes
3 answers
795 views

How do I emulate Sed's y command?

For the very first time I find myself in need for the y command Sed has. For those who don't know what y does, here's an example: $ echo x1 x2 x3 | sed 'y/123/234/' x2 x3 x4 Apparently Vim has no way ...
0 votes
2 answers
69 views

How to execute a shell script from a line in a file with `%` in it

I have a shell script on a line alone in a file which I would like to be able to easily execute from vim. Normally I could simply use Y:!^R", but this particular script has % in it, which is ...
0 votes
1 answer
108 views

au VimLeave ex mode command not returning output

I've been using the fmt Unix tool to standardise line length, for example :%! fmt -999 (thanks to this answer). I'd like to do this by default in Markdown files, so in ~/.vim/ftplugin/markdown.vim I ...
2 votes
2 answers
187 views

Why "normal n" does not work in Ex mode?

For example, if I want to find all bar lines and print them. $ cat file line foo line bar 1 line bar 2 $ cat cmd norm gg /bar p norm n p $ cat cmd | vim -u NONE -es file line bar 1 line bar 1 $ As it ...
4 votes
1 answer
84 views

Why do some Ex commands not need a white space before a path argument?

For example, why does this work: edit/home/foo/bar.txt (I had to enter visual to see the changes) I was expecting a whitespace after edit, like: edit /home/foo/bar.txt I couldn't find a reference in ...
14 votes
1 answer
4k views

delete lines that match a pattern from a given line to the end of the file

If I have a file with a lot of comments in it and I want to delete all of the comments from say, line 3 to the end of the file, what's the best way to do it? I'm stuck, since what I first tried doesn'...
1 vote
1 answer
91 views

Expansion of cmdline-special vs `=

Reading (and re-reading) the Vim docs on when :h cmdline-special expansion happens versus :h `= expansion, the :grep example below has me stumped: :let &grepprg = "echo 'grep: $*'" ...
2 votes
1 answer
183 views

How do I find the ex/vimscript equivalent of a normal-mode command?

Some operations can be done with either normal-mode commands or ex/vimscript commands. For example, :resize 1 does the same thing as 1 <C-W> _. In scripts, it's possible to simulate normal-mode ...
0 votes
1 answer
177 views

Conversion of Ex command to mapping not always working

Here, I'm using a mapping from this post. Edited it to my liking like so: nnoremap <F3> :execute 'help' expand('<cWORD>')<CR> that works. Problem is, i wanted to add | only so that ...
4 votes
2 answers
1k views

How to get line numbers of selected text

Is it possible to get the line numbers of selected text to pass to an external command? Context: I'd like to integrate pyfmt into vim. Ideally, I'd like to be able to select some text and type some ...
1 vote
0 answers
39 views

Is there a way to use ex mode similar to ed, with append only lines and all curses like features disabled?

I'd like to use ex similar to how ed behaves on an old teleprinter, so without ANSI Control sequences and CRT manipulations. This way it would be easier to interact with it from a Braille terminal, ...
3 votes
1 answer
2k views

How do I use vim within a Unix pipe-line?

I can use vim / ex to grep a file using the following invocation: ex -c'g/foo/p' -cq -s afile.txt I'd really like to use a similar command to grep some text from stdin. I thought the following command ...
1 vote
1 answer
254 views

How to escape a single quote when passing an ex-mode command from the command line, back to the command line?

Here is the command I'm trying to escape a ' from bash, to vis' to ex-mode, and then back to bash so it can be read into the buffer again: vi -c 'sp | enew | read ! echo "Use to jump between ...
1 vote
0 answers
231 views

Can I use feedkeys() inside of a keyloop implemented by getchar()

I implemented a fuzzy filter, which accept a list argument, open a window with a scratch buffer whose content set to the list, then waiting for use input and do filtering. Here is why I ask this ...
1 vote
1 answer
72 views

Is it possible to use word completion (e.g. `Ctrl-N`) in Ex mode?

I want to use word completion in Ex mode, similar to using Ctrl-N in Insert mode to complete the current word. Suppose, I want to do a substitution: :%s/<pattern>/<replacement>/gc. If the ...
1 vote
1 answer
307 views

Is it possible to view a history of commands (per mode) executed in Vim?

I sometimes execute commands in Vim by mistake, either in normal-, visual-, or ex-mode and have no idea what was executed. Is it possible to see a history of executed command per mode in Vim? I know ...
5 votes
1 answer
3k views

Using the ex mode command line (-c), how would I insert text?

I am interested in mastering the art of using ex from the command line (vi -esc <commands> / ex -sc <commands>). I got the basics worked out, but one thing eludes me: How do I add text ...
3 votes
2 answers
1k views

g/pattern/d but check first

I'd like to use Ex mode :g/pattern/d to delete most (but not all) of the rows containing pattern, but I want to see each one first and confirm before deleting, similar to :s/pattern/foo/gc. Is there a ...
4 votes
1 answer
2k 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 ...
2 votes
1 answer
365 views

How to paste copied character in ex mode?

Pressing yl I can copy the character where cursor locates. Now I press : to enter into last line mode, I enter %s/. Now I want to paste the character copied by yl. How can I do that?
6 votes
1 answer
827 views

vim, vimdiff, ex, view, rvim and rview: How do they start in a different way when they are symlinks to the same binary?

I just installed version 8 of Vim and notice in the bin directory of the install location that all the above mentioned programs point to the same binary – vim. Then, how does it know when I invoke ex ...
3 votes
2 answers
1k views

vim ex mode write to stdout

I am trying to output the contents of a file opened in vim ex mode to stdout. vi -es +'%write !tee' +'q' ./testfile Unfortunately, it does not write anything, although if I open the file in ex mode, ...
4 votes
0 answers
115 views

Why does vim ex mode 'print' command insert a space on empty lines?

Take the following example: $ printf "a\n\nb\n" | vim -E -c "%p" -c 'q!' /dev/stdin | hexdump -C 00000000 61 0a 20 0a 62 0a |a. .b.| 00000006 I would not expect that ...
1 vote
2 answers
264 views

File emptied when command not found

Given this command: ex -sc '%!alfa' -cx file I get this result: sh: alfa: command not found which is to be expected. However an unintended side effect of this is that the file is emptied and saved....
3 votes
2 answers
198 views

How to replay ex commands in order?

I often have a situation where I will direct some output to a file then open it in vim and use ex commands (substitution, keep lines, delete lines, etc) to massage the output to a form I want. However ...
4 votes
2 answers
360 views

Does vim's ex command line support (readline-like) motions? [duplicate]

tldr Moving in ex command line is slow because common readline motions (like in bash) are not supported. Are there any improvements for this? I often find myself with an ex command in the command ...
7 votes
4 answers
8k views

Replace with hex character

Given this file: printf 'hello\x19world\n' > hello.txt I can replace a hex character: $ ex -sc '%s/\%x19/ /|x' hello.txt $ od -c hello.txt 0000000 h e l l o w o r l d \n ...
2 votes
2 answers
360 views

Is it possible to use the :put Ex command using column numbers?

The documentation for :put says that the command accepts a line. That is, it puts the content after the line specified. Is it possible to put the content at a particular mark? For example, say I am ...
5 votes
2 answers
222 views

Equivalent of !n in bash in vim for ex commands?

I'd like to be able to view the last n commands, similar to the history command in bash, and then be able to execute the nth command similar to the way it is done in bash by using !<command number&...
4 votes
1 answer
603 views

Why substitute doesn't work in silent mode?

I'm playing with ex and I've found that removing trailing spaces for multiple files in silent mode doesn't work as expected. The following examples doesn't work as expected (whatever I use argdo or ...
1 vote
4 answers
854 views

In Vim ex mode how to re-use a string from the default buffer in the command

I'm trying to modify this file, by extracting the very first line in the file and prepend it to each of the consecutive lines until end of the file black widow card Friday berry I used ex command (...