Linked Questions

10
votes
2answers
2k views

How can you use vim as a stream editor? [duplicate]

Like most programmers, I perform a lot of repetitive tasks. In optimising my workflow, I'm taking some of those repetitive tasks, and refactoring them into shell scripts. One thing that I'm trying to ...
139
votes
9answers
48k 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 ...
32
votes
5answers
3k views

Terminal borked after invoking Vim with xargs

I've sometimes tried invoking Vim using xargs, like this: find . -name '*.java' | xargs vim … which kind of works: As Vim launches, I see the following warning flash briefly: Vim: Warning: Input ...
17
votes
4answers
5k views

How to edit content from the standard input?

I would like to edit content in vim which was dynamically generated from the command-line without having the file yet. In example: $ echo This is example. | vim /dev/stdin $ cat /etc/hosts | vim /dev/...
13
votes
4answers
2k views

How to reverse every 4 lines?

First of all, with this being my first post here, I'd just like to say that I've found VIM to be a great tool and the forum here to be very helpful in finding answers to questions, with lots of ...
12
votes
2answers
4k views

How can I run a function or macro across a folder of files?

Let's say I have a function, named StripWhitespace. I can run it on a single file by opening the file and running :StripWhitespace. How can I automatically run that function against a folder of ...
10
votes
2answers
3k 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 ...
4
votes
2answers
2k views

How to use “-c” command line option?

Fully realizing the heritage of vi, I know that its predecessor (ex) could be, and was, used for command line processing of files ("sed-style", if you like). The manpage says: -c {command} {...
2
votes
1answer
555 views

How to remove inner content of html tag conditionally?

I've html file (e.g. curl -o page.html http://example.com/) where I would like to remove inner html block for given html tag. I've the following code which works: $ ex -V1 page.html <<-EOF /&...
2
votes
1answer
183 views

argdo command hanging

I am interested in editing multiple files. Using this answer: How to edit files non-interactively (e.g. in pipeline)? I came up with my own test case: seq 10 14 | tee pa.txt > qu.txt ex -sc '...
1
vote
1answer
52 views

Attempt to create a buffer output script

I'm in a Linux class right now and the question was brought up as to if there was a command to see what's in your buffer list inside vi. I searched online to see if I could find anything, but found ...