Questions tagged [ex]

ex is a line editor which serves as the foundation of vi. ex commands work on the current line or on a range of lines in a file. ex is invoked using the colon syntax within vi, and can be invoked on its own from the shell.

75 questions
1
vote
1 answer

vim: Prevent :exe from quitting after error

I have an error-checking one-liner vim command that looks like the following. It's not directly part of the question but works as an example, so feel free to ignore it: :'<,'>g/foo{.*}/exe "norm! mxf{lvt}y/\\(foo{\\)\\@!\\"\yy'xP" Here…
Miles
  • 780
  • 7
  • 19
1
vote
1 answer

Opening worksheets based on Cell names in VBA

it's my first time posting on Stack Overflow. I am trying to use VBA to get it to create a new worksheet based on a cell value in sheet 1. But if the sheet already exists I need it to open that sheet instead. I'm having difficulty with this as I…
newbie2vba
  • 25
  • 4
1
vote
0 answers

Inserting a javascript file into an existing html file using a script

After an certain html page is generated by a publishing program I want to include some javascript in the element. I am in the middle of a script setting up some parameters that are needed to run the website and wanted to include the insertion of…
E. Porter
  • 11
  • 3
1
vote
1 answer

In vim ex mode, what does @% do?

I was writing a little vim leader mapping to convert a file in (GitHub flavoured markdown) to a pdf. Both of these work, and seem to be functionally equivalent: nnoremap pdf ':! pandoc -f markdown_github --latex-engine=xelatex ' .…
patrickdavey
  • 1,966
  • 2
  • 18
  • 25
1
vote
1 answer

Using ex editor to increment a number following a pattern in a file

Am aware of how to use the ex editor in syntaxes like this answer to do minor editing of files in place. For example, as mentioned in the answer, assuming I have a file content as below:- $ cat input-file patternGoingDown foo bar foo bar Running a…
Inian
  • 80,270
  • 14
  • 142
  • 161
1
vote
1 answer

How to go back in ex mode from vi?

I'm learning vi/vim. Recently, I've faced with some uncertain point. When I run: ex somefile The ex editor opens. Ok, good. After some play I run: :vi Now I'm in normal vi mode. Everything is clear here. But the question is: How can I go back to…
Timur Fayzrakhmanov
  • 17,967
  • 20
  • 64
  • 95
1
vote
0 answers

Vim: run Ex command on specified lines, ignoring folds

When running an Ex command in Vim on range of lines, the range is always extended to cover adjacent folds (which is documented in :help fold-behavior). For example, given the following file: int foo() { foobar(); } the :2s/o//n command (i.e.…
rburny
  • 1,559
  • 1
  • 9
  • 28
1
vote
3 answers

Getting text that is on a different line, with ex in Vim

Let's say I have the following text in Vim: file1.txt file2.txt file3.txt renamed1.txt renamed2.txt renamed3.txt I want a transformation as follows: file1.txt renamed1.txt file2.txt renamed2.txt file3.txt renamed3.txt What I have in mind is…
Andreas Grech
  • 105,982
  • 98
  • 297
  • 360
1
vote
1 answer

Sort headings alphabetically using regex

I have a markdown page where the header syntax is !!!. For example: !!! Better Heading This section has a sub-heading !! Sub-Heading one !!! Can't think of another one umm... !!! A Great Heading Some text here I would like to sort the blocks of…
Brett Y
  • 7,171
  • 1
  • 28
  • 42
1
vote
3 answers

swapping characters in ex

I am pretty new to vim and ex and I was wondering if anyone could help me with an area I am fuzzy on. I would like to know how to swap characters on every line or occurrence of a pattern. For example How would I swap the first 2 characters of every…
1
vote
4 answers

Vim - regex for changing bool variable checking

I am working on a C project an I want to change all bool-variable checking from if(!a) to if(a == false) in order to make the code easier to read(I want to do the same with while statements). Anyway I'm using the following regex, which searches…
bsky
  • 19,326
  • 49
  • 155
  • 270
1
vote
1 answer

vim ex mode: copy pattern and paste at end of file?

I'm trying to automate some simple modifications to a set of files with a script using vim ex mode. What I want to do is search for a pattern, delete it from its current location (just the pattern, not the whole line), and paste it at the end of…
user1521655
  • 486
  • 3
  • 17
1
vote
3 answers

using Linux shell script to edit and rename a file

I am trying to execute a command using Vi or ex to edit a file by deleting the first five lines, replace x with y, remove extra spaces at the end of each line but retain the carraige returns, and remove the last eight lines of the file, then rename…
camarokris
  • 345
  • 1
  • 3
  • 9
1
vote
5 answers

Trying to modify file with shell script - with /bin/ex

I have an xml file I need to modify: ... I want to add some text before this line. I've tried with the simple text and it works fine (I used /bin/ex): s/<\/web-app/test &/ so I get what I want: ... test But the real text I…
Francheska
  • 295
  • 1
  • 3
  • 11
0
votes
1 answer

How to pipe the output of `program` directly to `ex` without saving it as a temp file?

I have a program which print to stdout. $ ./program > log.txt $ cat log.txt [A] 00: efbb bf52 454d 2047 454e 5245 204f 7065 10: 7261 0d0a 5245 4d20 4441 5445 2032 3031 20: 310d 0a52 454d 2044 4953 4349 4420 3235 [B] 00: 3132 4334 3134 0d0a 5245…
kev
  • 155,172
  • 47
  • 273
  • 272