Re: taglist: "ctrl ]" & azerty

2007-05-24 Thread Jürgen Krämer

Hi,

Mathieu Malaterre wrote:
> 
>   I am trying to use taglist on my AZERTY keyboard and I cannot get
> ctrl ] to work. If I type :ts + tagname I can see that taglist is
> working.

this depends heavily on the operating system you use and the installed
keyboard driver. For me on Windows XP with a German keyboard pressing
+<+> works. It seems that ctrl-combinations that do not involve
alphabetic keys but only symbols have not moved from their original
position on an english/american keyboard, e.g., +<ü> is
equivalent to +<[> and +<6> is the same as +<^>.

You might try to press  and the rightmost key in the AZERTY row.

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: vim | delete consecutive occurrences of a pattern

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

Hi,

Nikolaos A. Patsopoulos wrote:
> Tim Chase wrote:
>>> I have a text that has many occurrences of a pattern . I want to delete 
>>> every consecutive occurrence, e.g.
>>>
>>> Pattern Pattern other text Pattern Pattern Pattern Pattern other text 
>>> Pattern Pattern Pattern
>>> should look like this:
>>> Pattern other text Pattern other text Pattern
>>>
>>> I've used:
>>>
>>> :%s/\(Pattern\s\+\)\(Pattern\)/\1/g
>>>
>>> but have to run this more than once with: %&g to result the wanted text.
>>>
>>> Can I do this with one command only? If not can I write a while function?:
>>> 
>> You seem to be close.  The following did it for me,
>>
>>   :%s/\(Pattern\)\(\s\+Pattern\)\+/\1/g
>>
>> or, if you're lazy,
>>
>>   :%s/\(Pattern\)\(\s\+\1\)\+/\1/g
>>
>> (no need to type the Pattern a 2nd time)
>
> I tried Jorgen' s code (all possible ways) but I still had to run the 
> command more than once.

strange, the only difference between Tim's and my versions where the \+
he used after the second parenthesis and the * I used. As both \+ and *
are greedy, this should not make a difference for the final result, only
maybe in speed.

Just out of curiosity could you show me/us the exact command you used?

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: vim | delete consecutive occurrences of a pattern

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

Hi,

Nikolaos A. Patsopoulos wrote:
> 
> I have a text that has many occurrences of a pattern . I want to delete 
> every consecutive occurrence, e.g.
> 
> Pattern Pattern other text Pattern Pattern Pattern Pattern other text 
> Pattern Pattern Pattern
> should look like this:
> Pattern other text Pattern other text Pattern
> 
> I've used:
> 
> :%s/\(Pattern\s\+\)\(Pattern\)/\1/g
> 
> but have to run this more than once with: %&g to result the wanted text.
> 
> Can I do this with one command only?

if you want to remove multiple occurrences of the same *pattern*, use

  :%s/\(Pattern\)\(\s\+Pattern\)*/\1/g

But if you want to remove multiple occurrences of the same *text*, use

  :%s/\(Pattern\)\(\s\+\1\)*/\1/g

There is a noticeable difference if your pattern is not a simple text
but a more complex regular expressions, e.g.

  :%s/\(\d\+\)\(\s\+\d\+\)*/\1/g

would turn

  42 00 00 00 43 00 00 00

into

  42

while

  :%s/\(\d\+\)\(\s\+\1\)*/\1/g

would result in

  42 00 43 00


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: join all lines inside pattern that occurs more than once

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

Hi,

Nikolaos A. Patsopoulos wrote:
> 
> I want to join all lines that are inside a given pattern and occurs more 
> than once  in the text, ie:
> 
> 
> PatternStart 
> text1
> text2
> ...text3
> ..text4
> PatternEnd
> ...
> ...
> 
> 
> PatternStart 
> text1
> text2
> ...text3
> ..text4
> ...
> ...textn
> PatternEnd
> 
> 
> 
> ...
> PatternStart text1text2...text3..text4PatternEnd
> 
> 
> 
> PatternStart text1text2...text3..text4......textnPatternEnd
> 
> 
> 
> I tried to use:
> :g/PatternStart\_.\{-}PatternEnd/ J
> 
> but this joins only first and second line of the pattern.
> 
> How can I tell vi to join all lines inside all occurrences of this 
> pattern with variable containing lines?

the pattern you supplied only specifies a single line range. If you want
to join a whole block you must give a start address and an end address,
e.g.

  :g/PatternStart/,/PatternEnd/j

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: Getting rid of indents

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

Hi,

Tomas Pihl wrote:
>
> As a convert from the dark side, I'm still learning Vim and have started to 
> use
> it for editing mails (from mutt) to get some practice. One thing that I 
> haven't
> managed to find is how I get rid of the (what I think) is some smart indenting
> after ( , ), / and , So if I type
> 
>   Hello all,
> 
> and press return, I end up under "a" but I really want to be under "H". What
> can I do to make this happen?

probably the cindent option is set. You can check this (and from where
it has been set) with

  :verbose set cindent?

(Note the trailing question mark.) This should give you the name of a
script file. To unset this option you can either remove the offending
line from this file or, if you want to deactivate this option only for
mails, put the line

  set nocindent

in a mail filetype plugin, e.g. ~/.vim/after/ftplugin/mail.vim.

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: Finding something conatined in two lines?

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

Hi,

[EMAIL PROTECTED] wrote:
> 
>  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 ?

you can represent an end-of-line inside a regular expression with \n

  :%s/^1\.txt\n2\.txt$/x.txt/

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

  /^# ---/+V/^# ---/-

where  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)


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: script boolean operators

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

Hi,

Horvath Adam wrote:
> 
> I can not find (manual, list-archiv, google) how to use boolean
> operators (and, or) in script.
> 
> I prefer this:
> if i>500 and i<1000

"boolean and" is written as "&&" and "boolean or" is written as "||". So
your example becomes

  if i>500 && i<1000.

> One working solution:
> 
> normal G
> let numberofrows = line(".")
> normal gg
> let i = 1
> while i<=numberofrows
> if i>500
> if i<1000
> " do something
> endif
> endif
> let i += 1
> endwhile
> 
> Any other way?

  normal G
  let numberofrows = line(".")
  normal gg
  let i = 1
  while i<=numberofrows
  if i>500 && i<1000
  " do something
  endif
  let i += 1
  endwhile

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: copy pasting HTML code into vim

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

Hi,

me wrote:
> 
> actually, the selected HTML code might be available from the clipboard.
> E.g., both Firefox and Internet Explorer put it there in multiple
> formats. The following are lists of the available formats after copying
> from FF and IE, respectively:
> 
>   49161: DataObject
>   49422: text/html
>   49366: HTML Format
>   49776: text/_moz_htmlcontext
>   49778: text/_moz_htmlinfo
>  13: CF_UNICODETEXT
>   1: CF_TEXT
>   49171: Ole Private Data
>  16: CF_LOCALE
>   7: CF_OEMTEXT
> 
>   49161: DataObject
>   1: CF_TEXT
>  13: CF_UNICODETEXT
>   49366: HTML Format
>   49330: Rich Text Format
>   49171: Ole Private Data
>  16: CF_LOCALE
>   7: CF_OEMTEXT
> 
> The formats starting with CF_ are pre-defined clipboard formats, the
> remaining ones are registered through Windows' RegisterClipboardFormat()
> function. I don't know how widely understood they are, but at least
> Microsoft Word is able to render headlines and other HTML-formatting
> instructions when text copied from Firefox is pasted into a document.
> It seems, the clipboard object associated with "HTML Format" contains
> enough information for correct rendering.
> 
> A different point is how to access the HTML content in VIM. I doubt it
> would be a good idea to always paste the HTML source when accessing the
> clipboard through the + or * register. Probably a "pasteclipboard()"
> function which takes an argument for determining the preferred format
> would be a better way. This function function could then be used inside
> a mapping whenever a VIM user wants to paste the original HTML source.

sorry, I forgot to mention explicitly that this is totally Microsoft
Windows-centric. But I think other OSs might also support multiple
formats on the clipboard.

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: copy pasting HTML code into vim

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

Hi,

A.J.Mechelynck wrote:
>
> Kamaraju S Kusumanchi wrote:
> >
> > Let's say I open up a webpage, select some text and paste it into vim. Then
> > all I see in vim is the text I see on the browser. While this is OK most of
> > the times, sometimes I wish there is a way to paste the actual HTML code
> > directly into the vim.
> >
> > Selecting "view source of the webpage" and then copy pasting into vim will
> > work. But it is very cumbersome and time consuming. So this is not an
> > option for me.
> >
> > Currently the editor in docs.google.com does what I need, Is there any way
> > the same can be achieved by vim?
> 
> Vim cannot get from the clipboard what isn't there: when you select text in a 
> browser (other than in View Source), what gets put onto the clipboard is the 
> text, not the source; IOW, the formatting tags aren't there.

actually, the selected HTML code might be available from the clipboard.
E.g., both Firefox and Internet Explorer put it there in multiple
formats. The following are lists of the available formats after copying
from FF and IE, respectively:

  49161: DataObject
  49422: text/html
  49366: HTML Format
  49776: text/_moz_htmlcontext
  49778: text/_moz_htmlinfo
 13: CF_UNICODETEXT
  1: CF_TEXT
  49171: Ole Private Data
 16: CF_LOCALE
  7: CF_OEMTEXT

  49161: DataObject
  1: CF_TEXT
 13: CF_UNICODETEXT
  49366: HTML Format
  49330: Rich Text Format
  49171: Ole Private Data
 16: CF_LOCALE
  7: CF_OEMTEXT

The formats starting with CF_ are pre-defined clipboard formats, the
remaining ones are registered through Windows' RegisterClipboardFormat()
function. I don't know how widely understood they are, but at least
Microsoft Word is able to render headlines and other HTML-formatting
instructions when text copied from Firefox is pasted into a document.
It seems, the clipboard object associated with "HTML Format" contains
enough information for correct rendering.

A different point is how to access the HTML content in VIM. I doubt it
would be a good idea to always paste the HTML source when accessing the
clipboard through the + or * register. Probably a "pasteclipboard()"
function which takes an argument for determining the preferred format
would be a better way. This function function could then be used inside
a mapping whenever a VIM user wants to paste the original HTML source.

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: VIM Delete All Except

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

Hi,

jas01 wrote:
> I have a huge file where I need to delete all lines except for a few I need.
> I'm trying to do this in a single command.
> 
> I know that:
> 
> :v/Text/d 
> 
> will delete all lines except for ones containing 'Text.' I have no idea how
> to put multiple strings so the command deletes everything except for 'Text'
> and 'Text2' and 'Text3'.

use  \|  in the search pattern

  :v/Text\|Text2\|Text3/d

See

  :help /\|

for more information.

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: autocmd bug?

2007-03-27 Thread Jürgen Krämer

Hi,

A.J.Mechelynck wrote:
> Jürgen Krämer wrote:
> [...]
>> Nice idea (esp. the recursion), but alas it's not that simple, because
>> the pattern only accepts wildcards (not regular expressions) and if it
>> did, the subpatterns would probably not be recognized in the command.
>> But your command gave me an idea -- the following should work
>>
>>   au FileType *.* exe substitute(expand(''),
>>   \  '^\(.*\)\.\(.*\)$',
>>   \  'doau FileType \1 | doau FileType \2',
>>   \  '')
>>> ('cindent' is set by the indent/c.vim plugin).
>> Regards,
>> Jürgen
>>
> 
> additional question: does ":doau" work in an autocommand or does it require a 
> "nested" flag somewhere?

>From the example at ":help doautocmd" it seems that an additional
"nested" is not needed. I also tested it by defining the following
autocommand:

  au FileType * echo expand('')

The result of executing

  setf c.doxygen

was

  c.doxygen
  c
  doxygen

So I'd say "nested" is not needed.

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: autocmd bug?

2007-03-27 Thread Jürgen Krämer

Hi,

A.J.Mechelynck wrote:
> Jürgen Krämer wrote:
> [...]
>> the FileType event is only fired once with the exact filetype you
>> specified in your set command, so you must additionally define the
>> following autocommand:
>>
>>   autocmd FileType c.doxygen setlocal cindent number cursorline
> 
> If that is true, doesn't it defeat the purpose of setting the filetype with a 
> dot?

I'm not sure -- at least it seems to be a little bit inconsistent to
me, because ":help 'filetype'" explicitly mentions filetype plugins and
syntax files:

| When a dot appears in the value then this separates two filetype
| names.  Example:
|   /* vim: set filetype=c.doxygen : */ ~
| This will use the "c" filetype first, then the "doxygen" filetype.
| This works both for filetype plugins and for syntax files.  More than
| one dot may appear.

So, moving the ":setlocal" commands from the autocommand to a filetype
plugin would work, but there seem to be a lot of people that want to
keep their settings in one single place -- namely ~/.vimrc -- to make
it simpler to exchange them between multiple installations.

> Or should we add something like (untested)
> 
>:au Filetype \(w*\).\(\S*\) exe "doau FileType \1" | exe "doau FileType \2"
> 
> ?

Nice idea (esp. the recursion), but alas it's not that simple, because
the pattern only accepts wildcards (not regular expressions) and if it
did, the subpatterns would probably not be recognized in the command.
But your command gave me an idea -- the following should work

  au FileType *.* exe substitute(expand(''),
  \  '^\(.*\)\.\(.*\)$',
  \  'doau FileType \1 | doau FileType \2',
  \  '')
> 
> ('cindent' is set by the indent/c.vim plugin).

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: autocmd bug?

2007-03-26 Thread Jürgen Krämer

Hi,

Michael Wookey schrieb:
> I have the following  in my .vimrc:
> 
> filetype plugin indent on
> autocmd FileType c,h,cpp,hpp,cs setlocal cindent number cursorline
> 
> If I have a new buffer and set the filetype as follows, everything works
> just fine:
> 
> :set filetype=c
> 
> However, if I have a new buffer and I set the filetype like this, the
> autocmd doesn't fire:
> 
> :set filetype=c.doxygen
> 
> This syntax is described in:
> 
> :help 'filetype'
> 
> The result is that I don't get cindent, number or cursorline set.
> 
> I actually noticed this behaviour when a modeline in a C file set the
> filetype to 'c.doxygen' and my options didn't appear.
> 
> Does this work for anyone else or is it just my settings messing
> something up?  Vim build details are below.

the FileType event is only fired once with the exact filetype you
specified in your set command, so you must additionally define the
following autocommand:

  autocmd FileType c.doxygen setlocal cindent number cursorline

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: Best way to repeat a sequence of keystrokes/commands with a single keypress ?

2007-03-09 Thread Jürgen Krämer

Hi,

Ivan Vecerina wrote:
> 
> I sometimes want to repeat a sequence of operations
> like I would repeat a single command.
> For example, I can repeat with '.' something like:
>  gI//{is a single operation '.' repeats all}
> But I cannot as easily repeat:
>  02r/{ '.' will repeat the 2r/ , but not the move to 0 }
> 
> [ Let's not focus on the example sequence I am using here,
>   I do know that there are other ways to comment a line ]
> 
> The obvious choice to repeat multiple operations is to record
> a macro (for example:  qq02r/q ), and replay it with @q.
> Unfortunately, '.' after @q only replays the last action
> within the macro, not the whole macro execution.
> So I have to repeatedly type two awkward keys (@q) instead
> of being able to use the dot command to repeat the whole
> sequence of operations.
>  [ I wonder why this behavior was chosen. Is there any
>way to have '.' repeat the whole macro instead ?]

you can use @@ to repeat the execution of the last macro.

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: :!start command: need to be root

2007-02-14 Thread Jürgen Krämer

Hi,

Régis B. wrote:
> 
> I use gVim on a Linux computer (KUbuntu), and I am trying to launch a
> program from inside gvim with the !start command, so for instance:
> 
> :!start kdvi
> or
> :!start /usr/bin/kdvi
> 
> But I get the following error:
> start: need to be root
> shell returned 1
> 
> So obviously I need to be root to execute commands from inside gvim, which
> is extremely weird.
> 
> You guys have any idea how to solve this?

I don't know what the "start" command on Linux does, but would it not
suffice to execute

  :!/usr/bin/kdvi

without start?

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: How to diff in gvim

2007-02-13 Thread Jürgen Krämer

Hi,

Naim Far wrote:
> 
>   Does anyone know how to do "vert diffsplit" between two buffers?!
> When using diffsplit I have to supply the full path of the second
> comparison file, what if I simply want the comparison to be done with
> another already opened buffer?!

execute

  :diffsplit

in both buffers.

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: Workspace concept ala TextPad

2007-02-07 Thread Jürgen Krämer

Hi,

A.J.Mechelynck wrote:
> Eric Leenman wrote:
>>
>> I read on the script that I need to follow the 6 points mentioned.
>>
>> [start of point 1]
>> 1. Download the workspace.zip file and unzip the files to the $HOME/.vim 
>> or the $HOME/vimfiles or the $VIM/vimfiles directory. This should unzip 
>> the following two files (the directory structure should be preserved):
>>
>>  plugin/workspace.vim - main workspace plugin file
>>  doc/workspace.txt- documentation (help) file
>>
>>   Refer to the 'add-plugin', 'add-global-plugin' and 'runtimepath'
>>   Vim help pages for more details about installing Vim plugins.
>> [end of point 1]
>>
>> What I did:
>> Download the zip file:
>> And stored
>> workspace.txt is stored in C:\Program Files\Vim\vimfiles\doc
   
>> workspace.vim C:\Program Files\Vim\vimfiles\plugin
  
>>
>> Is this OK?
> 
> No. These directories are only for what comes bundled with Vim. You should 
> not 
> change anything there, because any upgrade (maybe tomorrow, maybe next year) 
> may silently undo whatever changes you had made.

sorry to correct you, Tony, but I think you missed the "vimfiles" part of
those paths. C:\Program Files\Vim\vimfiles is used for system-wide
configuration files, not for files bundled with Vim.

[snip]

>> [start of point 2]
>> 2. Change to the $HOME/.vim/doc or $HOME/vimfiles/doc or
>>   $VIM/doc/vimfiles directory, start Vim and run the ":helptags ."
  
Those directories are swapped -- it should have read $VIM/vimfiles/doc.

>>   command to process the workspace help file.
>> [end of point 2]

An easier way to update the tags file is to just start Vim and enter

  :helptags $HOME/.vim/doc
  :helptags $HOME/vimfiles/doc

or

  :helptags $VIM/vimfiles/doc

In you case -- because C:\Program Files\Vim corresponds to $VIM -- the
third one is the correct one. After that, :help workspace should work.

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: / with grouping ([]) and word character abrev (\w)

2007-02-07 Thread Jürgen Krämer

Hi,

Thomas Michael Engelke wrote:
> 
> I'm trying to use a regex for searching in a file. I noticed that
> inside square brackets \w seems to loose all magical matching
> abilities. Is there a way to reverse that loss or do I have to specify
> everything inside [] explicitly?

yes, inside [] backslashes don't start a character class but may only be
used to denote special characters:

  \e
  \t
  \r(NOT end-of-line!)
  \b
  \nline break, see above |/[\n]|
  \d123 decimal number of character
  \o40  octal number of character up to 0377
  \x20  hexadecimal number of character up to 0xff
  \u20AChex. number of multibyte character up to 0x
  \U1234hex. number of multibyte character up to 0x

There is a different notation to denote character classes inside brackets:

  [:alnum:] letters and digits
  [:alpha:] letters
  [:blank:] space and tab characters
  [:cntrl:] control characters
  [:digit:] decimal digits
  [:graph:] printable characters excluding space
  [:lower:] lowercase letters (all letters when
'ignorecase' is used)
  [:print:] printable characters including space
  [:punct:] punctuation characters
  [:space:] whitespace characters
  [:upper:] uppercase letters (all letters when
'ignorecase' is used)
  [:xdigit:]hexadecimal digits
  [:return:]the  character
  [:tab:]   the  character
  [:escape:]the  character
  [:backspace:] the  character

So instead of [\w] you should use [[:alpha:]] (note the double
brackets).

You can find more on brackets in regular expressions with

  :help /[]

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: break option lines

2007-02-06 Thread Jürgen Krämer

Hi,

[EMAIL PROTECTED] schrieb:
> 
> is it possible in a vimrc for comma separated
> option strings like this one below to break:
> 
> set
> dictionary=$VIM\SQLDict\BPMS_Stamm.txt,$VIM\SQLDict\BPMS_Mandant.txt,$VIM\SQL
> Dict\CBS_2005.txt,$VIM\SQLDict\ICCS_Net_Strommixer.txt,$VIM\SQLDict\DBS.txt,$
> VIM\SQLDict\cbsbestenergy.txt,$VIM\SQLDict\iccs_2005.txt... many other
> files..

if you want to break a long line you must write a backslash as the
first non-white-space character on every but the first line

  set dictionary=$VIM\SQLDict\BPMS_Stamm.txt,
\$VIM\SQLDict\BPMS_Mandant.txt,
\$VIM\SQLDict\CBS_2005.txt,
\$VIM\SQLDict\ICCS_Net_Strommixer.txt,
\$VIM\SQLDict\DBS.txt,
\$VIM\SQLDict\cbsbestenergy.txt,
\$VIM\SQLDict\iccs_2005.txt

Or you can use multiple set-commands, the first with a single "=" and
the rest with "+=":

  set dictionary=$VIM\SQLDict\BPMS_Stamm.txt
  set dictionary+=$VIM\SQLDict\BPMS_Mandant.txt
  set dictionary+=$VIM\SQLDict\CBS_2005.txt
  set dictionary+=$VIM\SQLDict\ICCS_Net_Strommixer.txt
  set dictionary+=$VIM\SQLDict\DBS.txt
  set dictionary+=$VIM\SQLDict\cbsbestenergy.txt
  set dictionary+=$VIM\SQLDict\iccs_2005.txt

If the option is a comma separated list VIM takes care of the commas.

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: jump from word to word

2007-01-30 Thread Jürgen Krämer

Hi,

Claus Atzenbeck wrote:
> On Tue, 30 Jan 2007, Roy Fulbright wrote:
> 
>> Try using capital "W" instead.
> 
> Thanks, this helps. I read about it when I started using Vim, however,
> apparently I forgot that.

note that "W" uses Vim's definition of WORD, i.e., any sequence of
non-blank characters separated by white space is considered to be a
WORD. In practice this means that "W" will not stop at commas, dots,
exclamation marks, quotes, etc. It might be better to

  :set iskeyword=@,48-57,_,192-255

which considers all characters where the C runtime function isalpa()
returns TRUE, all digits, the underscore, and all characters in the
range from 192 to 255 to be part of a word. Then "w" should work as
wanted.

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: jump from word to word

2007-01-30 Thread Jürgen Krämer

Hi,

Claus Atzenbeck wrote:
> 
> "w" jumps from word to word. However, it considers German umlauts
> (äöüÄÖÜ) and German sz (ß) as word end. For example, "w" stops at the
> indicated positions:
> 
> Schwämme überall.
> ^   ^^   ^^ ^
> 
> However, I would desire instead:
> 
> Schwämme überall.
> ^^  ^
> 
> Any idea how to teach Vim to consider special characters as mentioned
> above as "normal" letters?

  :help word
  :help 'iskeyword'

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: 7.0.188 - problem with directory browser?

2007-01-27 Thread Jürgen Krämer

Hi,

Bill McCarthy wrote:
>
> After sending my response, I received the following alien
> language (probably German from the .de) email.  I copied no
> recipient at @youngs.de.  Perhaps a member of this list is
> sending "away from office" responses to the list?
> 
> From: [EMAIL PROTECTED]
> 
> Die von Ihnen genutzte eMail-Adresse ([EMAIL PROTECTED]) existiert
> nicht oder existiert nicht mehr.

  "The e-mail address you used ([EMAIL PROTECTED]) does not exist or does
  not exist anymore."

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: disable é map in tex-suite

2007-01-23 Thread Jürgen Krämer

Hi,

neolistic wrote:
>
> It don't works, I tried
> iunmap é
> iunmap 
> 
> and I can see the map with :imap
> i  é@Tex_InsertItemOnThisLine

from :help map-listing

| When listing mappings the characters in the first two columns are:
|
|   CHAR  MODE~
|  Normal, Visual and Operator-pending
| n   Normal
| v   Visual
| o   Operator-pending
| !   Insert and Command-line
| i   Insert
| l   ":lmap" mappings for Insert, Command-line and Lang-Arg
| c   Command-line
|
| Just before the {rhs} a special character can appear:
| *   indicates that it is not remappable
| &   indicates that only script-local mappings are remappable
| @   indicates a buffer-local mapping

Note the last line. To unmap this buffer-local mapping you should use

  :iunmap  é

or

  :iunmap  

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: map'ing a key to an expression that contains on Windows

2007-01-11 Thread Jürgen Krämer

Hi,

Lukas Ruf schrieb:
> 
> while I have several map'ings working under Linux that include ^M's
> (=Ctrl-Q ENTER (on Windows)), I cannot use them really under Windows.
> 
> For example:
> :map x :s/ /^M/g
> results in an execution of
> :s/ /
> and
> /g
> when x is pressed in normal mode.
> 
> Hence my question: can anyone give me any recommendations on how I can
> include ^M in map'ings on Windows?  Or asked differently: is there any
> way to insert line-breaks at particular places by a different
> approach?

use

  :map x :s/ /\r/g

instead.

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: Indendation of Progress code

2007-01-10 Thread Jürgen Krämer

Hi,

Thomas Michael Engelke schrieb:
> 
> I have a problem with indendation of a piece of Progress code. It's
> representative of a bit of indendation problems I have now and again,
> always indenting way too far without any visible cause. I hope someone
> can reproduce the issue.
> 
> I've attached the problematic file (zipped) to this post. When I am in
> line 771 and use O (shift+o, that's the letter, not the number), I get
> the cursor one line up, but indented by 49 chars, not (as I would
> expect) 7. I'm not sure if this is a problem of vim, a problem of the
> Progress syntax file or a problem of my configuration.
> 
> Please hint me in the right direction.

you seem to have

  set cindent

somewhere in one of your loaded scripts. Check where it has been set
with

  verbose set cindent?

and remove it from the script.

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: change syntax highlighting

2007-01-10 Thread Jürgen Krämer

Hi,

Geue, Stephan wrote:
>
> Hello, I would like to change the VIM colors, i.e. the C/C++ mapping of
> VIM colors to Xterm colors. First, I changed a few lines within
> /etc/X11/app-defaults/Xterm-color but this also changed the color scheme
> of the shell which is not my intention - and in some cases not
> acceptable at all. I identified a file that might be of relevance for
> that problem: /opt/vim/share/vim/vim70/syntax/cpp.vim. But I do neither
> know the syntax of that file nor if changing it is a solution. Can you
> tell me, which file has to be modified and where the doc files
> describing the necessary procedure are located? Thank you very much in
> advance!

the file syntax/cpp.vim defines the different syntax elements of C++.
You should not change this file.

The right way to change VIM's colors is to use a different color scheme.
There are already 17 color schemes supplied with VIM. You can find them
in the $VIMRUNTIME/colors directory. To use a different color scheme
just enter, e.g,

  :colorscheme morning

On www.vim.org you can find even more color schemes in the scripts
section. Just go to http://www.vim.org/search.php, select "color scheme"
in the "type" box below "Search for Scripts" and press the Search
button. If you find a scheme you like you save it to your local
~/.vim/colors directory.

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: % jumping over {} in c-files in the midst of {{{ folds

2007-01-08 Thread Jürgen Krämer

Hi,

Suresh Govindachar wrote:
>    Jürgen Krämer wrote: 
>  
>   > I don't see a place in the help files where % is documented to
>   > skip comments. You can only force it to skip strings by removing
>   > % from cpoptions (see ":help cpo-%"). 
>   
> In the steps I gave to reproduce the bug, adding the following:
> 
>  :set cpo-=%
>  
> does not make %-jumping skip the { inside comments.  So it is a
> bug in Vim.

no, it is not. % in cpoption only affects the skipping of strings -- if
it is included strings that are surrounded by "s are not treated
specially, thus with the cursor on the opening paren of

  Test("---)---")

% will move the cursor to the closing paren inside the string. Nowhere
in the documentation it is said that the behaviour of % with regard to
comments can be changed.

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: % jumping over {} in c-files in the midst of {{{ folds

2007-01-08 Thread Jürgen Krämer

Hi,

Suresh Govindachar wrote:
>A.J.Mechelynck wrote 
>   >Suresh Govindachar wrote:
>   >>
>   >> Start gvim via command:
>   >>  c:\opt\vim\vim70\gvim.exe --noplugin -u NONE -U NONE
>   >>
>   >> :saveas boo.c
>   >> :set filetype=c
>   >>
>   >> Enter following text:
>   >>
>   >> if(1)
>   >> {
>   >>   /* --- {{{3 */
>   >> }
>   >>
>   >> :w
>   >> Now try to jump between { using %.  
>   >>
>   >> Bug:  The { in the manual fold-markers interferes with %-jumping.
>   >
>   >  [comments on using the matchit plugin]
>  
>   % is a feature of Vim -- I am not trying to use % in any fancy
>   way, only in the way it is supposed to work under regular Vim.
>   I am reporting a bug in vim (and not looking for a work-around
>   based on a plugin).  The bug is that % is not ignoring { within 
>   c-comments in a c-file. 

what did lead you to the conclusion that the behaviour of % -- to not
ignore matching parentheses inside comments -- is a bug? I don't see a
place in the help files where % is documented to skip comments. You can
only force it to skip strings by removing % from cpoptions (see ":help
cpo-%"). The text

  Does not recognize "/*" and "*/".

from this help section does not relate to /* and */ as C style comments,
but as potentially matching pairs which are not counted as such if % is
included in cpoptions.

IMHO ignoring comments while searching for a matching parenthesis might
be considered a missing feature, but this can easily -- as Tony wrote --
be implemented by sourcing the matchit plugin.

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: GVIM 7-0-178 seizing up

2006-12-19 Thread Jürgen Krämer

Hi,

Steve Hall wrote:
> From: zzapper , Tue, December 19, 2006 6:53 am
>> http://downloads.sourceforge.net/cream/gvim-7-0-178.exe?modtime=1165578469&big_mirror=0
>>
>>
>> Downloaded above by following links from vim.org
>>
>> It works fine with most files but cannot edit .vimrc (unless I
>> rename .vimrc to say fred) it shows the menu "read only, edit anyway
>> etc then seizes.
> 
> The correct name of vimrc on Windows is "_vimrc". A file with a
> preceding dot is actually not a permitted file name on Windows.

there is nothing wrong with a file name with a leading dot. Even
directory names with a leading dot are accepted:

  :echo $MYVIMRC
  C:\Dokumente und Einstellungen\jkr.HABEL\.vimrc
  set rtp?
  
runtimepath=~/.vim,D:\Progs\vim/vimfiles,D:\Progs\vim\vim70,D:\Progs\vim/vimfiles/after,~/.vim/after

> (Although there are ways of getting one on the system.)

It seems Windows Explorer does not allow to create a file name with a
leading dot, but on the command line and inside VIM it's no problem --
just

  echo set compatible> .vimrc

or

  :w .vimrc

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: Linewise-only vnoremap

2006-12-07 Thread Jürgen Krämer

Hi,

Vigil wrote:
> vnoremap doesn't appear to care whether the text was selected blockwise or 
> linewise. How can I make a map work in linewise mode only?

you can use the visualmode() function and wrap your actual mapping with
an if-statement:

  :vnoremap  :if visualmode() == 'V'  echo 'linewise'  endif 


The  at the start of the mapping removes the visual range that is
supplied by VIM automatically when a colon is entered while in visual
mode. If you need this range you will have to re-supply it in your
original mapping.

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: add yanked line to already yanked lines

2006-11-23 Thread Jürgen Krämer

Hi,

Daniel Nogradi wrote:
> 
> I often find myself in need of copying (yanking) non-consecutive
> multiple lines so that I can paste them somewhere else in a
> consecutive way. Several lines are scattered around the file and would
> like to collect them kind of.
> 
> At the moment I go to to first line, yank it, go to the destination
> position, paste it, look for the second line, yank it, go to the
> destination position, paste it after the already pasted line, etc.
> 
> Is it possible to yank a line (or character or block of text) and then
> yank something else in a way that the second yanking does not
> overwrite the previously yanked stuff but adds to it? So that a
> subsequent paste would paste both?

in addition to Tony's suggestion you can use the :global command if
those lines match a common pattern:

  :let @a = ''
  :g/pattern/y A

will first clear the content of register "a. The :global command then
appends every line that matches the pattern to register "a.

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: sorting columns alphabetically

2006-11-22 Thread Jürgen Krämer

Hi,

Vim Visual wrote:
> 
> I have a text file like
> 
> Mr Bla Blo
> Ms Ble Blu
> Dr Bli Blu
> etc
> 
> and I would like to sort the file alphabetically after the surname
> (3rd column). How can I do that? I know how to sort it after the first
> one (visual + !sort)

with VIM 7 you can sort inside VIM:

  :%sort /^\S\+\s\+\S\+\s\+/

tells VIM to skip the first two words in every line and to sort on
whatever follows.

If the third column is always the last column another way would be to

  :%sort /\<\S\+\>$/ r

The "r" flag tells VIM to sort based on the matched text, which is the
last word in this case. This would also work around your problem with
initials you mentioned in your second mail.

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: Inserting date/text

2006-11-14 Thread Jürgen Krämer

Hi,

David Woodfall wrote:
>
> On (10:30 14/11/06), David Woodfall <[EMAIL PROTECTED]> put forth the 
> proposition:
>
> > I would like to make a command that would insert at cursor todays date,
> > and also a command to insert some custom text.
> >
> > In the help file it shows how to make a keybind to do this but I would
> > rather use a command - eg :date
> >
> > Can this be done?
> 
> Ok I've just found the :command command but I'm having problems:
> 
> :command Date :read !date +%d-%b-%Y
> 
> This prints xxd-xxb-xxY
> 
> !date with no options works fine on it's own. I have tried putting the
> options in "" and '' but still no go.

I guess the buffer from which you tested this command was named 'xx'.
The percent sign in you command is a placeholder for the current file
name. You have to escape it with a backslash if VIM should not touch
it:

  :command Date :read !date +\%d-\%b-\%Y

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: regular expression with character '@'

2006-11-12 Thread Jürgen Krämer

Hi,

Rui Gonçalves wrote:
>
> if i use the character '@' in a regular expression, i need use the '\' before?

no, you don't need the backslash.

> i try do
> [EMAIL PROTECTED]
> 
> and
> 
> [EMAIL PROTECTED]
> 
> but didn't work

You are missing the backslash in front of the final plus sign.

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: set backupext dynamicly

2006-11-10 Thread Jürgen Krämer

Hi,

Eric Leenman wrote:
> I've tried it but then I get the message :
> Error E510 'Can't backup file (add! to override)
> 
> 
> 
> I have a clean gvim70.exe downloaded today.
> I've added two lines to my _vimrc, see below for the complete file.
> Do I need to do something with backup and write backup?
> 
> [start _vimrc]
> set nocompatible
> source $VIMRUNTIME/vimrc_example.vim
> source $VIMRUNTIME/mswin.vim
> behave mswin
> 
> set bdir=$VIM/backup
> let &bex = '-' . strftime("%Y%b%d%X") . '~'
> [end _vimrc]

"%X" as part of the strftime parameter generates a time stamp like
"14:51:23", but colons are invalid in Windows file names. Better use
something like this:

  let &bex = '-' . strftime("%Y%m%d%H%M%S") . '~'

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: Ctrl-D delete mapping

2006-11-10 Thread Jürgen Krämer

Hi,

Allan Kelly wrote:
>
> Hello, I'd like Ctrl-D to delete a character in insert mode. This does not
> work (Ctrl-D continues to do the page down thing):

that might be because you were not in insert mode. "the page down thing"
is VIM's behaviour when pressing Ctrl-D in normal mode. Ctrl-D in insert
mode should remove one shiftwidth of indent.

> Imap  x
>
> Any ideas?

Did you really write "Imap" with an upper case "I"? You should write it
with a lower case "i".

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: Replacing '%' in a text file

2006-10-09 Thread Jürgen Krämer

Hi,

Muhammad Farooq-i-Azam wrote:
>
> I have to replace every occurrence of % in a file with
> % |. I have been effectively replacing text using the
> following construct:
> 
> :%s/\/replacement/g
> 
> However when I try to do the following:
> 
> :%s/\<%\>/% |/g 
> 
> I am greeted by an error message. Obviously, the %
> character needs to be treated differently for being
> replaced. Escap sequence? I cannot figure out how to
> do it. May be trivial for the gurus here. I will be 
> thankful for a hint.

normally % is not included in the 'iskeyword' option so it is not
considered part of a word. Therefore there can not be the beginning of
a word right in front of %. The same is for true for the end of a word
immediately after a %. You either have to include % in the 'iskeyword'
option by issuing a

  :set iskeyword+=%

before executing your substitute command or use

 :%s/%/% |/g

without '\<' and '\>', respectively.

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: bug in map and complete()

2006-10-05 Thread Jürgen Krämer

Hi,

Hari Krishna Dara wrote:
> The help on complete() gives an example as a usage pattern which seems
> to be very useful, but it doesn't work. Here is a slightly modified
> example to avoid breaking the lines in email transmission:
> 
> inoremap   ListWeeks()
> func! ListWeeks()
>   call complete(col('.'), ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'])
>   return ''
> endfunc
> 
> If you hit , Vim complains about the complete() as not allowed.
> 
> Error detected while processing function ListWeeks:
> line1:
> E523: Not allowed here

I don't know the reason for this restriction, but it is documented under
":help complete()":

| Set the matches for Insert mode completion.
| Can only be used in Insert mode.  You need to use a mapping
| with CTRL-R = |i_CTRL-R|.  It does not work after CTRL-O or
| with an expression mapping.

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: toggling keymap

2006-10-04 Thread Jürgen Krämer

Hi,

Sven Brueggemann schrieb:
> 
> where do I find CTRL-^ on a German keyboard? I know that I can
> map it, but I'd like to see if the standard keystroke fits my
> needs before changing it.

on my keyboard and with Windows XP it's CTRL-6.

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: sorting lines on lenght of characters

2006-09-22 Thread Jürgen Krämer

Hi,

Eric Leenman wrote:
> 
> Is it possible to sort lines on line length?
> Shortes firsts, longest last?
> If so how do you do this?

I would put the line lengths at the front of each line with leading
zeroes, sort the buffer, and remove the line lengths.

With Vim 7.0 you can do this with the following commands

  :%s/^/\=repeat('0', 8 - strlen(strlen(getline('.' . strlen(getline('.'))/
  :sort
  :%s/^\d\{8\}//

Note the double use of strlen() which is needed to prepends the line
length with the necessary number of zeroes to make it 8 digits wide.

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)



vim@vim.org

2006-09-22 Thread Jürgen Krämer

Hi,

Eric Leenman schrieb:
> 
> I have a file where I deleted all lines that don't contain a certain pattern
> For example I want to delete all lines that don't contain XXX and YYY.
> 
> Before:
> 
> [start of file]
> abcde XXX fghij YYY
> 12345 AAA 67890 BBB
> klmno XXX pqrst YYY
> 09876 XXX 54321 BBB
> &*()- XXX ,./;' YYY
> [end of file]
> 
> After:
> [start of file]
> abcde XXX fghij YYY
> &*()- XXX ,./;' YYY
> [end of file]
> 
> 
> How do I do that?

  :g/PATTERN/d

deletes all lines that match a specific pattern. To keep all lines you
need to use

  :g!/PATTERN/d

or

  :v/PATTERN/d

Now your pattern is either

  XXX.*YYY

or

  XXX.*YYY\|YYY.*XXX

depending on wheter you only want to keep lines with contain XXX in
front of YYY or whether the order of those strings is irrelevant. So
the final command is

  :v/XXX.*YYY/d

or

  :v/XXX.*YYY\|YYY.*XXX/d

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: What is the key nameing of...

2006-09-21 Thread Jürgen Krämer

Hi,

Meino Christian Cramer wrote:
> 
>  I often have the problem to guess, how a certain keysequence is named
>  by the syntax of the vim scripting language.
> 
>  Recently I tried to map Control-CursorUp but it simply does not work
>  for me.
> 
>  Is there any function/script/hack/trick/* like Ctrl-v is for the "raw
>  keysequence" to display the <"key"> thingy?

have you tried Ctrl-V + Control-CursorUp while in insert or command mode?
For me, Vim shows

  

>  Something like (example!)  : 
> 
>  :showkey
> 
>  will display
> 
>  :press key
> 
>  then one presses the key in question (for example Alt plus F11...)
>  and then it displays:
> 
>  :

Now that would be a really strange answer for your example. ;-)

There also is a list with some/all special key codes. Have a look at

  :help key-codes

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: Selective line deletion

2006-09-18 Thread Jürgen Krämer

Hi,

Fabien Meghazi wrote:
> 
> This is a stupid question about a basic feature but I don't have yet
> enough knowledge with vim.
> 
> How can I delete all lines of a buffer where at least one instance of
> "foobar" is found ?
> 
> eg the output of:
> 
> grep -v file.txt "foobar"

  :g/foobar/d

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: vim | insert filename into file

2006-09-14 Thread Jürgen Krämer

Hi,

Nikolaos A. Patsopoulos wrote:
> 
> how can anyone add the filename in the file in ex-mode?
> %  and  "%p works only in normal mode

  :put %

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: Counts for mapping

2006-09-11 Thread Jürgen Krämer

Hi,

Tom Carr wrote:
>
> Let's say I have the following mapping:
> nnoremap = 3l
> 
> Now if I type =, it moves 3 characters to the right, as expected.
> Now if I type 1=, it moves 13 characters to the right instead of 3.
> Now if I type 3=, it moves 33 characters to the right instead of 9.
> 
> Any idea how to make the counts work correctly with the mapping?
> (Vim 7.0)

you can achieve the desired behaviour with the help of a register:

  :let @q = '3l'
  :nnoremap = @q

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: testing patchlevel from script

2006-09-10 Thread Jürgen Krämer

Hi,

Yakov Lerner wrote:
>
> How can a script test for specific patchlevel ?
> For example, I have vim 7.0.86 and I need to check in the script that
> patchlevel is >= 7.0.86. But v:version is 700. How ? It would be
> nice if to have patchlist available through some v: variable.

you can check for a specific patch with

  :let patch_ok = has('patch123')

See

  :help has()
  :help feature-list

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: cursorline highlight error

2006-08-29 Thread Jürgen Krämer

Hi,

Paul van Erk wrote:
> 
> I'm having a problem with Vim 7.0.17's cursorline highlighting. When I have 
> in 
> my .gvimrc 'set highlight cursorline', I get the next error in gvim:
> 
> highlight=8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,
> +:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine

this is not an error, it's the output of your command.

  set highlight cursorline

is the same as

  set highlight
  set cursorline

Because 'highlight' is a string option, its current value is displayed.
In contrast to 'highlight' 'cursorline' is a boolean option, so it is
switched on.

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: expr returning path of sourced script?

2006-08-26 Thread Jürgen Krämer

Hi,

sgp wrote:
> On Windows gvim 7.0 I want to :set complete= to a file in the same folder of 
> a syntax file
> 
> c:\path\to\syntax\syn.vim
> c:\path\to\syntax\keywords.txt
> 
> what expression can I use with :exe to achieve that? I tried adding
> 
> exe "set 
> complete=k".substitute(fnamemodify(bufname('.'),':p:h').'\keywords.txt','\\','/','g')
> 
> in syn.vim - but it doesn't work, as it yields the path of the edited file 
> not of syn.vim

  let &complete = expand(':p:h') . '\keywords.txt'

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: vim doesn't create backups of files edited in /tmp

2006-08-25 Thread Jürgen Krämer

Hi,

Alexander Skwar wrote:
> 
> In my ~/.vimrc, I've got, among other settings, "set backup". Because
> of this, vim creates backup files in the current directory. That's good!
> 
> But when I edit a file which is in /tmp, there's no backup file "left
> behind".
> 
> Why's that so and how do I change this?
> 
> I'm using vim 7.0 on Gentoo Linux.

have a look at

  :help 'backupskip'

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: renaming unnamed buffer at creation

2006-08-21 Thread Jürgen Krämer

Hi,

Charles E Campbell Jr wrote:
> Yakov Lerner wrote:
> 
> > Now that my attempt to write unnamed buffer under
> > name /tmp/N failed, I want to autoname empty buffer.
> > My first attempt does not work. Autoevent is ot invoked.
> 
> 
> The autocmd system is always invoked based on the buffer name.
> Thus it appears none of the autocmds will fire, including BufWriteCmd,
> BufReadCmd, CursorHold, etc. 

  :au BufNew * echo 'File name is "' . expand('') . '".'

is fired for empty buffer names, too, and will output

  File name is "".

in this case.

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: E505, File is write-protected

2006-08-21 Thread Jürgen Krämer

Hi,

Wolfgang Schmidt wrote:
> 
> when I try to write (:w) a certain buffer, I get E505 (~ "file XXX is 
> write-protected, override with w!").
> The protection seems to be set by Vim, not the OS (WinXP). So I looked 
> for the "readonly" option value,
> but it's set to "noreadonly". I also checked "write", which is set to 
> "write". Nevertheless, everytime I try to
> :w the file, I get this E505 dialog. Any hints? I'm running Gvim 7.0 on 
> Win XP)

are you able to write the file with ":w!"? If not, the file might be
opened exclusively or with write-access denied by another program.

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: renaming unnamed buffer at creation

2006-08-21 Thread Jürgen Krämer

Hi,

Yakov Lerner wrote:
>
> Now that my attempt to write unnamed buffer under
> name /tmp/N failed, I want to autoname empty buffer.
> My first attempt does not work. Autoevent is ot invoked.
> 
> function! TempName()
> let x=1
> while filereadable("/tmp/".x)
> let x = x + 1
> endwhile
> return "/tmp/".x
> endfun
> 
> au BufNew * if(expand('') == '') | call input("AAA") | endif
> au BufNew * if(expand('') == '') | exe "file ".TempName() | endif

I checked it with this autocommand

  au! BufNew *
\ if expand('') == '' |
\   exe 'file ' . input('Enter file name: ') |
\ else |
\   echomsg 'File already has a name' |
\ endif

It seems to be triggered, but when the 'file' command is executed, VIM
is still in the original buffer thus renaming this one instead of the
new one. One way to circumvent this problem I can think of is to use the
BufNew event to store the new file name in a variable and to use this
variable in a BufEnter event. The following code should do this, but it
is untested:

  au! BufNew *
\ if expand('') == '' |
\   let new_file_name = input('Enter file name: ') |
\ else |
\   echomsg 'File already has a name' |
\ endif

  au! BufEnter *
\ if expand('') == '' && exists('new_file_name') |
\   exe 'file ' . new_file_name |
\   unlet new_file_name |
\ endif

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: saving unnamed buffer

2006-08-21 Thread Jürgen Krämer

Hi,

A.J.Mechelynck wrote:
>
> Yakov Lerner wrote:
> >
> > I fixed another bug, the '*' missing in the autocommand:
> >
> > au BufWritePre * if(expand('%') == '') | exe "file ".TempName() | endif
> > au BufWritePre * if(expand('%') == '') | exe "saveas ".TempName() | endif
> >
> > , but still no luck. I'm still getting the "E32: No file name" error.
> 
> Well, what gets displayed when you replace "exe" by "echo" or "echomsg"? 

probably nothing; I guess the file name is checked before BufWritePre is
executed.

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: saving unnamed buffer

2006-08-21 Thread Jürgen Krämer

Hi,

Yakov Lerner wrote:
> On 8/21/06, A.J.Mechelynck <[EMAIL PROTECTED]> wrote:
>> Yakov Lerner wrote:
>>> I want to make saving of unnamed buffers possible as follows:
>>>   When I do :w on a unnamed buffer, I want it to save to the
>>> file /tmp/N where N is number.
>>>
>>> I tried the simple code below, but it does not work. I am getting
>>> 'E32: No file name', same error as without this code.
>>>
>>> How do I fix it ?
>>>
>>> Thanks
>>> Yakov
>>> "  attempt to save unnamed buffer to file /tmp/N -
>>> au BufWritePre if(expand('%') == '') | exe "filename ".TempName() | endif
 ^^^

I think you forgot the pattern:

  au BufWritePre * if(expand('%') == '') | exe "filename ".TempName() | endif

>>>
>>> function! TempName()
>>>let x=1
>>>while filereadable("/tmp/".x)
>>>let x = x + 1
>>>endwhile
>>>return "/tmp/".x
>>> endfun
>>>
>>>
>> Instead of ":filename" which AFAIK is not a Vim command, try using
>> ":file" or ":saveas" instead.
> 
> Nope, does not help.

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: tabedit readonly

2006-08-18 Thread Jürgen Krämer

Hi,

SHANKAR R-R66203 wrote:
> 
>   How do I open a new file in a new tab, but in the read only mode.
> 
>   :tabedit -R file_name
> 
> Does not seem to work.

  :tab sview file_name

Regards,
Jürgen

-- 
Jürgen Krämer  Softwareentwicklung
HABEL GmbH & Co. KGmailto:[EMAIL PROTECTED]
Hinteres Öschle 2  Tel: +49 / 74 61 / 93 53 - 15
78604 Rietheim-WeilheimFax: +49 / 74 61 / 93 53 - 99


Re: using filereadable function

2006-08-16 Thread Jürgen Krämer

Hi,

SHANKAR R-R66203 wrote:
> 
> I am trying to use the filereadable function.
> 
> My code looks like given below (This code is part of a function) -
>  
> if (!filereadable("a:dataFile")
^  ^
remove the quotes.

> let @/ = rs_searchString
> keepjumps exec rs_ori_lineNum
> echohl Todo
> echomsg a:dataFile " Cannot open file for reading"
> echohl NONE
> return
> endif
> 
> a:dataFile is the argument passed to the function, while calling the
> function.
> This does not seem to work.
> Eventhough the file is present, the function reports, the file is not
> present.

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: Test for mapped key sequence available ?

2006-08-16 Thread Jürgen Krämer

Hi,

Meino Christian Cramer wrote:
> 
>  is there any way to check, whether a certain key is already in use
>  by vim or a map command, which is executed via the files read on
>  start up of vim ?
> 
>  I dont mean: reading the output of :map and look for that key.
>  Something like "describe-key" in Emacs -- but it only needs to
>  return "occupied" or "unused" (or equivalent).

have a look at

  :help maparg()

and

  :help mapcheck()

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: non-greedy pattern matching

2006-08-16 Thread Jürgen Krämer

Hi,

Wolfgang Schmidt wrote:
> 
> I'm trying to do a regexp replacement. My original line is
> 
> ignore MATCH1 ignore_again MATCH2
> 
> I want to match MATCH1 and MATCH2, so here's my trial:
> 
> s/^ignore \(.*\{-}\) .*\{-} \(.*\)/matched:\1,\2/gc
> 
> I tried to use \{-} to make the ".*" match non-greedy, but I get E62 and 
> E476.

in contrast to Perl where you have to append ? to * to make the match
non-greedy, in Vim you must replace * with \{-}. The correct regexp
would have been

  s/^ignore \(.\{-}\) .\{-} \(.*\)/matched:\1,\2/gc

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: gP-confusion

2006-08-16 Thread Jürgen Krämer

Hi,

Meino Christian Cramer wrote:
> From: "Yakov Lerner" <[EMAIL PROTECTED]>
> Subject: Re: gP-confusion
> Date: Wed, 16 Aug 2006 12:54:52 +
> 
>> On 8/16/06, Meino Christian Cramer <[EMAIL PROTECTED]> wrote:
>>>   ...and what is the difference between
>>>
>>>   y$$gp
>>>
>>>   and
>>>
>>>   y$$gP
>>>
>>>   then. Or in other words: In what case I would prefer gP instead of
>>>   gp ?
>> gp  puts after the cursor, gP puts before the cursor.
>>
>> When you want to paste at the front of the line, you want
>> gP, like 0gP. When you want to paste at the end of the
>> line, you'll want to use $gp.
> 
>   ?Hu?
> 
>   ...of the line ???
> 
>  May be it should be: In front og the pasted text or afer the
>  pasted text?

"gp" puts the text after the current cursor position, then positions the
cursor after the end of the newly yanked text: suppose you have "123" in
the register and the cursor is on the "b" in the current line:

  abc

Executing "gp" results in

  ab123c

with the cursor on the "c".

"gP" puts the text before the current cursor position and positions the
cursor after the end of the newly yanked text, too. With the same values
and the cursor on the "b" again,

  abc

becomes

  a123bc

with the cursor on the "b".

The examples Yakov provided -- 0gP and $gp -- combine "moving to the
start of line" with "putting before the cursor" and "moving to the end
of line" with "putting after the cursor", respectively. Thus they
provide a way to prepend and append text to a line.

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: gP-confusion

2006-08-16 Thread Jürgen Krämer

Hi,

Meino Christian Cramer schrieb:
> 
>  finally I found (nearly) what I am searching for...but...
> 
>  I wanted a command which after doing a y$ from in the midth of a
>  line, puts my yanked text after the end of the line and the cursor
>  right after the put text.
> 
>  The help of "gP" states (my im is "nocompatible"):
> 
>  ["x]gP   Just like "P", but leave the cursor just after 
> the new
>   text.  {not in Vi}
> 
>  
>  But it seems I understand the help wrongly. Example:
> 
>This is a very boring example of a line.
>x
> 
>  (x=position of the cursor)
> 
>  I do a y$gP and the line looks like:
> 
>This is a very boring example of a line.a very boring example of a line.
>x
> 
>  The help says:
>   ...but leave the cursor just after the *new*
>   text.

it did.

>  What did I so wrong here ? What did I misundertstand ?

You missed to go to the end of line before putting the text:

  y$$gp

Note the second dollar sign. "y$" alone does leave the cursor at its
current position. The second "$" then puts the cursor on the last
character of the line. "gp" (with *lower* case ell) appends the yanked
text. If you had chosen a different text to put than the one the cursor
is in front of, the result of your command would have been more
obvious.

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: Emacs 22 'feature' - Can Vim do this?

2006-08-11 Thread Jürgen Krämer

Hi,

Mark Woodward wrote:
> Thanks Jürgen,
> 
> On Fri, 11 Aug 2006 11:54:50 +0200
> Jürgen Krämer <[EMAIL PROTECTED]> wrote:
> 
> snip...
> 
>> 1.) if this text starts at line 1
>>
>>   %s/^\d\+:/\=line('.') . '.) '/
>>
>> 2.) for at most 26 lines
>>
>>   %s/^\d\+:/\=nr2char(char2nr('a') + line('.') - 1) . ') '/
>>
>> Regards,
>> Jürgen
> 
> 
> Is is possible where text starts on a line other than 1?

subtract the line number and add 1, e.g.,

  50,100s/^\d\+:/\=(line('.') - 50 + 1)  . '.) '/

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: Emacs 22 'feature' - Can Vim do this?

2006-08-11 Thread Jürgen Krämer

Hi,

Mark Woodward wrote:
> 
> came across this [Emacs] link the other day and wondered if Vim
> can do this?
> http://steve-yegge.blogspot.com/

[snip]

> 1. change these to number order starting at 1 (1, 2, 3, 4 etc)
> 2. change these to alpha list (a, b, c, etc)
> [This one has me stumped although I'm sure I've seen something
> along these lines before. ? something to do with sub-replace-special
> and submatch?]
> 
> 
> 1987:Bogotá
> 5243:Fabergé
> 9772:Mallarmé
> 12044:Paraná
> 12499:Poincaré
> 16956:abbé
> 19923:appliqué
> 20932:attaché
> 23704:blasé
> 26223:café
> 26511:canapé
> 29314:cliché
> 31431:consommé
> 38981:décolleté
> 42995:fiancé
> 43623:flambé
> 44996:frappé
> 48317:habitué
> 58328:macramé
> 58898:manqué
> 62514:naiveté
> 65243:outré
> 66710:passé
> 71609:protégé
> 73675:recherché
> 76387:risqué
> 76847:roué
> 77811:sauté
> 82455:soufflé
> 89055:touché
> 96268:émigré
> 96274:études
> 
> 
> any hints?,

1.) if this text starts at line 1

  %s/^\d\+:/\=line('.') . '.) '/

2.) for at most 26 lines

  %s/^\d\+:/\=nr2char(char2nr('a') + line('.') - 1) . ') '/

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: How to disable the automatic on for 'hlsearch' option.

2006-08-11 Thread Jürgen Krämer

Hi,

[EMAIL PROTECTED] wrote:
> 
> The 'hlsearch' can be turned off by :set nohls
> 
> However, it will be automatically turned on when I'd done a search, which
> is annoying me.

this does not happen here nor is it documented that way. Are you
possibly confusing ":set nohls" and ":nohls"? Or do you have mapped "/"
to do something with 'hlsearch'?

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: half of hlsearch

2006-08-11 Thread Jürgen Krämer

Hi,

Meino Christian Cramer wrote:
> 
>  I am searching for a way to switch "hlsearch" half on (or half
>  off...).
> 
>  Normally hlsearch is nice when searching regulary for a keyword or
>  phrase.
> 
>  On the other side it highlight half of my text, if I do things like
>  
>   y/
> 
>  . Is there a way to sitch off hlsearch when using y and other action
>  which are not "searching for something" actions from the users point
>  of view ?

you can achieve this with two mappings that toggle the state of the
'hlsearch' option depending on which type of search you are about to
execute.

After you have typed "y" VIM is in operator-pending mode which has its
own set of mappings. At this point you want to turn 'hlsearch' off.
Normally this can be done with "set nohls" in command-line mode but you
can't switch there from operator-pending mode like with "" from
insert mode. So you need a little trick -- evaluate the expression
register only for making use of a side effect. For this you need a
helper function which executes a command and returns an empty string.
The empty string can then be "inserted" into the right hand side of the
mapping without causing any harm.

  function! Execute(command)
  execute a:command
  return ''
  endfunction

  onoremap / /=Execute('set nohls')

"Regular" searches are started from normal mode. At this point you want
to turn 'hlsearch' on again. For this you need a normal mode mapping:

  nnoremap / /=Execute('set hls')

Note that there is (at least) one potential problem with this: by doing
"y/anything" the last search pattern is set to "anything". Executing
":set hls" after that will cause "anything" to be highlighted -- not the
search pattern of your last "regular" search.

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: Patch (Unofficial): Malformed characters in menu and toolbar when using zh_CN.GBK encoding under Linux

2006-08-10 Thread Jürgen Krämer

Hi,

Max Dyckhoff wrote:
> Bram, you have an overflow in your signature :)
> 
> Max
> 
>> -Original Message-
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>> Sent: Thursday, August 10, 2006 1:44 PM
>> Subject: Re: Patch (Unofficial): Malformed characters in menu and
> toolbar
>> when using zh_CN.GBK encoding under Linux
>>
>> 
>>
>> --
>> hundred-and-one symptoms of being an internet addict:
>> 102. When filling out your driver's license application, you give
>>  your IP address.
>>
>> 

from another mail by Bram:

| 257. Your ``hundred-and-one´´ lists include well over 101 items,
|  since you automatically interpret all numbers in hexadecimal
|  notation. (hex 101 = decimal 257)

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: Display the current character

2006-08-08 Thread Jürgen Krämer

Hi,

Ben lemasurier wrote:
> 
> Is there a way to dispaly the current cursor position? e.g,, "character 23".

  :set ruler

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: Copy a line of text without the LF

2006-08-08 Thread Jürgen Krämer

Hi,

Meino Christian Cramer wrote:
> From: Jürgen Krämer <[EMAIL PROTECTED]>
> Subject: Re: Copy a line of text without the LF
> Date: Tue, 08 Aug 2006 10:56:24 +0200
> >
> > Meino Christian Cramer schrieb:
> > >  I am using vim 7.0.42 on a Linux system.
> > >
> > >  I want copy a complete line of text *without+ the final LF at the
> > >  end, so it is possible to insert it elsewhere in the midth of text.
> > [snip]
> >
> > just use
> >
> >   y$
>
>  nice to now, that there is just another extra command... :)

it's not a command, it's a combination of a command (yank) and a motion
(to the end of line).

>  BUT: For what hopefully logical reason "y/$" does not work?

"/$" is a different motion than "$" -- in general, "/" as a motion puts
the cursor before the start of the matched text. As "$" is a zero-width
anchor and the cursor can't be positioned after the last character on a
line VIM uses the character before the match as "start of matched text".
Exception: With ":set virtualedit=all" the cursor can be placed beyond
the end of line and your command would have worked as expected.

>  And more
>  important: What is executed instead of one would extrapolate from
>  knowing y/.

Here again the cursor is put before the start of the matched text, e.g.,

  y/a

would yank up to but not including the next "a". If you want to include
the "a" you will have to use offsets, i.e. in this special case

  y/a/e

or more generally

  y/amore text/s+1

would include the "a". Have a look at ":help search-offset" for more
information on offsets in searches.

>  Or -- exaggerated to the limit -- do I need another extra command to
>  search/yank for example a "m" at line's end ???

  y/m/e

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: howto set magic=very?

2006-08-08 Thread Jürgen Krämer

Hi,

Linda W wrote:
>
> I couldn't figure out what flag to use to turn on the "very magic"
> flag by default.  Could someone maybe tell me where I should have
> looked to find it? :-)

there is no such flag. Everytime you want to use a "very magic" pattern
you have include "\v" inside the pattern.

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: Copy a line of text without the LF

2006-08-08 Thread Jürgen Krämer

Hi,

Meino Christian Cramer schrieb:
> 
>  I am using vim 7.0.42 on a Linux system.
>  
>  I want copy a complete line of text *without+ the final LF at the
>  end, so it is possible to insert it elsewhere in the midth of text.

[snip]

just use

  y$

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: Search and Replace with a Regular Expression

2006-08-03 Thread Jürgen Krämer

Hi,

Tim Chase wrote:
>>> zeros on the left if needed.  Ideally, Vim would provide a 
>>> right() function where you could just do something like
>>>
>>> right('0'.submatch(1), 2)
>>>
>>> to zero-pad to 2 places.  Alas, the substitute() trick is the 
>>> easiest way I've found to simulate this.
>>   repeat('0', 2 - strlen(submatch(1))) . submatch(1)
> 
> A slight step in the right direction.  Two caveats, however:
> 
> 1) if strlen(submatch(1)) > 2 (in other cases, not this 
> particular one where it's limited to at most 2 characters 
> initially), then this formula can end up with a result that is > 
> 2 characters.  A true right() function would never return more 
> than 2 characters (okay...insert funky tangent about 
> unicode/UTF-8 characters here).

  function! Right(s, n)
  return strpart(s, strlen(s) - n, n)
  endfunction

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: Search and Replace with a Regular Expression

2006-08-03 Thread Jürgen Krämer

Hi,

Tim Chase wrote:
>
[...]
> 
> I broke it out into multiple lines to hopefully make more sense 
> of it.  The first two substitute() lines add a zero on the left 
> of whatever they found, and then take whatever the rightmost two 
> characters of the result are...effectively padding them with 
> zeros on the left if needed.  Ideally, Vim would provide a 
> right() function where you could just do something like
> 
>   right('0'.submatch(1), 2)
> 
> to zero-pad to 2 places.  Alas, the substitute() trick is the 
> easiest way I've found to simulate this.

  repeat('0', 2 - strlen(submatch(1))) . submatch(1)

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: Search and Replace with a Regular Expression

2006-08-03 Thread Jürgen Krämer

Hi,

Marv Boyes wrote:
> Hello, all. I've been tasked with migrating a large MS Works
> "database" into the 21st century. The thing's original setup didn't
> enforce any sort of standardization in data entry, so there are nearly
> as many different formats and styles in the data as there have been
> people entering it. My best bet seems to be to hammer things into
> shape with a CSV version of the data before even thinking of trying to
> drop it into a new database app. Since it's plain text, Vim seems the
> perfect tool for the job. :)
>
> I could use some pointers on search and replace with regular
> expressions. I'm sure this will be painfully basic to most of you, but
> I can't seem ot get the hang of it for this particular job. Most of
> the problem is with dates, in that I have a mishmash of formats. Most
> of them are in dashed format, but there's not even much uniformity
> _there_: some are MM-DD-, some are M-D-YY, and so on. What I'd
> like to do is reformat them en masse as MM/DD/; preserving the
> original values, replacing dashes with slashes, putting zeroes in
> front of existing single digits, and expanding two-digit years into
> four digits by bolting on "20" at the front.
>
> For example, let's say I have some dates that look like this:
>
>   7-30-05
>   12-5-2006
>   10-2-06
>
> What I'd like to end up with is this...
>
>   07/30/2005
>   12/05/2006
>   10/02/2006
>
> ...without, of course, having to re-type every single one by hand. ;)

if you are sure that there are no dates from before 2000 the following
command should do the job (all on one line):

  :%s,\<\(\d\+\)[-/]\(\d\+\)[-/]\%(20\)\?\(\d\d\)\>,\=(submatch(1) < 10 ? '0' : 
'') . submatch(1) . '-' . (submatch(2) < 10 ? '0' : '') . submatch(2) . '-' . 
'20' . submatch(3),

I have used commas as separators so that there is no need to escape the
slashes used between the parts for month, day, and year. The regex part
is quite easy: we look for something word-like ("\<...\>") which
consists of one or more digits ("\d\+"), a dash or a slash ("[-/]"),
some digits, a second dash or slash, and two or four digits; if the
third number has four digits, the first two must be 20
("\%(20\)\?\(\d\d\)"). I used VIM's non-capturing parentheses to make
clear that the content of "\%(20\)" is not needed later.

If this expression matches, the submatches 1, 2, and 3 contain month,
day, and year, respectively.

Generating the replacement is simple, too; the expression is only
longer (therefore I have split it on three lines here):

  \=(submatch(1) < 10 ? '0' : '') . submatch(1) . '-' .
(submatch(2) < 10 ? '0' : '') . submatch(2) . '-' .
'20' . submatch(3)

It uses the "\=" special register to evaluate an expression.
"submatch(1)" contains the month. If it is less than 10 it has only one
digit. In this case the month is prefixed with a zero. The same is true
for the day in "submatch(2)". "submatch(3)" only contains the second to
last digits of the year, because we used non-capturing parentheses. So
we always have to prefix it with '20'. Those three strings are then
concatenated with dashes between them.

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: How to scroll up and down without changing horizontal pos

2006-08-03 Thread Jürgen Krämer

Hi,

Eric Leenman wrote:
> 
> I'm using page-up and page-down to scroll.
> Also ctrl-home and ctrl-end.
> This moves the cursor to the beginning of the line.
> How can this be avoided.

  :set nostartofline

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: Deleting a repetative pattern

2006-08-02 Thread Jürgen Krämer

Hi,

Eric Leenman wrote:
> 
> I see that my the 'ASCII-layout' is not what it should be.
> The command deletes all 200.
> 
> How can I give the command to deleted only the 1st, 3rd, 5th, 7th, ect.. 
> 200?
> And leaving (if any) the 2nd, 4th, 6th, ect.

  %s/\<200\>\(\%(.\{-\}\<200\>\)\?\)/   \1/g

this again replaces 200 with three spaces; if there is another 200
following with some text between them (this text can not contain a third
200, because of the non-greedy match forced by "\{-\}") we keep this
200 together with the interspersed text.

> [snip]
> 
>>> How do I deleted per line all the 'odd' 200?

Now I understand. When I read this for the first time, I wondered what's
so 'strange' about 200 -- I didn't think of 'odd' as the opposite of
'even'.

> [snip]
> 
>> use the 'g' flag of the substitute command:
>>   :%s/\<200\>/   /g
> 
> [snip]

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: Deleting a repetative pattern

2006-08-02 Thread Jürgen Krämer

Hi,

Eric Leenman wrote:
> 
> I see that my the 'ASCII-layout' is not what it should be.
> The command deletes all 200.
> 
> How can I give the command to deleted only the 1st, 3rd, 5th, 7th, ect.. 
> 200?
> And leaving (if any) the 2nd, 4th, 6th, ect.

  %s/\<200\>\(\%(.\{-\}\<200\>\)\?\)/   \1/g

this again replaces 200 with three spaces; if there is another 200
following with some text between them (this text can not contain a third
200, because of the non-greedy match forced by "\{-\}") we keep this
200 together with the interspersed text.

> [snip]
> 
>>> How do I deleted per line all the 'odd' 200?

Now I understand. When I read this for the first time, I wondered what's
so 'strange' about 200 -- I didn't think of 'odd' as the opposite of
'even'.

> [snip]
> 
>> use the 'g' flag of the substitute command:
>>   :%s/\<200\>/   /g
> 
> [snip]

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: Deleting a repetative pattern

2006-08-02 Thread Jürgen Krämer

Hi,

Eric Leenman wrote:
> 
> I have a file which contains lines like below
> 
> Line   18 |200  040  200 
>   200  200  051  200  1C2  200  2E2  Line   18 | 
> 200  040  200  040  200  052  200  1B9  200  2F4  
> Line   18 |200  040  200 
>   040  200  200  200  1C2  200  2DC
> Line   18 |200  040  200 
>   040  200  063  200  1D6  200  2D4
> 
> How do I deleted per line all the 'odd' 200?
> So that it becomes like:
> 
> Line   18 |   040
>   200  051 1C2 2E2  Line   18 |  
>   040 040  052   
>1B9 2F4  Line   18 |  
>   040 040  200 1C2 2DC
> Line   18 |   040
>   040  063 1D6 2D4

use the 'g' flag of the substitute command:

  :%s/\<200\>/   /g

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: Sorting a file

2006-08-02 Thread Jürgen Krämer

Hi,

Eric Leenman wrote:
> 
> I have a long file which contains like:
> ##
>   | 0123456
> ##
> Line   18 |   123
> Line   19 |abc
> --
> Line  332 |xyz
> ##
>   | 0123456
> ##
> Line   18 |   641
> Line   19 |  GHI
> --
> Line  332 |  vcx
> ##
>   | 0123456
> ##
> 
> 
> How do I sort this file so that
> - all line 18 , i.e., comes under each other? And line 19 , and so on.
> - removes the lines starting with ###
> - removes the lines starting with ---
> - removes the lines starting with spaces
> 
> So that what remains look like this:
> ...
> Line   18 |   123
> Line   18 |   641
> Line   19 |abc
> Line   19 |  GHI
> Line  332 |xyz
> Line  332 |  vcx

  :g/^\(###\|---\|   \)d
  :%!sort

Note that the final order of lines with same numbers depends on the
whole line -- Lines with more spaces after "Line  ### |" will come out
first.

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: Clearing Jumplist

2006-07-31 Thread Jürgen Krämer

Hi,

SHANKAR R-R66203 wrote:
> 
>When I open a particular file, I want to clear all the jumplist.
>How do I do that ? Is there any function when called clears the
> jumplist.

I don't think there is a function for this. The best way I could think
of is to set the jumplist to the same (current) position 100 times

  :let i = 0 | while i < 100 | mark ' | let i = i + 1 | endwhile

See ":help jumplist" for a reason for using the magic number 100.

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: Add to jumplist

2006-07-31 Thread Jürgen Krämer

Hi,

SHANKAR R-R66203 wrote:
> 
>   Is there a function, to add the line under the cursor to the jump-list
> ?
> 
>   This may sound strange. I am coding a function in which "from the
> current line, the cursor moves to a different line or a file
> altogather."
>  I want a way to come back if needed by the CTRL-O command

perhaps this excerpt from ":help jumplist" helps you

| When the |:keepjumps| command modifier is used, jumps are not stored in the
| jumplist.  Jumps are also not stored in other cases, e.g., in a |:global|
| command.  You can explicitly add a jump by setting the ' mark.


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: au! failure in vimrc

2006-07-31 Thread Jürgen Krämer

Hi,

Bill McCarthy wrote:
> 
> Suppose two plugins define autocmds, so after start Vim,
> 
> :au FuncUndefined
> 
> displays:
> 
> * call AsNeeded(1,expand(""))
> Tlist_*   source C:\vim\vimfiles\plugin\taglist.vim
> 
> Now I add a line to my _vimrc:
> 
> au! FuncUndefined * call Foo()
> 
> Now after starting Vim and typing :au FuncUndefined
> 
> * call Foo()
>   call AsNeeded(1,expand(""))
> Tlist_*   source C:\vim\vimfiles\plugin\taglist.vim
> 
> It did not replace!

it can't replace. Your _vimrc is sourced before all plugins, so at the
time your autocommand command is executed there's no other autocommand
to be replaced.

> Now removing the line I added to _vimrc, starting Vim and
> typing :au! FuncUndefined * call Foo()
> 
> I get what I expected from :au FuncUndefined
> 
> Tlist_*   source C:\vim\vimfiles\plugin\taglist.vim
> * call Foo()
> 
> Vim only appears to fail in startup - it is not just a
> script error.  If I write a small script file that just
> contains the line:  au! FuncUndefined * call Foo()
> 
> Sourcing that script works just like typing the command.

Putting this script in the after\plugin directory of the local or
personal part of your runtime path (i.e., $VIM\vimfiles\after\plugin or
$HOME\vimfiles\after\plugin) is the best way to replace or delete an
existing autocommand.

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: Visual select / paste behaviour

2006-07-28 Thread Jürgen Krämer

[Resending this because I noticed that the original mail had been
encoded with base64 by either my mail client or a server on the way
to the mailing list.]

Hi,

Roel Vanhout wrote:
> 
> Take the following example:
> 
> c:\test.txt
> 
> When the cursor is on the 'm' of 'myid' and I press 'vw', a word is 
> selected in visual mode. However, the " at the end of 'myid' is also 
> selected. How do I change the list of 'word separators'?

to be exact 'w' in visual word does NOT select a word but it extends the
current selection to the START of the next "word" (for a definition of
"word" see ":help word"). So in your case 'viw' would be better. This
starts visual mode and selects the Inner Word. This works on any letter
of "myid" and does not select the following quote.

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: Visual select / paste behaviour

2006-07-28 Thread Jürgen Krämer

Hi,

Roel Vanhout wrote:
> 
> Take the following example:
> 
> c:\test.txt
> 
> When the cursor is on the 'm' of 'myid' and I press 'vw', a word is 
> selected in visual mode. However, the " at the end of 'myid' is also 
> selected. How do I change the list of 'word separators'?

to be exact 'w' in visual word does NOT select a word but it extends the
current selection to the START of the next "word" (for a definition of
"word" see ":help word"). So in your case 'viw' would be better. This
starts visual mode and selects the Inner Word. This works on any letter
of "myid" and does not select the following quote.

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: Matching non-capitalized words?

2006-07-26 Thread Jürgen Krämer

Hi,

Tim Chase wrote:
> > >   :%s/\<[a-z]\+\>//gI
> > another option is to include \C in the regular expression itself:
> >
> > :%s/\C\<[a-z]\+\>//g
> 
> One should be careful about this, as the help states:
> 
> :help /\C
> 
> 
>   Note that 'ignorecase', "\c" and "\C" are not
>   used for the character classes.

this means that \u always matches uppercase characters regardless of
whether ignorecase is set or not. \c is (at least in this case)
equivalent to setting ignorecase before search -- \u still matches
only uppercase letters. Because \C is used to make a pattern independent
of the current value of ignorecase, \u does not change when used with
\C either.

> And when you look up
> 
>   :help /character-class
> 
> it shows you what's considered a character class.  I don't know 
> if the [...] notation is considered a character-class or not, but 
> the \u \l etc are listed there.

[...] is not considered a character class but a collection. As such it
behaves differently depending on the current value of ignorecase. If
set [A-Z] matches lowercase letters, too, as is the case when \c is
included in the search pattern.

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: Matching non-capitalized words?

2006-07-25 Thread Jürgen Krämer

Hi,

Tim Chase wrote:
>
> > Make sure 'ignorecase' is off:
> >
> > :set noignorecase
> >
> > :%s/\<[a-z]\+\>//g
> 
> If you don't want to bung with your vim-wide (or bufferwide) 
> settings, you can always just change your :s to include the "I" flag.
> 
>   :%s/\<[a-z]\+\>//gI

another option is to include \C in the regular expression itself:

:%s/\C\<[a-z]\+\>//g

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: search and result

2006-07-25 Thread Jürgen Krämer

Hi,

SHANKAR R-R66203 wrote:
>
> I am actually having a little bit complicated situation.
> Inside a search() fucntion, can I use, variables.
> The part of the code is given below.
> 
> 
> let rs_sig = expand("")
> exec '1'
> exec '/^\s*module\s\+\w\+'
> let rs_line=getline(".")
> let rs_ModuleName=matchstr(rs_line,"\\<\\w\\+\\>",0,2)
> exec 'tabedit D:\Profiles\r66203\_tags\LF\debussy.harlech'
> if search('/^' . rs_sig . '\t' . rs_ModuleName . '\t') != 0
 ^^

the slash is not needed.

> echo "Got the signal inside a module"
> else
> echo "Not got it"
> endif

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: search and result

2006-07-25 Thread Jürgen Krämer

Hi,

SHANKAR R-R66203 wrote:
>
> In a function,
>I am executing a search.
>I have to implement different things based on whether search got a
> result or failed with an error.
> 
>   exec '/^\w\+\t\w\+'
> 
> In the next line, I have to check whether the test passed or failed.
> 
> How do I do this ?

use the search() function:

  if search('/^\w\+\t\w\+') != 0
    " do something
  endif

Regards,
Jürgen

-- 
Jürgen Krämer  Softwareentwicklung
HABEL GmbH & Co. KGmailto:[EMAIL PROTECTED]
Hinteres Öschle 2  Tel: +49 / 74 61 / 93 53 - 15
78604 Rietheim-WeilheimFax: +49 / 74 61 / 93 53 - 99


Re: How can I know difference between Vim6.3 and Vim 6.2?

2006-07-21 Thread Jürgen Krämer

Hi,

[EMAIL PROTECTED] wrote:
> 
> This may be a silly question, but I had done a search and did not found the
> answer.
> 
> The help version7 tells difference between version6 and version7
> 
> However, 6.1 and 6.2 has differences, 6.2 and 6.3 has differences, where is
> the document about differences between the minor versions?

  :help version-6.3

Regards,
Jürgen

-- 
Jürgen Krämer  Softwareentwicklung
HABEL GmbH & Co. KGmailto:[EMAIL PROTECTED]
Hinteres Öschle 2  Tel: +49 / 74 61 / 93 53 - 15
78604 Rietheim-WeilheimFax: +49 / 74 61 / 93 53 - 99


Re: :split above below...

2006-07-20 Thread Jürgen Krämer

Hi,

Marco Kunze wrote:
> 
> Is there a method to tell vim whether I would like to open the new file below 
> or 
> above the current window when using :split?

for a permanent setting there are two options:

  :help 'splitbelow'
  :help 'splitright'

For a case by case decision you can prefix any command with

  :vertical
  :leftabove
  :aboveleft
  :rightbelow
  :belowright
  :topleft

or

  :botright

> Or is there a way to swap two windows?

See

  :help CTRL-W_x

Regards,
Jürgen

-- 
Jürgen Krämer  Softwareentwicklung
HABEL GmbH & Co. KGmailto:[EMAIL PROTECTED]
Hinteres Öschle 2  Tel: +49 / 74 61 / 93 53 - 15
78604 Rietheim-WeilheimFax: +49 / 74 61 / 93 53 - 99


Re: Incompatible change in 7.0 which were not mentioned

2006-07-19 Thread Jürgen Krämer

Hi,

[EMAIL PROTECTED] wrote:
> 
> I've got it, "" will be interprated as "" in Vim 6.4, and 
> will be the command line argument of the :Explore
> However, in Vim 7.0, "" will NOT be "". it will still be ""
> 
> Note that the :h version7 does not noticed about the incompatible change.
> 
> Is this a bug or a feature?

from ":help version7" (lines 156 to 158):

| When defining a user command with |:command| the special items could be
| abbreviated.  This caused unexpected behavior, such as  being recognized
| as .  The items can no longer be abbreviated.

Regards,
Jürgen

-- 
Jürgen Krämer  Softwareentwicklung
HABEL GmbH & Co. KGmailto:[EMAIL PROTECTED]
Hinteres Öschle 2  Tel: +49 / 74 61 / 93 53 - 15
78604 Rietheim-WeilheimFax: +49 / 74 61 / 93 53 - 99


Re: OPen a dialog box

2006-07-19 Thread Jürgen Krämer

Hi,

SHANKAR R-R66203 wrote:
> 
>I have want to display a message (which I have in a variable), in a
> popup-dialog box.
> Is it possible to do in VIM. I have seen that in ccase.vim 
> In this plugin, in order to enter comments, a dialog box appears and
> then we have to type in the check in comments into it.
> I want to do almost the samething. Looked into ccase.vim, but no clues.

have a look at

  :help input()
  :help inputdialog()

Regards,
Jürgen

-- 
Jürgen Krämer  Softwareentwicklung
HABEL GmbH & Co. KGmailto:[EMAIL PROTECTED]
Hinteres Öschle 2  Tel: +49 / 74 61 / 93 53 - 15
78604 Rietheim-WeilheimFax: +49 / 74 61 / 93 53 - 99


Re: search history - more questions

2006-07-19 Thread Jürgen Krämer

Hi,

SHANKAR R-R66203 wrote:
> I found out that
>:his /
> Gives the listing of the search history.
> 
> In a particular file, I tried using
> :his /
> 
>   #  search history
>   4  \
>   5  ^I
>   6  crg_arm
>   7   
>   8  ipss
>  10  #
>  11  perl D:/Profiles/r66203/utils/v2html/vhier_ls.pl -f
> verilog.harlech > test.hier
>  13  \
>  14
> \(^\s*\(\\)[EMAIL PROTECTED](\#\s*(\s*\w\+\s*)\s\+\)\=\w\+\_s*(\(\/\/\
> )\=\)|\(^\s*\w\+\s\+#\s*(.\{-},\)
>  15
> \(\(^\s*\(\\)[EMAIL PROTECTED](\#\s*(\s*\w\+\s*)\s\+\)\=\w\+\_s*(\(\/\
> /\)\=\)|\\)
>  16
> \(\(^\s*\(\\)[EMAIL PROTECTED](\#\s*(\s*\w\+\s*)\s\+\)\=\w\+\_s*(\(\/\
> /\)\=\)|\(^\s*\w\+\s\+#\s*(.\{-},\)\)
>  17
> \(\(^\s*\(\\)[EMAIL PROTECTED](\#\s*(\s*\w\+\s*)\s\+\)\=\w\+\_s*(\(\/\
> /\)\=\)\\|\(^\s*\w\+\s\+#\s*(.\{-},\)\)
>  20  \
>  87  \
> 138  pllmrbi_ipi
> 155  ^\s*pllmrbi_ipi\>
> 156
> \(^\s*\(\\)[EMAIL PROTECTED](\#\s*(\s*\w\+\s*)\s\+\)\=\w\+\_s*(\(\/\/\
> )\=\)
> 162  \(^\s*\w\+\s\+#\s*(.\{-},\)
> 177  \
>>   192
> \(\(^\s*\(\\)[EMAIL PROTECTED](\#\s*(\s*\w\+\s*)\s\+\)\=\w\+\_s*(\(\/\
> /\)\=\)\|\(^\s*\w\+\s\+#\s*(.\{-},\)\)
> 
> I do not understand why the numbers are not consecutive.

whenever you re-use a search pattern by using  the search pattern
is removed from its current position in the history and put at the end
of it.

> How the search history can be deleted ??

There is a histdel() function.

> And finaly another question -
> 
> How do I put the result of the following command in a variable.
> :his / -2 

  :let var = histget('/', -2)

Regards,
Jürgen

-- 
Jürgen Krämer  Softwareentwicklung
HABEL GmbH & Co. KGmailto:[EMAIL PROTECTED]
Hinteres Öschle 2  Tel: +49 / 74 61 / 93 53 - 15
78604 Rietheim-WeilheimFax: +49 / 74 61 / 93 53 - 99


Re: escaping special characters in visual search

2006-07-17 Thread Jürgen Krämer

Hi,

Richard Emberson wrote:
> I've got the following visual maps which I use to do
> visual base searches:
> 
> vmap F y?"
> vmap f y/"
> 
> They work great, select some characters in visual mode and
> then enter 'f' (or 'F').
> The one caveat is if there are characters that have
> special meaning in searched such as the '[' ']' pair
> in the visual selection, then the search fails.
> Does anyone have a macro that will allow visual selection
> based searches that account for such special characters
> being in the selection?

this started as a macro, but to make use of the then new functions
getreg() and getregtype() I defined two helper functions:

if version >= 602

function! VisualSelection()
" Save register content and type.
let old_reg = getreg('"')
let old_regmode = getregtype('"')

" Calling this function has ended visual mode, so it must be started
" again before the selection can be yanked into the unnamed 
register.
normal gvy
let selection = @"

" Restore register content and type.
call setreg('"', old_reg, old_regmode)

return selection
endfunction

else

function! VisualSelection()
" Save register content and type.
let old_reg = @"

" Calling this function has ended visual mode, so it must be started
" again before the selection can be yanked into the unnamed 
register.
normal gvy
let selection = @"

" Restore register content and type.
let @" = old_reg

return selection
endfunction

endif

function! Escaped(text)
let result = escape(a:text, '\\/.*$^~[]')
let result = substitute(result, "\n$", "", "")
let result = substitute(result, "\n", '\\n', "g")
return result
endfunction

vnoremap  * :/=Escaped(VisualSelection())
vnoremap  # :?=Escaped(VisualSelection())

Regards,
Jürgen

-- 
Jürgen Krämer  Softwareentwicklung
HABEL GmbH & Co. KGmailto:[EMAIL PROTECTED]
Hinteres Öschle 2  Tel: +49 / 74 61 / 93 53 - 15
78604 Rietheim-WeilheimFax: +49 / 74 61 / 93 53 - 99


Re: substitute a char with newline

2006-07-12 Thread Jürgen Krämer

Hi,

Wim R. Crols wrote:
> 
> Side-question: What line endings does \r insert? Or is this dependant on 
> fileformat?

\r only inserts a end-of-line-marker which is then represented by NUL
internally (more or less). The actual line ending that is visible in the
file is determined when the file is written by inspecting the fileformat
option.

Regards,
Jürgen

-- 
Jürgen Krämer  Softwareentwicklung
HABEL GmbH & Co. KGmailto:[EMAIL PROTECTED]
Hinteres Öschle 2  Tel: +49 / 74 61 / 93 53 - 15
78604 Rietheim-WeilheimFax: +49 / 74 61 / 93 53 - 99


Re: substitute a char with newline

2006-07-12 Thread Jürgen Krämer

Hi,

Fabio Rotondo schrieb:
> 
> I have a text file with many lines made like this:
> 
> [EMAIL PROTECTED]@[EMAIL PROTECTED]@
> 
> And I'd like to have them splitted on "@" in newlines.
> 
> I have tried:
> 
> :%s/@/\n/g
> 
> but it does not work.
> What am I missing?

\n in the second part of a substitution denotes the NUL character which
is used internally to represent end-of-line. To insert newlines you
have to use \r:

  :%s/@/\r/g

Regards,
Jürgen

-- 
Jürgen Krämer  Softwareentwicklung
HABEL GmbH & Co. KGmailto:[EMAIL PROTECTED]
Hinteres Öschle 2  Tel: +49 / 74 61 / 93 53 - 15
78604 Rietheim-WeilheimFax: +49 / 74 61 / 93 53 - 99


Re: Shortest Pattern Match

2006-07-12 Thread Jürgen Krämer

Hi,

Bob Fleming wrote:
> Hi all, 
> 
> I believe vim carries out greedy pattern matching, i.e. the longest pattern
> found will be used. Is there a way of performing shortest matching ?
> 
> As an example, I have the following text:
> 
> fe fi fo united kingdom fe fi fo 0911 209 30 30
> 
> and I want to delete everything up to the word united so I used :%s/.*fo //
> but this deleted everything up to 0911.

have a look at ":help /\{"

  :%s/.\{-\}fo //

Another way to remove everything in front of "united" is

  :%s/.*\zeunited//

for the last "united" on the line and

  :%s/.\{-}\zeunited//

for the first "united" (see ":help /\ze" for the special meaning of \ze)

Regards,
Jürgen

-- 
Jürgen Krämer  Softwareentwicklung
HABEL GmbH & Co. KGmailto:[EMAIL PROTECTED]
Hinteres Öschle 2  Tel: +49 / 74 61 / 93 53 - 15
78604 Rietheim-WeilheimFax: +49 / 74 61 / 93 53 - 99


Re: Vim6.4: Some weird matching highlight

2006-07-11 Thread Jürgen Krämer

Hi,

Johnathan wrote:
> 
> When editing some .cc files (no apparent pattern), I seem to get some  
> weird can't-be-turned-off red highlighting. Some code snippet:
> 
> 
>1 int main()
>2 {
>3 if (1=1)
>4 [
>5 fail.push_back(students[i]);
>6 else
>7 pass.push_back(students[i]);
>8 }
> 
> without the [ on line 4, everything is colour-free.
> 
> As soon as I put the [ in line 4, the ;'s on line 5 & 7 as well as the }  
> on line 8.

I would guess it's some kind of error highlighting -- semicolons are not
allowed inside square brackets (unless they are inside a string or a
comment) -- and because the square bracket has not been closed the
closing curly brace in line 8 is an error, too.

Regards,
Jürgen

-- 
Jürgen Krämer  Softwareentwicklung
HABEL GmbH & Co. KGmailto:[EMAIL PROTECTED]
Hinteres Öschle 2  Tel: +49 / 74 61 / 93 53 - 15
78604 Rietheim-WeilheimFax: +49 / 74 61 / 93 53 - 99


Re: Irritating column numbers with encoding=utf-8

2006-07-05 Thread Jürgen Krämer

Hi,

Bram Moolenaar wrote:
>
> Jürgen Krämer wrote:
>
>> with 'encoding' set to "utf-8" there is a quite confusing (to me)
>> difference between the column number and my expectations (supported by
>> the virtual column number) if there are non-ASCII characters on the
>> line. I don't know what the intended meaning of "column count" and the
>> intended behaviour of "cursor()" are, but it seems they both depend on
>> the size of the encoded characters. I always thought "nth column" was
>> more or less a synonym for "nth character on a line" while "nth virtual
>> column" meant "nth cell on a screen line".
>>
[snipped
>>
>> I don't know whether the shown behaviour is a bug or just a feature I
>> don't like, but in summary I think "column number" should really
>> represent a character count (i.e, corresponding to what the user sees),
>> not a byte count depending on the underlying encoding.
>>
>> I have seen this behaviour in VIM 6.2, 6.3, 6.4, and 7.0, so changing
>> the code will definitely introduce an incompatibility. So the final
>> question is: What do you (Vimmers) and you (Bram) think: is there a need
>> for a change.
>
> I don't know why you call this a column count, in most places it's
> called a byte count.  Perhaps in some places in the docs the remark
> about this actually being a byte count is missing.

sorry, the "column count" in the first paragraph should have been a
"column number". I called it so because I have the statusline option set
to

  %<%f%= [%1*%M%*%{','.&fileformat}%R%Y] [%6l,%4c%V] %3b=0x%02B %P

and noticed that "%4c-%V" displayed two numbers instead of the one I
expected, because I knew there were no tabs or unprintable characters
on that line. Even more disturbing was the fact that the first number
(the column number) was bigger than the second one (the virtual column
number). So I checked ":help statusline" and it told me

c N   Column number.
v N   Virtual column number.
V N   Virtual column number as -{num}.  Not displayed if equal to 'c'.

> You could also want a character count.  But what is a character when
> using composing characters?  E.g., when the umlaut is not included in
> a character but added as a separate composing character?

I would say that a character is what the user sees. Why should he (be
forced to) know wheter "ä" is represented internally as LATIN SMALL
LETTER A WITH DIAERESIS or as LATIN SMALL LETTER A plus COMBINING
DIARESIS? So in my opinion "column count" is equivalent to "character
count" unless there are characters like tabs and unprintable ones that
have a special representation -- on the screen, not internally.

> It's not so obvious what to do.  In these situations I rather keep it as
> it is.

I know it's a big change and would introduce imcompatibiliy with older
versions, but here is another example: Take this line (ignoring the
leading spaces)

  ääbbcc

and the following commands

  :s/\%3c../xx/
  %s/^..\zs../xx/

>From my point of view they should both replace the 3rd and 4th column
with "xx". When encoding is set to latin1 they do, but not when it is
set to utf-8 -- the first one replaces "äb" with "xx". As a user I would
be really stumbled and ask "Why that, it's the same text as before."

Changing these commands to

  :s/\%2c../xx/
  %s/^.\zs../xx/

makes things even more irritating. The second one works as expected, now
correctly replacing "äb" with "xx", but the first one fails with "E486:
Pattern not found: \%2c..". Again: Ought I (as a user) really need to
know that \%2c depends on the number of non-ASCII letters in front of
the column I'm interested in?

Regards,
Jürgen

-- 
Jürgen Krämer  Softwareentwicklung
HABEL GmbH & Co. KGmailto:[EMAIL PROTECTED]
Hinteres Öschle 2  Tel: +49 / 74 61 / 93 53 - 15
78604 Rietheim-WeilheimFax: +49 / 74 61 / 93 53 - 99


Re: Irritating column numbers with encoding=utf-8

2006-07-05 Thread Jürgen Krämer

Hi,

James Vega wrote:
>
> On Wed, Jul 05, 2006 at 11:50:51AM +0200, Jürgen Krämer wrote:
>>
>> with 'encoding' set to "utf-8" there is a quite confusing (to me)
>> difference between the column number and my expectations (supported by
>> the virtual column number) if there are non-ASCII characters on the
>> line.
>
> Column number n is really the nth byte on that line.  This is described
> at ":help /\%c".  This description should explain all the behavior
> you're seeing.  This is the intended behavior and I'm not sure of a way
> off-hand to get the visual character count like you want.

yes, it does *explain* the behaviour. But it makes things even worse.
Suppose I have some lines with aligned data (just like a table) where I
want to replace certain columns with dashes, e.g.,

  PeterTraurig irgendwo  0
  Hänschen Klein   unterwegs 1
  Jürgen   Krämer  hier  2

  :%s/\%18c.*\%27c/-/

should strike out the third column of the table, but the result is

  PeterTraurig - 0
  Hänschen Klein  -s 1
  Jürgen   Krämer-   2

which is depending on the random number of non-ASCII characters in front
of the used position, characters whose internal representations should
never be relevant for this substitution, because the user cannot know
them.

Since it works as documented it is hard to call it a bug, but I would
really consider it a mis-feature, because it works in such a
non-predictable way.

To work around the problem in this example is not that hard -- I can use
/\%...v instead. The example in my original mail poses a bigger problem
(to me) -- I'd like to switch to "encoding=utf-8" as default, but I
often need to work with text files of fixed line length. With encoding
set to "latin1" the difference between column number and virtual column
number in the status line is a visual clue that there is a tabular or a
control code in the line, reminding me to look for this character. With
UTF-8 encoding this hint would be rendered useless because of all those
little umlauts in German. :-(

But perhaps this is just my special problem.

Regards,
Jürgen


-- 
Jürgen Krämer  Softwareentwicklung
HABEL GmbH & Co. KGmailto:[EMAIL PROTECTED]
Hinteres Öschle 2  Tel: +49 / 74 61 / 93 53 - 15
78604 Rietheim-WeilheimFax: +49 / 74 61 / 93 53 - 99


  1   2   >