# # ex (non visual vi)
APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

2005/02/10 ex

I've removed advertising from most of this site and will eventually clean up the few pages where it remains.

While not terribly expensive to maintain, this does cost me something. If I don't get enough donations to cover that expense, I will be shutting the site down in early 2020.

If you found something useful today, please consider a small donation.



Some material is very old and may be incorrect today

© February 2005 Tony Lawrence

Ex is the non-visual mode of vi, the mode that you are in when you type ":". You can enter this mode semi-permanently by typing "gQ" (return to visual mode with "vi").

Why would you want to do such a thing? Well, because if you are going to do a bunch of ex mode commands in a row, and only care about seeing the results, this is the way to do it. No more ":" to type, no waiting for the screen to redraw. Ex is "line at a time" mode: if you search for a pattern, only the first matching line displays. Press ENTER, and you see the line below it. Let's look at an example with this file:


abc def ghi
ghi abc abc
def lmn opq
abcdefghi
ghi abc abc
def lmn opq
abc def ghi
abcdefghi
ghi abc abc
def lmn opq
 

I want to go to each line with "abc", but not "abcdef", and possibly make some changes. Here's what it looks like after typing "Gq" and entering commands:

(enter vi, type gQ)
Entering Ex mode.  Type "visual" to go to Normal mode.
:set number

:/abc[^a-z]\|abc$
      2 ghi abc abc
:/
      5 ghi abc abc
:/
      7 abc def ghi
:/
      9 ghi abc abc
:/
      1 abc def ghi
:set nonumber

:vi
(screen clears)
abc def ghi 
ghi abc abc 
def lmn opq 
abcdefghi  
ghi abc abc 
def lmn opq 
abc def ghi 
abcdefghi  
ghi abc abc 
def lmn opq 

Bruce Garlock reminded me that /\<abc\> also finds abc in the same way.

Ex mode is also useful when you have sub-standard terminal emulation and the screen gets messed up because of it. Having lines displayed one at a time can be much less confusing.

If you found something useful today, please consider a small donation.



Got something to add? Send me email.





(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

->
-> ex (non visual vi)


Inexpensive and informative Apple related e-books:

Take Control of Parallels Desktop 12

Take Control of iCloud

Take Control of the Mac Command Line with Terminal, Second Edition

iOS 8: A Take Control Crash Course

Take Control of Preview





More Articles by © Tony Lawrence





Printer Friendly Version

Have you tried Searching this site?

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us


Printer Friendly Version





Technology is anything that wasn’t around when you were born. (Alan Kay)




Linux posts

Troubleshooting posts


This post tagged:

Administration

Shell



Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode