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
29 votes
1 answer
14k views

How to edit files non-interactively (e.g. in pipeline)?

I would like to edit files passed in pipeline input using vim in non-interactive way or edit files in-place (similar to sed). Few examples using sed: $ sed -i'.bak' s/foo/test/g file # Edit file ...
kenorb's user avatar
  • 18.3k
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[...
Random832's user avatar
  • 1,202
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 ...
Andrew Ferrier's user avatar
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 ...
Enlico's user avatar
  • 2,184
1 vote
4 answers
893 views

redirect exmode command to variable

This is perhaps a beginner question, but I'm unable to (intuitively) figure out how to redirect the output of an ex command to a variable for further processing. Some background: I'm trying to create ...
Mahmoud Al-Qudsi's user avatar
10 votes
2 answers
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 ...
kenorb's user avatar
  • 18.3k
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. ...
Evan Carroll's user avatar
  • 1,244
14 votes
1 answer
3k views

What is the difference between Ex mode and improved Ex mode?

There are two vim Ex modes: the vi compatible Ex-mode (vim -e -s), vim improved Ex mode (vim -E -s). Vim improved Ex mode allows for more advanced commands than the vi compatible Ex-mode, however ...
kenorb's user avatar
  • 18.3k
9 votes
2 answers
578 views

Use ex-command to check whether two lines are identical?

I was looking at this question and then wondered how I might implement my answer which uses sed using purely POSIX ex. The trick is that while in sed I can compare the hold space with the pattern ...
Wildcard's user avatar
  • 4,389
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 ...
kenorb's user avatar
  • 18.3k
7 votes
1 answer
2k views

How can I repeat last Ex-mode command in normal mode?

I'm looking for something like . or @@ that will work in normal mode for repeating the last Ex-mode command. As per the rule of the XY problem, I'll also state the broader goal: I have a fancy regex ...
Wildcard's user avatar
  • 4,389
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 ...
silico-biomancer's user avatar
4 votes
1 answer
2k views

How to copy lines from 4th till 11th and paste it from 15th till 22th line in ex mode?

To move cursor on the 4th line,toggle into normal mode,input 8yy. To move cursor to 15th line,and toggle into normal mode,press p . Now the lines from 4th till 11th was pasted from 15th till 22th ...
showkey's user avatar
  • 1,120
4 votes
2 answers
1k views

How to search in Ex mode and place the cursor on the matched pattern?

I've the following example: vim -E http://example.com/ where I'd like to search for <head> tag. It seems that search only works when the lines are separated, but when the lines are joined ...
kenorb's user avatar
  • 18.3k
2 votes
1 answer
838 views

How to print a multi-line match?

I've a file where I would like to extract a multiline pattern in non-greedy way (similar to this scenario) by using ex editor. This example works fine: $ ex +'/aa/,/cc/p' -scq! <(echo -e "start\...
kenorb's user avatar
  • 18.3k
2 votes
1 answer
2k views

How to set the vim path to your bash PATH?

I'd like my $PATH to be available to vim when running commands with !. How do I set vim's set path= to my environment variable $PATH?
leeand00's user avatar
  • 3,491
2 votes
1 answer
402 views

Automatically set the 'number' option in Vim when entering Ex mode, set 'nonumber' in visual mode

I have previously asked this in StackOverflow (May 2015), but without getting any replies that I was completely happy with. This ought to be simple: I want to configure Vim to set number whenever ...
Kusalananda's user avatar
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 (...
Inian's user avatar
  • 63