<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Insert string at specific column in VI in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/insert-string-at-specific-column-in-vi/m-p/2885888#M869784</link>
    <description>Perfect!  Thanks for your help Mr. Brown!</description>
    <pubDate>Mon, 20 Jan 2003 19:50:59 GMT</pubDate>
    <dc:creator>Tom Weber_4</dc:creator>
    <dc:date>2003-01-20T19:50:59Z</dc:date>
    <item>
      <title>Insert string at specific column in VI</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/insert-string-at-specific-column-in-vi/m-p/2885885#M869781</link>
      <description>This is probably easy for you VI experts out there.  Say I have a file as such:&lt;BR /&gt;&lt;BR /&gt;111111&lt;BR /&gt;222222&lt;BR /&gt;333333&lt;BR /&gt;444444&lt;BR /&gt;&lt;BR /&gt;I want to insert "xx" at column 4 in each line to look like this:&lt;BR /&gt;&lt;BR /&gt;111xx111&lt;BR /&gt;222xx222&lt;BR /&gt;333xx333&lt;BR /&gt;444xx444&lt;BR /&gt;&lt;BR /&gt;I know doing a :1,$s/^/xx/ will add the "xx" to the beginning of each line but I want to insert the string at a specific column.&lt;BR /&gt;&lt;BR /&gt;I know there are other methods of doing this using other utilities, but I'm interested in just VI for this example.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance!</description>
      <pubDate>Mon, 20 Jan 2003 19:18:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/insert-string-at-specific-column-in-vi/m-p/2885885#M869781</guid>
      <dc:creator>Tom Weber_4</dc:creator>
      <dc:date>2003-01-20T19:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: Insert string at specific column in VI</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/insert-string-at-specific-column-in-vi/m-p/2885886#M869782</link>
      <description>s/\(...\)\(.*\)/\1xx\2/99999&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Mon, 20 Jan 2003 19:36:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/insert-string-at-specific-column-in-vi/m-p/2885886#M869782</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2003-01-20T19:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Insert string at specific column in VI</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/insert-string-at-specific-column-in-vi/m-p/2885887#M869783</link>
      <description>or to nail any column without counting your periods:&lt;BR /&gt;&lt;BR /&gt;:s/\(.\{3\}\)\(.*\)/\1xx\2/9999&lt;BR /&gt;&lt;BR /&gt;replacing the "3" with whatever column you want.&lt;BR /&gt;&lt;BR /&gt;You can EASILY do this with sed also:&lt;BR /&gt;&lt;BR /&gt;sed "s/\(.\{3\}\)\(.*\)/\1xx\2/" &amp;lt; filename &amp;gt; newfilename&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Mon, 20 Jan 2003 19:45:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/insert-string-at-specific-column-in-vi/m-p/2885887#M869783</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2003-01-20T19:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: Insert string at specific column in VI</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/insert-string-at-specific-column-in-vi/m-p/2885888#M869784</link>
      <description>Perfect!  Thanks for your help Mr. Brown!</description>
      <pubDate>Mon, 20 Jan 2003 19:50:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/insert-string-at-specific-column-in-vi/m-p/2885888#M869784</guid>
      <dc:creator>Tom Weber_4</dc:creator>
      <dc:date>2003-01-20T19:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Insert string at specific column in VI</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/insert-string-at-specific-column-in-vi/m-p/2885889#M869785</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You can do a '4|' using the vertical bar to take you to column four, but I don't know of any way to get that into an insert command, so you'd have to goto the column and then do the insert, and then move to the next line manually, move to the fourth column, and do a repeat on the insert.  My fingers already hurt just thinking about that method.&lt;BR /&gt;&lt;BR /&gt;Now, I know you want to do it with just vi commands, but here is a combination hack that uses a vi command to send the lines to awk to do it.  It works on lines 1 through 4 as an example:&lt;BR /&gt;&lt;BR /&gt;:1,4!(awk '{print substr($0,1,3) "xx" substr($0,3)}')&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;It's ugly, but it's one way to do it.  &lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Mon, 20 Jan 2003 19:58:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/insert-string-at-specific-column-in-vi/m-p/2885889#M869785</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2003-01-20T19:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: Insert string at specific column in VI</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/insert-string-at-specific-column-in-vi/m-p/2885890#M869786</link>
      <description>John, I didn't note this would be for a very large file not a 4 liner like my example.  I think the manual method would be palatable for a file that small but I agree it wouldn't be pleasant with say 10,000 lines : )&lt;BR /&gt;</description>
      <pubDate>Mon, 20 Jan 2003 20:05:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/insert-string-at-specific-column-in-vi/m-p/2885890#M869786</guid>
      <dc:creator>Tom Weber_4</dc:creator>
      <dc:date>2003-01-20T20:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: Insert string at specific column in VI</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/insert-string-at-specific-column-in-vi/m-p/2885891#M869787</link>
      <description>Here's a thought for you, John.  You can use the :map command to define a macro:  "map key cmd_sep".  So, if you define a macro that does your "4|" , followed by "i text" to insert the desired test, followed by a "+" for beginning of next line, all you'd have to do would be to hit you map key (over and over and over).&lt;BR /&gt;&lt;BR /&gt;Just conjecture, Harry's obviously got the ultimate solution.&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Mon, 20 Jan 2003 20:07:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/insert-string-at-specific-column-in-vi/m-p/2885891#M869787</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2003-01-20T20:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: Insert string at specific column in VI</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/insert-string-at-specific-column-in-vi/m-p/2885892#M869788</link>
      <description>Tom,&lt;BR /&gt;&lt;BR /&gt;Yeah, it would probably be a dog for a large file.  Harry's solution with the regular expression is much more elegant.&lt;BR /&gt;&lt;BR /&gt;Pete,&lt;BR /&gt;&lt;BR /&gt;I looked up the macros.  I haven't done one before but it sure would be handy.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Someday I'm gonna die and I'll be standing in front of the pearly gates.  Before they let me in, they ask me one question, "Can you write a regular expression to insert some text at a certain column?"&lt;BR /&gt;&lt;BR /&gt;Darn.   :)&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Mon, 20 Jan 2003 20:13:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/insert-string-at-specific-column-in-vi/m-p/2885892#M869788</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2003-01-20T20:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: Insert string at specific column in VI</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/insert-string-at-specific-column-in-vi/m-p/2885893#M869789</link>
      <description>I know this has been answered but wanted to share a script that I created to simplify this task a little bit.   It's not very pretty but it's easy to use.&lt;BR /&gt;&lt;BR /&gt;Syntax of script is as follow:&lt;BR /&gt;&lt;BR /&gt;sed_insert_column.sh &lt;COLUM_NUMBER&gt; &lt;FILENAME&gt; "text"&lt;BR /&gt;&lt;BR /&gt;example:   sed_insert_column.sh 4 /tmp/file1 "xx"&lt;BR /&gt;&lt;BR /&gt;Script does not save the file, redirection will be needed.&lt;BR /&gt;&lt;BR /&gt;Here's the script.  It also includes two other scripts in the file for verifying the first argument is a number.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/FILENAME&gt;&lt;/COLUM_NUMBER&gt;</description>
      <pubDate>Mon, 02 Aug 2004 15:21:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/insert-string-at-specific-column-in-vi/m-p/2885893#M869789</guid>
      <dc:creator>Jack C. Mahaffey</dc:creator>
      <dc:date>2004-08-02T15:21:07Z</dc:date>
    </item>
  </channel>
</rss>

