Questions tagged [ex-mode]
Vim's ex mode is similar to the command line mode which is designed for Batch processing.
120
questions
0
votes
1
answer
23
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
30
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
57
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
36
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='...
1
vote
2
answers
40
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
247
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
366
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
921
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
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
129
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
122
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
41
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
281
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
784
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
67
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
104
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
183
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
83
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 ...
1
vote
1
answer
88
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
181
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
153
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 ...
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
234
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
1
answer
69
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
294
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 ...
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 ...
2
votes
1
answer
341
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
805
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 ...
4
votes
0
answers
105
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 ...
2
votes
2
answers
181
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
348
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 ...
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, ...
1
vote
0
answers
227
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 ...
0
votes
2
answers
944
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
4
answers
841
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 (...
0
votes
2
answers
430
views
Why is `vim -E` always exiting with non-zero exit code when using here-doc?
see the following session in dash:
$ printf "foo\nbar\n" > testfile
$ cat testfile
foo
bar
$ vim -E testfile <<-EOS
> 1
> s/foo/baz/
> x
> EOS
$ echo $?
1
$ cat testfile
baz
bar
$...
3
votes
1
answer
110
views
Why does colon in shell command read the wrong file?
I write ruby test files in vim, and regularly run tests from the file I'm editing by running
:!rspec %:N
or something similar (to execute the test at line N). The problem is that when the first ...
0
votes
2
answers
227
views
How to yank a specified amount of lines in vim -E mode?
This is my first-post and question here so please be gentle (but also tell me if, it I wasn't specific enough etc...)
So my questions seems rather simple to me, but still blocks me and I can't find ...
0
votes
0
answers
36
views
How do you end the command when using :c?
When using the ex command change (c), carriage returns become part of the input, so how do you indicate that you are done entering text?
(I notice that if I hit the backspace, it finishes the command,...
0
votes
1
answer
296
views
Transform lines: prepend with incrementing number and string and append with string for each line in one step
I have the following lines:
abc07
bca08
xyz17
And I would like to transform it to:
[0]="abc07" \
[1]="bca08" \
[2]="xyz17" \
Based on this question, I can do the first part and the end ...
4
votes
1
answer
2k
views
How to use normal mode commands in ex mode?
When I start vi/vim as ex, I can use the -c option to provide the set of ex commands to apply to a file:
echo Yes | ex -sc 's/Y/y/|%p|q!' /dev/stdin
yes
But how can I use normal mode commands like ...
1
vote
2
answers
317
views
Overwrite buffer with system clipboard by ex command
I'm trying to find the right ex command to overwrite the current vim buffer with the system clipboard.
The relevant system clipboard register is "+ in this case.
My first guess was to use :%+p; i.e. ...
1
vote
2
answers
1k
views
How to write the output of scriptnames into a file? [duplicate]
:scriptnames can list all plugins installed in my vim.
How to write the output of scriptnames into a file?
:scriptnames > names.txt
It can't do the trick.
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 ...
0
votes
1
answer
109
views
Discrete line numbers specified individually not as range
I was trying to find out if it is possible to give an ex command a list of lines instead of a range?
1
vote
3
answers
1k
views
Execute() is not returning a value
I am apparently not getting a return value from execute():
function! Example()
return 5
endfunction
:echo execute("call Example()")
Just results in a blank line. The 5 is not printed. Why is ...
0
votes
1
answer
286
views
What does execute() return?
In the function-list, it gives execute() as running an ex command, but it does not seem to be returning a string as I expect.
For example, if I run this on a file that has 'abc' in it somewhere:
:...
0
votes
1
answer
308
views
How do I get a numeric return value from an Ex command?
How can I get a numeric return value from an Ex command. For example, if I want to set a variable to the number of times a pattern occurs in a buffer. I tried this:
:let answer=exe('%s/xyz//n')
but ...
2
votes
2
answers
235
views
What is the relationship between command line Ex and Vim?
I have read in various documentation that when Vim is started in Ex mode, it attempts to "act like" Ex, so I gather from this that Ex is a separate program and is not an actual part of the Vim source ...