Legal way to inhibt saveing of a buffer

2007-06-03 Thread meino . cramer
Hi,

 I want to hook a function into the saveing
 process of a file.
 This function will test certain conditions
 and according to the result should make
 saveing of the file impossible for
 the moment.
 I want to avoid things like false error
 messages like File is set readonly.

 Is there a way to accomplish this ?

 Thank you very much for any help in advance!
 Keep vimmering! :)
 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.


Really stupid question...

2007-05-22 Thread meino . cramer
Hi,

 I may become blinded by to often looking for too long
 onto my monitor, but...

 I am trying to write a simple function, which searches through
 the whole buffer to fund a certain pattern and stops searching
 when found the first match. I also want the function to 
 return a matched/not matched return code and given the caller
 the line/column of the match if found.

 But all I are errors...

 Thank you very much for any helpful hint...

 Slightly frustrated,
 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.


Blocking of save

2007-05-09 Thread meino . cramer
Hi,

 is there a way to disabling the saveing and writing of/to a file
 and leaving of vim until a certain condition of the contents of
 the file is not given (in this case certain characters are not
 allowed as contents of the file)?
 The whole thing should only be active for a C-/C++-Files.

 Thanks a lot for any help in advance!
 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.


...to shoot into oneelse feet...

2007-04-30 Thread meino . cramer
Hi,

 is it possible to get out of a started
 change command (dont know, whether this
 is this the correct naming...) with a single
 key pressed ?

 For example the text is

Vim is a #eally$nice editor.
 

 # is marking my cursor position and $
 is the sign appearing after I have submitted
 cfn already.

 Since vim is really a nice editor, I do not
 want to change anything and pressed cfn by
 accident.

 HmmmESC kills everything between # and $...
 u would undo it...but this like do the wrong thing
 and repair it afterwards.

 What I want is to prevent doing wrong things by aborting
 them,..not to do them and saying ooops sorry...my fault
 afterwards and starting repairing the desaster then... :)

 Sohow can I _abort_ this ?

 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.


...curiosity

2007-04-29 Thread meino . cramer
Hi,

 I am curious whether this kind of meta-regexp is
 possible with vim:

 I want to match a certain kind of pattern and want to
 do something with it.
 
 The kind of pattern does not describe a group of chars
 but their relation to each other.

 Example:
 I want to search for a number sequence like
 1221
 and also
 2332
 and also
 3443
 and also

 Or:
 I want to find a sequence of five identical characters. The 
 character itsself doesn't matter.

 There is no limit to complexity of this kind of pattern. The only
 limit seems to be my brain.

 Is there a kind of general recipe to construct such patterns and
 to instruct vim to use them as wanted ?

 Happy 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.


Avoiding German Umlauts....

2007-04-27 Thread meino . cramer
Hi,

 I want to write a macro, function or what else, which ensures, that
 no german umlauts (äöüÄÖÜ) or the sz (ß) will ever occure in any
 file written with vim. It does not matter, if these charactes will
 appear while typing but they should never and under no circumstances
 be saved to disk. Best solution however would be, if they were
 changed on the fly to their replacements:
 
 umlaut a ä - ae
 umlaut o ö - oe
 umlaut u ü - ue

 umlaut A Ü - Ae
 umlaut O Ö - Oe
 umlaut U Ü - Ue

 sz ß - sz

 I did some experiments, which had worked under some circumstances and
 did not under others.
 But I need something, which does the replacements under any
 condition.
 
 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.


Lost in Space

2007-04-22 Thread meino . cramer
Hi,

Suppose I have a text like this (:set list)

Hello  $
this  $
is$
a $
text with $
spaces  $

and want it to become this one:

Hello  = 
this   = 
is =  
a  =  
text with  =   
spaces =

. I tried different cpoptions combined with
blcok-seelcting in visual mode, but I failed
and ended up adding spaces by hand in each line,
which isn't efficent that much ;)

I set virtualedit=block.

What do I have to tell vim that it will recognize
missing spaces and add it according to a block
select?

By the way: I am using vim on Gentoo linux as console
applikation only (no gvim).

Thank you very much in advance for any helpful space! ;)

Kind regards and have a nice sunday!
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.


Describe-key ?

2007-04-15 Thread meino . cramer
Hi,
 
 is there anything like describe-key (EMacs)in vim ?

 In EMacs vou can submit this command, press a combination
 of keys and EMacs will tel you the naming convention
 of this key (for example Meta-p) and its current
 bindings of that combination of keys.

 Anything like that in vim ?

 Would help a lot :)

 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.


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.


Finding something conatined in two lines?

2007-04-12 Thread meino . cramer
Hi,

 Suppose there is a file containing a path/filename -- in each line:

 #
 a.txt
 b.txt
 c.txt
 #
 1.txt
 2.txt
 3.txt
 4.txt
 #
 1.txt
 3.txt
 4.txt
 #

 Now I want to replace any combination of
 1.txt
 2,txt
 by - say - 
 x.txt

 Is there a way to expand / of two/more lines ?

 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.


meta offtopic: UTF-8/vim/mutt/mrxvt

2007-04-12 Thread meino . cramer
Hi,

 sorry for this meta offtopic question...but I need informations about
 some internals of vim...

 I am using mutt to compose and read mail. The editor for this is vim
 (surprised? :) Mutt/Vim are running on/in/at/on top off/with (or what
 else the correct preposition is... X-) mrxvt. And all this is running
 on a Linux 2.6.20.6 Gentoo Linux.

 Now: When I am receiving mail containing german umlauts, they will be
 displayed as \number inside mutt.  Inside vim these mails are
 displayed correctly when cited -- most of the times. But in some
 cases the umlauts also get corrupted.

 Entering umlauts in vim is also no problem.

 Entering umlauts on the commandlind (zsh/mrxvt) also displayed them
 correctly. Filenames containing umlauts are displayed...hrmmm...
 encrypted but will be correctly expanded (TAB) when using the zsh
 completion system.

 These mix of it works and it does not work confuses me.  Would
 vim be able to display german umlauts correctly if the system
 completly ignores/does not know of  UTF-8 ?

 What is the trick I am missing to display german umlauts correctly
 with mutt? There are recipes out there in the internet which
 discribes the _complete_ change from ASCII to UTF-8 for mutt. But
 these recipes describes more or less the change either on base of a
 totally UTF-8 aware system (which seems not applicable in my case) or
 the a complete recompilation of the whole system as a migration 
 from ASCII to UTF-8 ... which seems not to be needed in my case.

 The basic question is for me: How can vim display german umlauts
 correctly if the world outside of vim seems not to be completly
 UTF-8 aware? What do I need to change in the chain ?

 Thank you very much for your help in advance!
 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.


replace word from buffer

2007-04-06 Thread meino . cramer
Hi,

 is there a way to do this more effectively?

 I often get in the situation of yanking a word
 into the buffer, search another word I want to
 replace with the contents of the buffer, delete
 the found word and paste the contents of the buffer
 at the place of the previously found word.

 Despite the fact, that -- without the yank-ring
 script -- you have to keep an eye on what is
 in what buffer, it would be more effective
 if one could do the following:
  
 ywyank replacement word
 /word find word (word) to be replaced
 cwchange word under cursor with that in buffer

 I know, that cw is another command, which is wrong in 
 this case...I only needed a name for what I want to do and
 cw keeps track of the length of the replaced word and the
 replacement.

 Thank you very much for any helpful hint :)   !

 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.


Vim freezes system ?!

2007-04-06 Thread meino . cramer
Hi,

 I did th3 follwing: With a program, which generates random numbers in
 different formats, I created a file, which consists of _one_ line of
 2097152 characters (0-9,A-F).

 To split the line into lines of 72 characters each, I started vim and
 let it read the file.

 I postioned the cursor at position 0 and entered the following in
 normal mode:

 qq72rightireturnesc0q

 Then I did a 

 [EMAIL PROTECTED]

 After only 10 or 15 (guessed) executions of the macro the system
 freezes while constantly swapping (?) and became unuseable and did no
 longer respond.

 Even the mouse pointer was nearly unmoveable...

 After heavily and constantly trying I managed to kill the X-session
 and to 'killall -9 vim' from the console to get back my computer.

 I am using an up-to-date version of Gentoo and vim (not gvim).  My
 system runs an AMD 64 X2 3800+ CPU and uses a Seagate 200GB harddisk
 (dma enabled). It needs a lot of load to bring the system to its
 knees.

 May be it was wrong what I did in the sense of there are better
 UNIX tools to reformat such a file or better commands in vim to
 accomplish this,...

 ...but in a critical moment it may be that I would have lost my work
 (other open applikations) due to the need of killing X.


 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.