mark block from unknown position

2007-04-12 Thread meino . cramer
Hi,

 I am trying to automate this:

 There is a file, which contains one path/filename at each line.
 Lines with equal files (contents wise) are grouped together.  Groups
 are separated by # ---' (or whatever you want).

 To sort the lines of one group only I want to put the group into a
 visual block (correcht naming?) as part of a macro.

 First step of the macro will be the search for a certain directory.
 Next will be the creation of the visual block.  Since I dont know,
 whether the line containing the searched directory cames first in the
 group or last or wherever, and how large the group is, I cannot do
 things like mark next 3 lines or so.

 Now I am looking for the command doing mark this group visually.

 How can I acchieve this?

 Another question is: If I have created a useful macro -- is there
 a way to store this macro in .vimrc (or wherever) so that it does
 not get lost ?

 Thank you very much in advance for any help ! :)

 Keep editing!
 mcc



-- 
Please don't send me any Word- or Powerpoint-Attachments
unless it's absolutely neccessary. - Send simply Text.
See http://www.gnu.org/philosophy/no-word-attachments.html
In a world without fences and walls nobody needs gates and windows.


Re: mark block from unknown position

2007-04-12 Thread Jürgen Krämer

Hi,

[EMAIL PROTECTED] schrieb:
 
  I am trying to automate this:
 
  There is a file, which contains one path/filename at each line.
  Lines with equal files (contents wise) are grouped together.  Groups
  are separated by # ---' (or whatever you want).
 
  To sort the lines of one group only I want to put the group into a
  visual block (correcht naming?) as part of a macro.

you don't need a visual block here. Say you have the following file

  # ---
  3.txt
  2.txt
  1.txt
  # ---
  6.txt
  5.txt
  4.txt
  # ---
  9.txt
  7.txt
  8.txt
  # ---

Then

  :g/^# ---/+1,/^# ---/-1!sort

will sort it by file names inside your groups. This command will emit
an error message E16: Invalid range for the last marker, which you
can safely ignore.

Regards,
Jürgen

-- 
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)


Re: mark block from unknown position

2007-04-12 Thread Jürgen Krämer

Hi,,

[EMAIL PROTECTED] wrote:
 
 J?rgen Kr?mer [EMAIL PROTECTED] [07-04-12 13:12]:
 Hi,

 [EMAIL PROTECTED] schrieb:
  I am trying to automate this:

  There is a file, which contains one path/filename at each line.
  Lines with equal files (contents wise) are grouped together.  Groups
  are separated by # ---' (or whatever you want).

  To sort the lines of one group only I want to put the group into a
  visual block (correcht naming?) as part of a macro.
 you don't need a visual block here. Say you have the following file

   # ---
   3.txt
   2.txt
   1.txt
   # ---
   6.txt
   5.txt
   4.txt
   # ---
   9.txt
   7.txt
   8.txt
   # ---

 Then

   :g/^# ---/+1,/^# ---/-1!sort

 will sort it by file names inside your groups. This command will emit
 an error message E16: Invalid range for the last marker, which you
 can safely ignore.

  Thanks for your reply ! :)

  Sort was only an example...is it possible
  to mark the group visually ?

yes. While in normal mode enter

  /^# ---/+CRV/^# ---/-

where CR means Press the Return/Enter key. After that the lines
between two consecutive markers are visually selected.

Regards,
Jürgen

-- 
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)