home
NEWS       BLOGS       FORUMS       NEWSLETTERS       RESEARCH       EVENTS       DIGITAL LIBRARY       CAREERS  
Network Computing Network Computing Powered by InformationWeek Business Technology Network

IMMERSE YOURSELF:

SOA

  |

Data Center

  |

802.11n

  |

Data Privacy

  |
APO  |

Virtualization

  |

NAC

  |

Security

  |

Network Mgmt

  |

Enterprise Apps

  |

Storage & Servers




UnixWorld Online: Tutorial: Article No. 009: Part 8: Answers

Answers to Exercises

Hint for Indentation Exercise

Using a global command can cut the length of the command sequence roughly in half. The correct way to use it depends on something I did not explicitly say about global commands, but which you should be able to guess from what I did say.

 

Answer to Indentation Exercise

A fairly simple way to handle both writing the tab-revised version of your file and keeping the original version in the editor buffer is this sequence:


:.g/^/%s/\({*\)^I^I/\1{/g|%s/^\({*\)^I/\1    /|%s/{/^I/g|w
u

The first line is pretty straightforward, excepting the initial global command. Otherwise it just replaces every pair of tabs at the start of a line with the dummy character ``{'', then changes any remaining solitary tab in the initial whitespace with four space characters, changes every dummy ``{'' to a single tab, and finally writes the file.

That initial global command seems silly, I know. It scans over just the current line, it marks that line without fail because every line has a starting point, and so it ends up running the remaining commands on the line for sure and exactly once. This is just what the command line would do without that initial global . So why is it there?

The answer is in that second line. When you run an undo after a global command, you don't just undo the last command the global ran; you undo every buffer change done by every command the global ran. (Note that the u is not preceded by a colon (``:''); it is a screen-mode command.) So as soon as the write is finished, the undo puts the entire buffer back as it was.

Print This Page


e-mail Send as e-mail





Ready to take that job and shove it?

Function:

Keyword(s):

State:
SPONSOR
RECENT JOB POSTINGS
CAREER NEWS
Go beyond Google and get vertical. These specialized search sites will help you find the business information you need -- fast.

Ari Balogh was named to the post of chief technology officer as the companys for a "realignment" of employees.










InformationWeek U.S. IT Salary Survey 2008
Salaries for business technology professionals are falling. Here's what you need to know in order to make good hiring decisions and personal career choices. Download Today
 
ROLLING RIGHT ALONG
Follow key Network Computing Reviews from conception to completion. This Week: Holistic APM.



Network Computing Reports Emerging Enterprise Podcast Series: Secrets to Success








TechSearch


Microsite of the Week


Powerful Information at Your Fingertips



InformationWeek Business Technology Network
InformationWeekInformationWeek 500InformationWeek 500 ConferenceInformationWeek AnalyticsInformationWeek CIO
InformationWeek EventsInformationWeek ReportsInformationWeek MagazinebMightyByte and SwitchDark Reading
Digital LibraryIntelligent EnterpriseInternet EvolutionNetwork ComputingNo JitterPlug Into The Cloud
space
Techweb Events Network
InteropVoiceConWeb 2.0 ExpoWeb 2.0 SummitEnterprise 2.0 ConferenceMobile Business ExpoSoftware ConferenceCSI - Computer Security Institute
Black HatGTECEnergy CampMashup CampStartup Camp
space
Light Reading Communications Network
Light ReadingLight Reading EuropeUnstrungLight Reading's Cable Digital NewsConstantinopleInternet EvolutionPyramid Research
Heavy ReadingLight Reading Live!Light Reading InsiderEthernet ExpoOptical ExpoTeleco TVTower Technology Summit
space
Financial Technology Network
Advanced TradingBank Systems & TechnologyInsurance & TechnologyWall Street & TechnologyAccelerating Wall StreetBank Systems & Technology Executive SummitBuyside Trading SummitInsurance & Technology Executive Summit
space
Microsoft Technology Network
MSDN MagazineTechNetThe Architecture Journal
space


App Infrastructure   |   Messaging & Collaboration   |   Network & Systems Mgmt   |   Network Infrastructure   |   Security  |   Storage & Servers   |   Wireless   |   Enterprise Apps
About Us  |  Contact Us  |  Site Map  |  Technology Marketing Solutions  |  Advertising Contacts  |   Briefing Centers
Copyright © 2008  United Business Media LLC  |  Privacy Statement  |  Terms of Service  |  Your California Privacy Rights