How to trigger a screen update from RealWaitForChar

2006-08-18 Thread Brad Beveridge

Hi all, I'm working with a Vim that has been hacked so that you can
get callbacks when data appears on a socket.
Basically, our callback system works in pretty much the same way as
the code in FEAT_SNIFF.  We add the filedescriptors that we are
interested in to the select/poll code in os_unix, if there is data
pending on a socket then we callback a registered function, which
should clear the data from the socket.
In my particular case, the callback calls into Lisp code in our
embedded Lisp interpreter, which writes data to buffers using
ml_replace and ml_append.

Q1) Is using ml_append from (effectively) within RealWaitForChar a bad
thing?  At the moment it appears to work properly.

At the moment, after the callback has run we call
screen_update(NOT_VALID).  However, from what I can see, calling
screen_update may (does?) re-call RealWaitForChar, which can retrigger
the callback, etc.
Q2) Is this nesting of RealWaitForChar a bad thing? (I thing it may be)

Q3) What is the correct way/place to trigger screen_update(NOT_VALID)?
How should I trigger it from within RealWaitForChar?

One other point to consider, although we may do callbacks,
RealWaitForChar may not have keyboard input - what should
RealWaitForChar return in this case?

If the list would like to see this code, I can post a patch, or you
can use Darcs to get a Vim+Callbacks+ECL from
http://theclapp.org/repos/vim70+async+ecl/.

Q4) Would this callback mechanism be more generally useful for other
scripting engines?

Cheers
Brad


Re: Fastest way to append line or char to a buffer

2006-08-18 Thread Brad Beveridge

On 16/08/06, Brad Beveridge [EMAIL PROTECTED] wrote:

On 16/08/06, Bram Moolenaar [EMAIL PROTECTED] wrote:

 Brad -

  As a side note, if I wanted to get really fast char append, how does
  this method sound:
  1) In a structure (not sure if a mem_line or bufT struct), have three
  new entries
  uint current_line_num;
  uchar *current_line_buffer;
  uint current_line_alloced;
  2) current_line_buffer points to the string data for the current line,
  it starts off at a sane size (say 80, or screen_width), and doubles in
  alloced size when it is too full.
  3) ml_append_char (or whatever I call it), will check the target line
  number against current_line_number, if the match then
- append the char, possibly reallocing the current_line_buffer if we
  have run out of space
  ELSE, the edit line number and our cached line don't match
- trim the size of the current_line_buffer to match the STRLEN of the line
- alloc a new oversized line buffer and copy the new edit line into it
- append the char as above

 Vim caches the last changed line, you could do something with that.
 Start looking at ml_flush_line(), you can find the rest from there.

  Would this kind of optimisation be more widely useful?

 Perhaps.  Changing the same line several times is not unusual.  It
 mostly depends on how much code would need to be changed compared to
 how much we would gain.

 - Bram


Thanks for the tips, I'll test all this out and see what I can come up
with.  I also accidentally posted just to Bram, so I've included the
list in this reply.

Thanks
Brad


I ended up writing a string append function, that has sped up my
output code by a couple of orders of magnitude :)  Here it is, does it
look sane?

Cheers
Brad

/*
* Append string to line lnum, with buffering, in current buffer.
*
* Always makes a copy of the incoming string
*
* Check: The caller of this function should probably also call
* changed_lines(), unless update_screen(NOT_VALID) is used.
*
* return FAIL for failure, OK otherwise
*/
   int
ml_append_string(lnum, string, slen)
   linenr_Tlnum;
   char_u  *string;
   int slen;
{
   int append_len = 0;
   int line_len = 0;
   if (slen == -1)
   append_len = STRLEN(string);
   else
   append_len = slen;
   if (string == NULL) /* just checking... */
   return FAIL;

   if (lnum == 0)
   ml_append (lnum, string, slen, 0);

   /* When starting up, we might still need to create the memfile */
   if (curbuf-b_ml.ml_mfp == NULL  open_buffer(FALSE, NULL) == FAIL)
   return FAIL;

#ifdef FEAT_NETBEANS_INTG
   /*
#error I am 99% sure this is broken
   if (usingNetbeans)
   {
   netbeans_removed(curbuf, lnum, 0, (long)STRLEN(ml_get(lnum)));
   netbeans_inserted(curbuf, lnum, 0, string, (int)STRLEN(string));
   }
   */
#endif
   if (curbuf-b_ml.ml_line_lnum != lnum)  /* other line buffered */
   {
   ml_flush_line(curbuf);  /* flush it, this frees
ml_line_ptr */

   /* Take a pointer to the existing line, will get re-alloced right
* away below because it is not big enough */
   curbuf-b_ml.ml_line_ptr = vim_strsave(ml_get(lnum));
   curbuf-b_ml.ml_line_len = STRLEN(curbuf-b_ml.ml_line_ptr);
   curbuf-b_ml.ml_line_lnum = lnum;
   }
   /* By here,
* curbuf-b_ml.ml_line_ptr - is filled with the correct existing line
* curbuf-b_ml.ml_line_len - is the alloced size of the line
*/
   line_len = STRLEN(curbuf-b_ml.ml_line_ptr);
   if (curbuf-b_ml.ml_line_len  line_len + append_len + 1)
   {
   int new_len = (curbuf-b_ml.ml_line_len + line_len + 1) * 2;
   char_u *new_line;
   if (new_len  80) new_len = 80;
   new_line = vim_strnsave(curbuf-b_ml.ml_line_ptr, new_len);
   vim_free(curbuf-b_ml.ml_line_ptr);
   curbuf-b_ml.ml_line_ptr = new_line;
   curbuf-b_ml.ml_line_len = new_len;
   }
   /* by here:
* ml_line_ptr is allocated to fit the current line + the append
* ml_line_len is the total alloced size of the line
*/
   STRCPY (curbuf-b_ml.ml_line_ptr[line_len], string);  /* Append
our string */
   curbuf-b_ml.ml_line_ptr[line_len + append_len] = NUL; /* End the line */
   curbuf-b_ml.ml_flags = (curbuf-b_ml.ml_flags | ML_LINE_DIRTY)  ~ML_EMPTY;

   return OK;
}


Re: How to trigger a screen update from RealWaitForChar

2006-08-18 Thread Gautam Iyer
On Thu, Aug 17, 2006 at 11:35:09PM -0700, Brad Beveridge wrote:

 
 Hi all, I'm working with a Vim that has been hacked so that you can
 get callbacks when data appears on a socket.
 Basically, our callback system works in pretty much the same way as
 the code in FEAT_SNIFF.  We add the filedescriptors that we are
 interested in to the select/poll code in os_unix, if there is data
 pending on a socket then we callback a registered function, which
 should clear the data from the socket.
 In my particular case, the callback calls into Lisp code in our
 embedded Lisp interpreter, which writes data to buffers using
 ml_replace and ml_append.
 
 [snip]

 Q4) Would this callback mechanism be more generally useful for other
 scripting engines?

Hi Brad,

I'm not sure about other scripting engines -- But I can certainly think
of one very good use: Poling for email :). If you add
/var/spool/mail/uname to the select'ed file descriptors, then it would
be nice to have a little message line pop up saying You have new
mail. I know this can be done using biff / xbiff / kbiff, etc. But I
much prefer a vimbiff :-).

GI

-- 
When an actress saw her first strands of gray hair, she thought she'd
dye.


Netrw and cindent

2006-08-18 Thread Mark S. Williams
I think I've uncovered an odd bug involving Netrw and the cindent local 
buffer option for Java files, where cindent is unset under certain 
conditions.


To track down the bug I removed all my Java file type plugins and 
created a new Java file type plugin called java.vim which contains only 
the following:


if exists(b:did_java_vim)
  finish
endif
let b:did_java_vim = 1
setlocal cindent


There are two scenarios that can reproduce the bug:

Scenario #1
---
1. Start vim in a dir with Foo.java
2. :E and select Foo.java
3. :setl  cindent is set.
4. :E and select Foo.java again.
5. :setl and cindent is not set.

Scenario #2
---
1. Start vim in a dir with Foo.java and Bar.java
2. :E and select Foo.java
3. :setl  cindent is set.
4. :E and select Bar.java
5. :setl  cindent is set.
6. :2b to return to Foo.java
7. :setl and cindent is not set.

It seems the the bug involves Netrw, I can't reproduce it when I open 
files with :e.


Quite a puzzler. Can anyone else reproduce this one?

Thanks in advance,
-Mark


Re: Netrw and cindent

2006-08-18 Thread A.J.Mechelynck

Mark S. Williams wrote:
I think I've uncovered an odd bug involving Netrw and the cindent local 
buffer option for Java files, where cindent is unset under certain 
conditions.


To track down the bug I removed all my Java file type plugins and 
created a new Java file type plugin called java.vim which contains only 
the following:


if exists(b:did_java_vim)
  finish
endif
let b:did_java_vim = 1
setlocal cindent


There are two scenarios that can reproduce the bug:

Scenario #1
---
1. Start vim in a dir with Foo.java
2. :E and select Foo.java
3. :setl  cindent is set.
4. :E and select Foo.java again.
5. :setl and cindent is not set.

Scenario #2
---
1. Start vim in a dir with Foo.java and Bar.java
2. :E and select Foo.java
3. :setl  cindent is set.
4. :E and select Bar.java
5. :setl  cindent is set.
6. :2b to return to Foo.java
7. :setl and cindent is not set.

It seems the the bug involves Netrw, I can't reproduce it when I open 
files with :e.


Quite a puzzler. Can anyone else reproduce this one?

Thanks in advance,
-Mark




To check which script last set the option, use :verbose setl cindent? 
(without quotes, but with the question mark). If it does mention netrw, 
check near the top of the netrw script which version of netrw you're 
running. You may be able to obtain a newer version from vim-online or 
from Dr. Chip's site.



Best regards,
Tony.


Re: How to insert text via script/function call ?

2006-08-18 Thread Marius Roets

On 8/18/06, Meino Christian Cramer [EMAIL PROTECTED] wrote:

Hi,

 I often need to place a header above a function defintion (C-source)
 fpr documentational purposes.

 What I treid is to write a short function for vim, which dioes insert
 the text skeleton -- but I did not find any already existing function
 in the API which does this for me. With :i I got weird effects --
 sure my fault, but... .

 How can I insert text via a script ?

 Kind regards,
 mcc



Hi
I got this in my .vimrc:

function! ReadSkeleton()

  if exists (g:Skeleton_path)
 let skeleton_path = g:Skeleton_path
  else
 let skeleton_path = getcwd()
  endif

  let filenameList = split (glob ( skeleton_path . /*.*) , \n)
  let filenameList = insert (filenameList, Select skeleton to load)
  let choiceList = copy (filenameList)
  let choiceList = map (choiceList, 'index(filenameList,v:val) .. . v:val')
  let choiceList[0] = Select skeleton to load
  let listLen = len(choiceList)
  let choiceList = add (choiceList, listLen . . Browse for some
other folder (gui ONLY))
  let choice = inputlist(choiceList)
  echo choice
  let skeletonName = 
  if choice == listLen
 Do the browse thingie if possible
 if has(browse)
   let skeletonName = browse(0,Select session to
restore,skeleton_path,)
   echo skeletonName
endif
  elseif choice  0
 Load the file
 let skeletonName = filenameList[choice]
  echo setting skeletonName to . skeletonName
  endif
  if skeletonName != 
 execute 0read  . skeletonName
  endif
endfunction
nmap F4 :call ReadSkeleton()cr
let Skeleton_path = /home/mroets/.vim/skeletons

I put all the skeletons for programs (perl, c , php etc), each in
their own file in a directory, and set Skeleton_path to this directory
in my .vimrc. Now I press F4 and choose which skeleton I want for my
new file.

HTH
Marius


an indentation question

2006-08-18 Thread steven woody

i use vim on both linux and windows. but i found their indentation
behavior a little differently.

say i was coding a c program on the below line

void  foo_fun( int p1

then i press return on linux, the cursor come to a pleasant position,
that became,

void foo_fun( int p1
   , int p2 );

but when i was on windows and do the same thing, it became

void foo_fun( int p1
, int p2 );

and i dont like that.

i compared .vimrc files on linux and windows, but got nothing.  so i
am wandering whether someone here got know a setting which helps.

thanks.

--
then sun rose thinly from the sea and the old man could see the other
boats, low on the water and well in toward the shore, spread out
across the current.


Re: an indentation question

2006-08-18 Thread A.J.Mechelynck

steven woody wrote:

i use vim on both linux and windows. but i found their indentation
behavior a little differently.

say i was coding a c program on the below line

void  foo_fun( int p1

then i press return on linux, the cursor come to a pleasant position,
that became,

void foo_fun( int p1
   , int p2 );

but when i was on windows and do the same thing, it became

void foo_fun( int p1
, int p2 );

and i dont like that.

i compared .vimrc files on linux and windows, but got nothing.  so i
am wandering whether someone here got know a setting which helps.

thanks.



there are some options which might be relevant, like 'cindent' and 
'indentexpr'. You might also want to check :filetype (without 
arguments) to see if filetype-related indentation is or isn't on on 
both sides.



Best regards,
Tony.


set listchars=tab:-,trail:-,eol:$

2006-08-18 Thread Adam Gray
So basically I have the following in my .vimrc

set listchars=tab:-,trail:-,eol:$

But it's slightly intrusive in the colour it is at the moment (dark
blue), and I was wondering if there was any easy way to set it to
something less overt, for example dark grey (I use a dark background).

Thanks!

Adam
-- 
Adam Gray
[EMAIL PROTECTED]


Re: set listchars=tab:-,trail:-,eol:$

2006-08-18 Thread A.J.Mechelynck

Adam Gray wrote:

So basically I have the following in my .vimrc

set listchars=tab:-,trail:-,eol:$

But it's slightly intrusive in the colour it is at the moment (dark
blue), and I was wondering if there was any easy way to set it to
something less overt, for example dark grey (I use a dark background).

Thanks!

Adam


:hi NonText ctermfg=darkgrey guifg=darkgrey
:hi clear SpecialKey
:hi link SpecialKey NonText

You may place them in your vimrc, or (maybe better) in a newly-created 
colourscheme: start with whatever colourscheme you're already using, 
copy it under a different name (but keeping the .vim extension) to 
~/vimfiles/colors (on Windows) or to ~/.vim/colors (on Unix), then add 
the above lines. If you aren't using any colorscheme yet, you can use 
the folowing as a source of inspiration, change it to your heart's 
delight (and see :help :colorscheme about how to invoke it):


- 8 - ~/.vim/colors/almost-default.vim
 Vim color file
 Maintainer:  Tony Mechelynck [EMAIL PROTECTED]
 Last Change: 2006 Aug 16
 ÷÷
 This is almost the default color scheme.  It doesn't define the Normal
 highlighting, it uses whatever the colors used to be.

 Only the few highlight groups named below are defined; the rest (most
 of them) are left at their compiled-in default settings.

 Set 'background' back to the default.  The value can't always be
 estimated and is then guessed.
hi clear Normal
set bg

 Remove all existing highlighting and set the defaults.
hi clear

 Load the syntax highlighting defaults, if it's enabled.
if exists(syntax_on)
  syntax reset
endif

 Set our own highlighting settings
hi Errorguibg=red   guifg=black
hi clear ErrorMsg
hi link  ErrorMsg   Error
hi CursorLine   guibg=#F4F4F4
hi clear CursorColumn
hi link  CursorColumn   CursorLine
hi clear helpBar
hi link  helpBarhelpHyperTextJump
hi clear helpStar
hi link  helpStar   helpHyperTextEntry
hi StatusLine   gui=NONE,bold   guibg=red   guifg=white
hi StatusLineNC gui=reverse,bold
hi TabLine  gui=NONEguibg=#DD   guifg=black
hi TabLineFill  gui=NONEguibg=#AA   guifg=red
hi User1ctermfg=magenta guibg=white guifg=magenta
hi User2ctermfg=darkmagenta guibg=#DD   guifg=magenta

 remember the current colorscheme name
let colors_name = almost-default

 vim: sw=2
- 8 -


Best regards,
Tony.


Search all text files in a directory for text

2006-08-18 Thread Jerin Joy

Hi,

I have a lot of source code distributed over a directory hierarchy
structure. I always need to find class declarations, instances where
variables are set etc. Usually I just go to command line and run
something like
find . -name *.vr -print | xargs grep 'class foo'

Isn't there an easier way to do this in vim? I can't use cscope since
the source is not in C.

Jerin


--
http://jerinj.blogspot.com/
--


Re: Search all text files in a directory for text

2006-08-18 Thread Marius Roets

On 8/18/06, Jerin Joy [EMAIL PROTECTED] wrote:

Hi,

I have a lot of source code distributed over a directory hierarchy
structure. I always need to find class declarations, instances where
variables are set etc. Usually I just go to command line and run
something like
find . -name *.vr -print | xargs grep 'class foo'

Isn't there an easier way to do this in vim? I can't use cscope since
the source is not in C.

Jerin


--
http://jerinj.blogspot.com/
--



Exuberant ctags supports 33 languages. Maybe yours is one of them:

http://ctags.sourceforge.net/

Marius


Problem or bug?

2006-08-18 Thread David Venus
Hi!

I ran across a problem today where I could not enter 2  characters in a
row into a KSH script I was editing. You could enter the first one, then
the screen would flash and repaint itself, then you could type any other
character except a . I had to enter a space than the 2nd , then
delete the space.

Is this a base VIM bug or a problem with the KSH syntax stuff? Anybody else
seen anything like this? This is the 7.0 release on Windows XP.

Thanks in advance for the help!


Dave Venus



Re: Search all text files in a directory for text

2006-08-18 Thread A.J.Mechelynck

Jerin Joy wrote:

Hi,

I have a lot of source code distributed over a directory hierarchy
structure. I always need to find class declarations, instances where
variables are set etc. Usually I just go to command line and run
something like
find . -name *.vr -print | xargs grep 'class foo'

Isn't there an easier way to do this in vim? I can't use cscope since
the source is not in C.

Jerin




:vimgrep /\class\_s\+foo\/ *.vr

which applies to Vim 7 only; in earlier versions of Vim you can use 
external grep though. The pattern between slashes is a Vim regular 
expression; I have arbitrarily put in \ (start of word), \ (end of 
word) and \_s\+ (one or more spaces, tabs and/or line breaks).


The results of vimgrep (or grep) end up in a quickfix error list and 
can be viewed using :cfirst, :cnext, :cprev, :clast, etc.


See
:help quickfix.txt
and in particular
:help :vimgrep
:help :grep
:help :cnext
etc.


Best regards,
Tony.


Re: windows unicode (iso10646-1) font for vim

2006-08-18 Thread Robert Hicks

Alan G Isaac wrote:
On Mon, 31 Jul 2006, (BST) Georg Dahn apparently wrote: 
I personally need Latin only and use Consolas: 
http://www.microsoft.com/downloads/details.aspx?familyid=22e69ae4-7e40-4807-8a86-b3d36fab68d3displaylang=en 
which (IMHO) is a great font. 


This package is only intended for licensed users of 
Microsoft Visual Studio 2005.  I'm not sure what

that means here ...
(intended for vs. licensed to?)



If you don't own VS2005...you can't use the font.

Robert



tabedit readonly

2006-08-18 Thread SHANKAR R-R66203
Hi,
  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.

Thanks
Shankar


Re: Problem or bug?

2006-08-18 Thread A.J.Mechelynck

David Venus wrote:

Hi!

I ran across a problem today where I could not enter 2  characters in a
row into a KSH script I was editing. You could enter the first one, then
the screen would flash and repaint itself, then you could type any other
character except a . I had to enter a space than the 2nd , then
delete the space.

Is this a base VIM bug or a problem with the KSH syntax stuff? Anybody else
seen anything like this? This is the 7.0 release on Windows XP.

Thanks in advance for the help!


Dave Venus





You might have a mapping or abbreviation

:verbose map! gt
:verbose iabbr gt

or a message could have been displayed too fast for you to notice

:messages


Best regards,
Tony.


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

2006-08-18 Thread A.J.Mechelynck

SHANKAR R-R66203 wrote:

Hi,
  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.

Thanks
Shankar





:tab sview foobar.txt

see
:help :tab
:help :sview


Best regards,
Tony.


Re: windows unicode (iso10646-1) font for vim

2006-08-18 Thread Robert Hicks

Georg Dahn wrote:

I am not sure, if they have CJK included yet, but
http://dejavu.sourceforge.net/wiki/index.php/Main_Page
is a set of Unicode fonts which are being worked at intensely.

--- A.J.Mechelynck [EMAIL PROTECTED] wrote:

As I already mentioned, on Windows I use Courier_New for Russian and
Arabic, and MingLiU for Chinese. For Latin-only editing sessions I use
Lucida_Console.


I personally need Latin only and use Consolas:

http://www.microsoft.com/downloads/details.aspx?familyid=22e69ae4-7e40-4807-8a86-b3d36fab68d3displaylang=en

which (IMHO) is a great font.

Best wishes,
Georg
They could have done better. The  symbol should have been centerlined 
so that = looked better. It is a clear font though.


Robert



Re: Search all text files in a directory for text

2006-08-18 Thread A.J.Mechelynck

Jerin Joy wrote:

Hi,

I'll try the ctags. Both vera and verilog are supported. I'm running
vim 6.4 so no vimgrep. Can't change it since I work on a remote login.

thanks,
Jerin


You can still invoke grep from Vim 6.4 (since you have an external grep 
 program installed): see :help :grep. Tags may be faster if you use 
them repeatedly in the same directories, but you have to generate the 
tags file first using Exuberant ctags or similar.


Best regards,
Tony.



On 8/18/06, A.J.Mechelynck [EMAIL PROTECTED] wrote:

Jerin Joy wrote:
 Hi,

 I have a lot of source code distributed over a directory hierarchy
 structure. I always need to find class declarations, instances where
 variables are set etc. Usually I just go to command line and run
 something like
 find . -name *.vr -print | xargs grep 'class foo'

 Isn't there an easier way to do this in vim? I can't use cscope since
 the source is not in C.

 Jerin



:vimgrep /\class\_s\+foo\/ *.vr

which applies to Vim 7 only; in earlier versions of Vim you can use
external grep though. The pattern between slashes is a Vim regular
expression; I have arbitrarily put in \ (start of word), \ (end of
word) and \_s\+ (one or more spaces, tabs and/or line breaks).

The results of vimgrep (or grep) end up in a quickfix error list and
can be viewed using :cfirst, :cnext, :cprev, :clast, etc.

See
:help quickfix.txt
and in particular
:help :vimgrep
:help :grep
:help :cnext
etc.


Best regards,
Tony.








Re: How to insert text via script/function call ?

2006-08-18 Thread Benji Fisher
On Fri, Aug 18, 2006 at 04:44:26AM +0200, Meino Christian Cramer wrote:
 Hi,
 
  I often need to place a header above a function defintion (C-source)
  fpr documentational purposes.
 
  What I treid is to write a short function for vim, which dioes insert
  the text skeleton -- but I did not find any already existing function
  in the API which does this for me. With :i I got weird effects --
  sure my fault, but... .
 
  How can I insert text via a script ?
 
  Kind regards,
  mcc

 One way to do this is the ClassHeader() function (and associated
map/autocommand) in my file of example vim functions, foo.vim :
http://www.vim.org/script.php?script_id=72
This one is pretty old:  I wrote it before there were such things as
buffer-local mappings and ftplugins.

HTH --Benji Fisher


Re: an indentation question

2006-08-18 Thread Benji Fisher
On Fri, Aug 18, 2006 at 10:36:32AM +0200, A.J.Mechelynck wrote:
 steven woody wrote:
 i use vim on both linux and windows. but i found their indentation
 behavior a little differently.
 
 say i was coding a c program on the below line
 
 void  foo_fun( int p1
 
 then i press return on linux, the cursor come to a pleasant position,
 that became,
 
 void foo_fun( int p1
, int p2 );
 
 but when i was on windows and do the same thing, it became
 
 void foo_fun( int p1
 , int p2 );
 
 and i dont like that.
 
 i compared .vimrc files on linux and windows, but got nothing.  so i
 am wandering whether someone here got know a setting which helps.
 
 thanks.
 
 
 there are some options which might be relevant, like 'cindent' and 
 'indentexpr'. You might also want to check :filetype (without 
 arguments) to see if filetype-related indentation is or isn't on on 
 both sides.
 
 
 Best regards,
 Tony.

 Also check the output of

:version

If one system has version 6.x of vim and the other has 7.0, that could
explain a lot of differences.  You will also see (after the feature
list) the location of the system vimrc file, if any.  You should compare
those (if they exist) as well as your personal vimrc files on the two
systems.

HTH --Benji Fisher


Re: an indentation question

2006-08-18 Thread A.J.Mechelynck

steven woody wrote:

On 8/18/06, A.J.Mechelynck [EMAIL PROTECTED] wrote:

steven woody wrote:
 i use vim on both linux and windows. but i found their indentation
 behavior a little differently.

 say i was coding a c program on the below line

 void  foo_fun( int p1

 then i press return on linux, the cursor come to a pleasant position,
 that became,

 void foo_fun( int p1
, int p2 );

 but when i was on windows and do the same thing, it became

 void foo_fun( int p1
 , int p2 );

 and i dont like that.

 i compared .vimrc files on linux and windows, but got nothing.  so i
 am wandering whether someone here got know a setting which helps.

 thanks.


there are some options which might be relevant, like 'cindent' and
'indentexpr'. You might also want to check :filetype (without
arguments) to see if filetype-related indentation is or isn't on on
both sides.




yes, filetype command returns different results, in linux it is

filetype detection: ON plugin:ON  indent: ON

but in windows, it is

filetype detection: ON plugin:OFF  indent: OFF

how to fix that?



Best regards,
Tony.






:filetype plugin indent on
or
:runtime vimrc_example.vim

(the latter includes the former). If you invoke the vimrc_example, place 
that near the top of your vimrc, before everything except (if present) 
setting the :language.


see :help :filetype.


Best regards,
Tony.

P.S. I'm no Vim official, just a user like you. Next time, please use 
reply to all rather than reply to sender so the list gets it and, if 
e.g. I've gone to bed, someone else can reply.


Re: tabedit readonly

2006-08-18 Thread Charles E Campbell Jr

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.
 

Why would you think it would?  I see no mention of a -R modifier for 
tabedit.  Here's the

help for tabedit:

:tabe[dit]  *:tabe* *:tabedit* *:tabnew*
:tabnew Open a new tab page with an empty window, after the current
   tab page.

:tabe[dit] [++opt] [+cmd] {file}
:tabnew [++opt] [+cmd] {file}
   Open a new tab page and edit {file}, like with |:edit|.

No minus-anythings there.  At least it'd seem more likely that a + 
something might work...


OK, so let's look around:

:he tabtab

to see a list of tab related help items/commands.  The first command on 
that list is


 :tab

The help for that says:

Execute {cmd} and when it opens a new window open a new tab page 
instead. ..snip..


OK, so let's look around for something that will open a new window, but 
in read-only
mode.  Doing  :he readonlytab gives us readonly, write-readonly, and 
noreadonly,

none of which seem to me to be likely to help.  So, let's try

:helpgrep readonly
:cope

Look over the list of matches in the quickfix window (which is what 
:cope opened)
for windows.txt; because, after all, what you want is to open a readonly 
window.

Hmm, there's a line:

windows.txt|185 col 30| Same as :split, but set 'readonly' option for 
this buffer.


which, when I hit the cr and go to it, mentions  something about the 
sview command.


So, put the two together:   :tab sview SomeFile
and you get your new tab with readonly set, opened to SomeFile.

Regards,
Chip Campbell





Re: an indentation question

2006-08-18 Thread Charles E Campbell Jr

A.J.Mechelynck wrote:



P.S. I'm no Vim official, just a user like you. Next time, please use 
reply to all rather than reply to sender so the list gets it and, 
if e.g. I've gone to bed, someone else can reply.


But, Anthony -- you get paid the top salary available for Vim mailing 
list personnel! :)

Of course, it's probably a bit difficult to buy a cup of coffee with it...

Regards,
Chip Campbell



Re: an indentation question

2006-08-18 Thread Tim Chase
But, Anthony -- you get paid the top salary available for Vim mailing 
list personnel! :)

Of course, it's probably a bit difficult to buy a cup of coffee with it...


And you're both still making twice my vim mailing-list salary! :)

-a mock-disgruntled tim






Re: an indentation question

2006-08-18 Thread A.J.Mechelynck

Charles E Campbell Jr wrote:

A.J.Mechelynck wrote:



P.S. I'm no Vim official, just a user like you. Next time, please use 
reply to all rather than reply to sender so the list gets it and, 
if e.g. I've gone to bed, someone else can reply.


But, Anthony -- you get paid the top salary available for Vim mailing 
list personnel! :)

Of course, it's probably a bit difficult to buy a cup of coffee with it...

Regards,
Chip Campbell





No, Dr. Chip, Bram earns more out of Vim than I do. Sure, he does more 
than just answer the mailing list, and I wouldn't want to be in his 
seat, so that's OK by me. Anyway, cup of coffee or no, any matters 
on-topic for the list had better stay on the list: I can go to bed, or 
into town, or even (as happened earlier this year) have my computer 
suddenly go on strike...


I don't like coffee, but I have enough boxes of various kinds of tea in 
my kitchen to last me for quite some time, provided of course that I 
have water at the faucet and gas for the kettle. ;-) Tea is only a very 
small part of my food budget.



Best regards,
Tony.


Re: How to insert text via script/function call ?

2006-08-18 Thread Meino Christian Cramer
From: A.J.Mechelynck [EMAIL PROTECTED]
Subject: Re: How to insert text via script/function call ?
Date: Fri, 18 Aug 2006 07:29:05 +0200

 Meino Christian Cramer wrote:
  Hi,
  
   I often need to place a header above a function defintion (C-source)
   fpr documentational purposes.
  
   What I treid is to write a short function for vim, which dioes insert
   the text skeleton -- but I did not find any already existing function
   in the API which does this for me. With :i I got weird effects --
   sure my fault, but... .
  
   How can I insert text via a script ?
  
   Kind regards,
   mcc
  
  
   
  
  
 
 If your text is in a file on its own, you can use :r with a line 
 number (the number of the line after which to insert, or 0 for before 
 first line, or . for after cursor line, or $ for after last line; 
 default is after cursor line) in the range position, i.e. just before 
 the r. The file name comes as an argument at the end.
 
 Example (after line 5):
 
   5r ~/template.txt
 
 If your text is in a register, you can use :put with a line number 
 (again) in the range position and the register name (including , which 
 must be escaped as \, for the default register; or + for the system 
 clipboard) after the :put.
 
 Example (before cursor line):
 
   .-1put \
 
 
 See
   :help :read
   :help :put
 
 
 Best regards,
 Tony.
 

Hi Tony,

 thank you for your reply ! :)

 No, sorry...I was simply searching for a function call like

 printf( This is my text! )

 but instead of C and printing onto stdout it should be vim-script
 and the text should go right at the current cursor position.

 Thats all.
 No registers, no script magic, not extra files. Simply put a string
 after the cursor into the text.

 Keep hacking!
 mcc



Re: How to insert text via script/function call ?

2006-08-18 Thread Meino Christian Cramer
From: Marius Roets [EMAIL PROTECTED]
Subject: Re: How to insert text via script/function call ?
Date: Fri, 18 Aug 2006 09:52:42 +0200

 On 8/18/06, Meino Christian Cramer [EMAIL PROTECTED] wrote:
  Hi,
 
   I often need to place a header above a function defintion (C-source)
   fpr documentational purposes.
 
   What I treid is to write a short function for vim, which dioes insert
   the text skeleton -- but I did not find any already existing function
   in the API which does this for me. With :i I got weird effects --
   sure my fault, but... .
 
   How can I insert text via a script ?
 
   Kind regards,
   mcc
 
 
 Hi
 I got this in my .vimrc:
 
 function! ReadSkeleton()
 
if exists (g:Skeleton_path)
   let skeleton_path = g:Skeleton_path
else
   let skeleton_path = getcwd()
endif
 
let filenameList = split (glob ( skeleton_path . /*.*) , \n)
let filenameList = insert (filenameList, Select skeleton to load)
let choiceList = copy (filenameList)
let choiceList = map (choiceList, 'index(filenameList,v:val) .. . v:val')
let choiceList[0] = Select skeleton to load
let listLen = len(choiceList)
let choiceList = add (choiceList, listLen . . Browse for some
 other folder (gui ONLY))
let choice = inputlist(choiceList)
echo choice
let skeletonName = 
if choice == listLen
   Do the browse thingie if possible
   if has(browse)
 let skeletonName = browse(0,Select session to
 restore,skeleton_path,)
 echo skeletonName
  endif
elseif choice  0
   Load the file
   let skeletonName = filenameList[choice]
echo setting skeletonName to . skeletonName
endif
if skeletonName != 
   execute 0read  . skeletonName
endif
 endfunction
 nmap F4 :call ReadSkeleton()cr
 let Skeleton_path = /home/mroets/.vim/skeletons
 
 I put all the skeletons for programs (perl, c , php etc), each in
 their own file in a directory, and set Skeleton_path to this directory
 in my .vimrc. Now I press F4 and choose which skeleton I want for my
 new file.
 
 HTH
 Marius
 

 Hi Marius!

 thank you for your reply and the script !

 That's far more that I ever want ! :)

 I was simply for an aquivalent to

   printf( This is my text! )

 but instead of C and printing via stdout it should be
 vim script and the text should go right to the current cursor
 position.

 That's all!
 
 Keep hacking!
 mcc



RE: use '/' to find both upper and lower case instances

2006-08-18 Thread Gene Kwiecinski
I have a need to use '/' to find something in a file, but I wish it
to ignore case.

So say I'm looking for 'foo' then I want to find all instances for
'foo' and 'FOO'

Can try

:set ignorecase
or
:set ic

to do so.  Former will almost always work, latter works on some variants
of 'vi' but not all.


Re: How to insert text via script/function call ?

2006-08-18 Thread A.J.Mechelynck

Meino Christian Cramer wrote:

From: A.J.Mechelynck [EMAIL PROTECTED]
Subject: Re: How to insert text via script/function call ?
Date: Fri, 18 Aug 2006 07:29:05 +0200


Meino Christian Cramer wrote:

Hi,

 I often need to place a header above a function defintion (C-source)
 fpr documentational purposes.

 What I treid is to write a short function for vim, which dioes insert
 the text skeleton -- but I did not find any already existing function
 in the API which does this for me. With :i I got weird effects --
 sure my fault, but... .

 How can I insert text via a script ?

 Kind regards,
 mcc


 



If your text is in a file on its own, you can use :r with a line 
number (the number of the line after which to insert, or 0 for before 
first line, or . for after cursor line, or $ for after last line; 
default is after cursor line) in the range position, i.e. just before 
the r. The file name comes as an argument at the end.


Example (after line 5):

5r ~/template.txt

If your text is in a register, you can use :put with a line number 
(again) in the range position and the register name (including , which 
must be escaped as \, for the default register; or + for the system 
clipboard) after the :put.


Example (before cursor line):

.-1put \


See
:help :read
:help :put


Best regards,
Tony.



Hi Tony,

 thank you for your reply ! :)

 No, sorry...I was simply searching for a function call like

 printf( This is my text! )

 but instead of C and printing onto stdout it should be vim-script
 and the text should go right at the current cursor position.

 Thats all.
 No registers, no script magic, not extra files. Simply put a string
 after the cursor into the text.

 Keep hacking!
 mcc





(Untested):
Characterwise:
exe normal aThis is my text!\Esc

Linewise:
exe normal oThis is my text!\Esc

If I didn't goof, you can paste one of the above lines straight into 
your script (via the clipboard).



Best regards,
Tony.


Re: ANN: vcscommand beta 4 (supercedes cvscommand)

2006-08-18 Thread Alan G Isaac
On Wed, 9 Aug 2006, Bob Hiestand apparently wrote: 
 http://vim.sourceforge.net/scripts/script.php?script_id=90 

I see that many people are liking this plugin.
Could you please add a few details about how it works
and why it is better than just using the SVN executables.

Thank you,
Alan Isaac




comment command tightness

2006-08-18 Thread Dimitriy V. Masterov

I am using this commenting mapping to place /* */ around text:

map C-c :s/^\(.*\)$/\/\* \1 \*\//CR:nohlsCR

However, I would like it be tighter, meaning that instead of

/* blah blah blah */

I would like to see

/* blah blah blah */

Is there a way to do this?

DVM


Paragraph formatting options

2006-08-18 Thread Noah Spurrier
I use the :gwap command a lot. I'd like to fine-tune it.
Can the following be done? I'd like to reformat only those
lines with the same indentation (and keep the indent).

I tend to write a lot of HTML and documentation
with indented blocks. For example:

hive.py
This script creates SSH connections to a list of hosts that you
provide. Then you are given a command line prompt. Each
shell command that you enter is sent to all the hosts.
The response from each host is collected and printed. For
example, you could connect to a dozen different machines and reboot
them all at once.

When I hit :gwap in the body of the paragraph I get this:

hive.py This script creates SSH connections to a list of hosts that you
provide. Then you are given a command line prompt. Each shell command
that you enter is sent to all the hosts. The response from each host is
collected and printed. For example, you could connect to a dozen different
machines and reboot them all at once.

I want two thing to happen instead. First, I would like the indent to
be preserved. Second, I would like it to only format the indented paragraph
and not leak into the previous non-indented line. In other words I would
like to define a parahraph as only those line with the same indent
(yes, I'm a Python programmer ;-). So, what I would like to see is this:

hive.py
This script creates SSH connections to a list of hosts that
you provide. Then you are given a command line prompt. Each
shell command that you enter is sent to all the hosts. The
response from each host is collected and printed. For example,
you could connect to a dozen different machines and reboot
them all at once.

Yours,
Noah




Re: Search all text files in a directory for text

2006-08-18 Thread Gary Johnson
On 2006-08-18, Charles E Campbell Jr [EMAIL PROTECTED] wrote:
 Jerin Joy wrote:,
 
 
  I have a lot of source code distributed over a directory hierarchy
  structure. I always need to find class declarations, instances where
  variables are set etc. Usually I just go to command line and run
  something like
  find . -name *.vr -print | xargs grep 'class foo'
 
  Isn't there an easier way to do this in vim? I can't use cscope since
  the source is not in C.
 
 Read   :help netrw-starstarpat  :
 
   :Explore **//class foo
 
 for example.  You'll be presented with an netrw browser display in each 
 subdirectory
 with matching files and the cursor on the first file that matches.  Use 
 shift-up and shift-down
 to move the cursor to previous or subsequent files with matches.  Hit 
 the cr when your
 cursor is on an interesting file to select and edit it.

I've never used the netrw's :Explore command before, but seeing 
this, I read the help sections on pattern-searching and tried the 
example from *netrw-starstar*.  It doesn't seem to work.  I'm using 
Vim-7.0 and netrw v103 on SunOS 5.8.

$ cd /home/garyjohn/src/SunOS/vim-7.0/vim70/src
$ vim -N -u NONE
:runtime plugin/netrwPlugin.vim
:Explore **/*.c
E77: Too many file names

Gary

-- 
Gary Johnson | Agilent Technologies
[EMAIL PROTECTED] | Wireless Division
 | Spokane, Washington, USA


SORBS, etc.

2006-08-18 Thread Gene Kwiecinski
Piqued my curiosity, asked around, got back this as a possible
explanation:

See http://www.us.sorbs.net/faq/spamdb.shtml

I have *no* idea who Joey McNichols be, or why he needs a legal defense,
etc., but it seems as though the whole SORBS thing might be on the
up-and-up, if unpopular o those who got zinged by it.

Lis, I know nothing about SORBS, etc., until today when I saw this, so I
have no real opinion either way.  Just posted for whatever it may be
worth...


Re: Paragraph formatting options

2006-08-18 Thread Alan G Isaac
Try this:
set fo+=w and then leave no white space after your 
outdented header. Then you can gwap to your hearts 
content.

Not quite what you asked for ...

hth,
Alan Isaac



Re: Paragraph formatting options

2006-08-18 Thread Keith Warno

On 8/18/06, Noah Spurrier [EMAIL PROTECTED] wrote:

I use the :gwap command a lot. I'd like to fine-tune it.
Can the following be done? I'd like to reformat only those
lines with the same indentation (and keep the indent).

[...]

I'm sure it could be scripted up fairly easily.  In the meantime you
could do it manually with little effort, like:

V
 select the block you want to reformat
gq

It'd be nice to have a function to do this in one motion but I've been
too lazy lately. :)


RE: SORBS, etc.

2006-08-18 Thread Gene Kwiecinski
Piqued my curiosity, asked around, got back this as a possible
explanation:

  See http://www.us.sorbs.net/faq/spamdb.shtml

I have *no* idea who Joey McNichols be, or why he needs a legal
defense,
etc., but it seems as though the whole SORBS thing might be on the
up-and-up, if unpopular o those who got zinged by it.

No matter what, the ISP has to pay their way out of the blacklist.
It still seems to be a crappy way of running a spam blacklist to me.
My
mail hosting provider is a small company, and probably couldn't afford
to stay in business if they had to pay $50 for every piece of spam that
some of its less-virtuous customers chose to send.

Which is kind of the point.  If a provider doesn't impose at least
minimally-intrusive measures to prevent spamming (eg, maximum of N
emails sent per hour, progressively slowing to a crawl with increasing
volume, etc.), ie, things which wouldn't affect you or me no matter how
prolific we are in emailing, but which would cripple spammers (eg, do I
personally need to send 1000 emails in one shot?), then quite frankly,
if someone *does* abuse it, the provider can't cry foul that they're
blameless victims.

Believe me, I wouldn't shed a single tear if pissed-off vigilantes would
quite literally hunt down and kill the top 10 known spammers and set
their computers on fire, so I personally am willing to suffer not
being able to send 1000 or even 100 emails in one day (as long as
they're queued up and not lost, should I want to send announcements to
friends that I'm changing an email address, etc.).  If a provider
can't/won't put even minor inconveniences to dissuade spamming, then
they deserve to be SORBSed.

If SORBS would pocket their fines, that's one thing, but as they
explicitly don't want to be connected with any charities they approve of
in their list, that to me seems to be on the up-and-up.  Have Bram ask
SORBS to include among the list of approved charities those that assist
Ugandans and Ethernopians and whatnot.  Let some good come out of
spammers' eee-vil actions, and the providers who unwittingly abet them.

To use an analogy, if I leave a loaded gun or samurai sword or
something, out on my front lawn, and some idiot kid goes and hurts or
even kills someone with it, can I insist that I'm blameless in the
matter?  Or should I instead bear some of the blame for my recklessness?

The more I think about it, the more I gotta agree with SORBS, that if
some provider did something to trigger being blacklisted, they *should*
in fact have to pay.  Maybe next time they'd look a little more closely
at their clientele.  If you want a waiver to send more than N emails/day
(eg, for a mailing list), let the provider at least look into the
content and make sure you're not hawking V1AAgrA or fake R0L3X watches
or whatnot.

All that being said, did your provider (the Z-thing?) explain *why* it
may've gotten blacklisted in the first place?  I'd look into that first.
shrug/


Another thing I wanted to point out is that my mail is *never* bounced
by any other mailing list or anyone else to which I ever send mail.

Kewl.  Hope you don't have any more problems with it.


Re: Search all text files in a directory for text

2006-08-18 Thread Charles E Campbell Jr

Gary Johnson wrote:


On 2006-08-18, Charles E Campbell Jr [EMAIL PROTECTED] wrote:
 


Read   :help netrw-starstarpat  :

 :Explore **//class foo

for example.  You'll be presented with an netrw browser display in each 
subdirectory
with matching files and the cursor on the first file that matches.  Use 
shift-up and shift-down
to move the cursor to previous or subsequent files with matches.  Hit 
the cr when your

cursor is on an interesting file to select and edit it.
   



I've never used the netrw's :Explore command before, but seeing 
this, I read the help sections on pattern-searching and tried the 
example from *netrw-starstar*.  It doesn't seem to work.  I'm using 
Vim-7.0 and netrw v103 on SunOS 5.8.


   $ cd /home/garyjohn/src/SunOS/vim-7.0/vim70/src
   $ vim -N -u NONE
   :runtime plugin/netrwPlugin.vim
   :Explore **/*.c
   E77: Too many file names
 


Sigh -- I'm not sure what to do about this one.  Turns out that:

 com! ... -complete=dir Explore ...

causes the E77 with Too many file names.  Simply removing the 
-complete=dir

from the command fixes things.

Regards,
Chip Campbell



Re: Search all text files in a directory for text

2006-08-18 Thread Gary Johnson
On 2006-08-18, Charles E Campbell Jr [EMAIL PROTECTED] wrote:
 Gary Johnson wrote:
 
  On 2006-08-18, Charles E Campbell Jr [EMAIL PROTECTED] wrote:
   
 
  Read   :help netrw-starstarpat  :
 
   :Explore **//class foo
 
  for example.  You'll be presented with an netrw browser display in each 
  subdirectory
  with matching files and the cursor on the first file that matches.  Use 
  shift-up and shift-down
  to move the cursor to previous or subsequent files with matches.  Hit 
  the cr when your
  cursor is on an interesting file to select and edit it.
 
 
 
  I've never used the netrw's :Explore command before, but seeing 
  this, I read the help sections on pattern-searching and tried the 
  example from *netrw-starstar*.  It doesn't seem to work.  I'm using 
  Vim-7.0 and netrw v103 on SunOS 5.8.
 
 $ cd /home/garyjohn/src/SunOS/vim-7.0/vim70/src
 $ vim -N -u NONE
 :runtime plugin/netrwPlugin.vim
 :Explore **/*.c
 E77: Too many file names
   
 
 Sigh -- I'm not sure what to do about this one.  Turns out that:
 
  com! ... -complete=dir Explore ...
 
 causes the E77 with Too many file names.  Simply removing the 
 -complete=dir
 from the command fixes things.

Thanks.  That removes the error and gives me a list of files, but 
included in that list are non-*.c names such as

INSTALL
Makefile
README.txt

Regards,
Gary

-- 
Gary Johnson | Agilent Technologies
[EMAIL PROTECTED] | Wireless Division
 | Spokane, Washington, USA


Re: Search all text files in a directory for text

2006-08-18 Thread Charles E Campbell Jr

Gary Johnson wrote:



Thanks.  That removes the error and gives me a list of files, but 
included in that list are non-*.c names such as


   INSTALL
   Makefile
   README.txt
 



:Explore **/*.c  doesn't give a list of just *.c files.  Instead, it 
opens a browser listing of every directory
with *.c files in it.  The cursor will be on the first such .c file; you 
may edit it if you wish.
If its not the one you want, shift-down will move the cursor to the 
next .c file, repeat at will.
One may go back with shiftup .  Directory displays will change as 
necessary.


Regards,
Chip Campbell



Re: Search all text files in a directory for text

2006-08-18 Thread Gary Johnson
On 2006-08-18, Charles E Campbell Jr [EMAIL PROTECTED] wrote:
 Gary Johnson wrote:
 
 
  Thanks.  That removes the error and gives me a list of files, but 
  included in that list are non-*.c names such as
 
 INSTALL
 Makefile
 README.txt
   
 
 
 :Explore **/*.c  doesn't give a list of just *.c files.  Instead, it 
 opens a browser listing of every directory
 with *.c files in it.  The cursor will be on the first such .c file; you 
 may edit it if you wish.
 If its not the one you want, shift-down will move the cursor to the 
 next .c file, repeat at will.
 One may go back with shiftup .  Directory displays will change as 
 necessary.

OH!  Got it.

I found another problem, though.  Following my previous example and 
proceeding from

$ vim -N -u NONE

I execute the following commands and the cursor moves to the file 
indicated.

+-+-+
| Command | Resulting   |
| | Cursor Location |
+=+=+
| :Explore **/*.c | arabic.c|
| | |
| :Nexplore   | auto/pathdef.c  |
| :Nexplore   | buffer.c|
| :Nexplore   | charset.c   |
| :Nexplore   | diff.c  |
| | |
| :Pexplore   | diff.c  |
| :Pexplore   | diff.c  |
| :Pexplore   | auto/pathdef.c  |
| :Pexplore   | arabic.c|
+-+-+

So there seems to be a pointer traversing an internal list of 
files that is moved by the :Nexplore and :Pexplore commands.  The 
:Nexplore and :Pexplore commands both control this pointer 
correctly, but only the :Nexplore command updates the cursor 
location correctly, unless the directory is changed.

Regards,
Gary

-- 
Gary Johnson | Agilent Technologies
[EMAIL PROTECTED] | Wireless Division
 | Spokane, Washington, USA


Re: Paragraph formatting options

2006-08-18 Thread cga2000
On Fri, Aug 18, 2006 at 02:12:19PM EDT, Alan G Isaac wrote:
 Try this:
 set fo+=w and then leave no white space after your 
 outdented header. Then you can gwap to your hearts 
 content.
 
 Not quite what you asked for ...
 
I realize that this is not what you asked for either .. but what is this
gwap (or :gwap ..) command?

Seems it is not recognized by Vim 6.3.

Another good reason to upgrade?

Thanks

cga


Re[2]: Paragraph formatting options

2006-08-18 Thread Alan G Isaac
On Fri, 18 Aug 2006, apparently wrote: 
 but what is this 
 gwap (or :gwap ..) command? 
 Seems it is not recognized by Vim 6.3 

:h gw

Enjoy.

Alan Isaac



ksh93s

2006-08-18 Thread John Little

Hi all

The wikipedia entry for the Korn shell
http://en.wikipedia.org/wiki/Korn_shell has a tantalizing
parenthetical note:

 ksh93s will add a 4th vim mode

Googling for ksh93s + vim only finds the wikipedia article, or copies
of it, and ksh93 + vim mode the same, and ksh93 + vim nothing I
recognized as relevant.

Does anyone here know anything about it?

John


Tip: selecting a file to edit with the handy completion feature

2006-08-18 Thread Fan Decheng
Only recently did I read the vim manual for command line completion. In
the documentation, I found that the following is a handy way to open a
file when using the :e command.

1. Type :e followed with a space.
2. Type the first a few characters of the file you want to edit.
3. Press CTRL-L. Vim will do completion like most UNIX shells do.
4. Type more characters if the file name is not expected.
5. Repeat step 3 to 4 until the file name is complete.
Note: After pressing CTRL-L, if you still cannot remember the rest part
of the file name, press CTRL-D to list all possible names. This works
like the Bourne Again Shell.

Happy Vimming!






Re: Paragraph formatting options

2006-08-18 Thread cga2000
On Fri, Aug 18, 2006 at 08:12:01PM EDT, Alan G Isaac wrote:
 On Fri, 18 Aug 2006, apparently wrote: 
  but what is this 
  gwap (or :gwap ..) command? 
  Seems it is not recognized by Vim 6.3 
 
 :h gw
 
guess what .. I was mistyping it ..

.. something like gwa- I guess ..

didn't realize it was gw+[motion] 

:-(

 Enjoy.
 
Many thanks.. I certainly do..!

I there a way I can enter effortlessly stuff like the following:

1. this is a numbered paragraph several lines long and I would like all
lines aligned with the this which starts in column 4.  I don't know if
it's good typography but I use these numbered lists a lot and with the
text aligned I think it looks better.

.. and format it like this:

1. this is a numbered paragraph several lines long and I would like all
   lines aligned with the this which starts in column 4.  I don't know 
   if it's good typography but I use these numbered lists a lot and with
   the text aligned I think it looks better.

.. or possibly make Vim indent this automatically when typing..?

I mean that I usually have a textwidth of 72 and Vim automatically wraps
to line 2 after I have written the all at the end of line 1 .. but
obviously Vim has no reason to indent and therefore starts line 2 and
the following lines in column 1. 

Is there any way I can tell Vim that when line 1 starts with a number
followed by a dot '.' .. the following lines should be indented so that
all the text is aligned.

Not simple .. I guess .. since this could move into double digits (or
more..) -- there could be more than nine numbered paragraphs and text
should start in column 5 (or 6..).

Or maybe somone has written a script that can convert a bunch of
paragraphs into something like a numbered (or bulleted) list?

Thanks

cga


Re: Paragraph formatting options

2006-08-18 Thread Gary Johnson
On 2006-08-18, cga2000 [EMAIL PROTECTED] wrote:

 I there a way I can enter effortlessly stuff like the following:
 
 1. this is a numbered paragraph several lines long and I would like all
 lines aligned with the this which starts in column 4.  I don't know if
 it's good typography but I use these numbered lists a lot and with the
 text aligned I think it looks better.
 
 .. and format it like this:
 
 1. this is a numbered paragraph several lines long and I would like all
lines aligned with the this which starts in column 4.  I don't know 
if it's good typography but I use these numbered lists a lot and with
the text aligned I think it looks better.
 
 .. or possibly make Vim indent this automatically when typing..?
 
 I mean that I usually have a textwidth of 72 and Vim automatically wraps
 to line 2 after I have written the all at the end of line 1 .. but
 obviously Vim has no reason to indent and therefore starts line 2 and
 the following lines in column 1. 
 
 Is there any way I can tell Vim that when line 1 starts with a number
 followed by a dot '.' .. the following lines should be indented so that
 all the text is aligned.
 
 Not simple .. I guess .. since this could move into double digits (or
 more..) -- there could be more than nine numbered paragraphs and text
 should start in column 5 (or 6..).
 
 Or maybe somone has written a script that can convert a bunch of
 paragraphs into something like a numbered (or bulleted) list?

For numbered lists,

set fo+=n

For bulleted lists using '-',

set com+=fb:-

or '*',

set com+=fb:*

but those should already be part of the default 'comments' option
unless you have changed it.  (Odd that numbered lists and bulleted
lists use different options.)
See

:help 'fo'
:help 'com'

I also have '2' as part of my 'formatoptions' string.  I don't think
it affects lists, but you might try it if those other settings don't
work as you'd like them to.

Regards,
Gary

-- 
Gary Johnson | Agilent Technologies
[EMAIL PROTECTED] | Wireless Division
 | Spokane, Washington, USA


Re: Paragraph formatting options

2006-08-18 Thread Gary Johnson
On 2006-08-18, Gary Johnson [EMAIL PROTECTED] wrote:

 For bulleted lists using '-',
 
 set com+=fb:-
 
 or '*',
 
 set com+=fb:*
 
 but those should already be part of the default 'comments' option
 unless you have changed it.

I just checked again.  fb:- is there by default; I added fb:* in 
my .vimrc and ftplugin/mail.vim.

Regards,
Gary

-- 
Gary Johnson | Agilent Technologies
[EMAIL PROTECTED] | Wireless Division
 | Spokane, Washington, USA


Re: Tip: selecting a file to edit with the handy completion feature

2006-08-18 Thread A.J.Mechelynck

Fan Decheng wrote:

Only recently did I read the vim manual for command line completion. In
the documentation, I found that the following is a handy way to open a
file when using the :e command.

1. Type :e followed with a space.
2. Type the first a few characters of the file you want to edit.
3. Press CTRL-L. Vim will do completion like most UNIX shells do.
4. Type more characters if the file name is not expected.
5. Repeat step 3 to 4 until the file name is complete.
Note: After pressing CTRL-L, if you still cannot remember the rest part
of the file name, press CTRL-D to list all possible names. This works
like the Bourne Again Shell.

Happy Vimming!








If you have 'wildmenu' on, you can do the same with Tab instead of 
Ctrl-L, and get a menu of possible completions on the bottom status 
line. Use the left and right arrow keys to cycle through the possible 
completions and what you initially typed, down-arrow to descend into a 
 subdirectory, add some more letters and tab again for a narrower 
choice, Enter to accept, Esc to abort, etc. To complete the longest 
common match in addition to this menu behaviour, use :set wildmenu 
wildmode=longest:full.


see
:help 'wildmenu'
:help 'wildmode'


Best regards,
Tony.


Re: Paragraph formatting options

2006-08-18 Thread cga2000
On Sat, Aug 19, 2006 at 12:15:10AM EDT, Gary Johnson wrote:
 On 2006-08-18, cga2000 [EMAIL PROTECTED] wrote:
 
[help creating numbered and bulleted lists in Vim]
 
 For numbered lists,
 
 set fo+=n
 
 For bulleted lists using '-',
 
 set com+=fb:-
 
 or '*',
 
 set com+=fb:*
 
 but those should already be part of the default 'comments' option
 unless you have changed it.  (Odd that numbered lists and bulleted
 lists use different options.)
 See
 
 :help 'fo'
 :help 'com'
 
 I also have '2' as part of my 'formatoptions' string.  I don't think
 it affects lists, but you might try it if those other settings don't
 work as you'd like them to.
 
Looks very promising. 

I'm three hours behind/ahead of you (EST) .. so it's bedtime for me .. 

Main thing that I have to figure out is a simple way to get back to
column 1 when starting a new list item.  When I am done entering item
#1, I need to type 2. in columns 1 and 2 and if I just hit enter to
start a new line, Vim jumps to column 4.  So I escape back to command
mode .. Vim moves the cursor to column 1 .. I hit i .. 

Also, I created a ten-item list and the text in item #10 and items #1
to #9 is not aligned.  So I select the column that has the space that
separated 1. .. 2. .. from the text Ctrl-V .. yank it .. and hit p
causing Vim to indent the text in items 1-9 by an additional column.
Need to check the help files .. see if there's a better way.

Lastly.. I need to check what happens with fo+=a .. see if this plays
well with automatic formatting of paragraphs.  Hopefully Vim will
reflow text without losing track of the list indent.

Thank you very much..

cga


Re: Paragraph formatting options

2006-08-18 Thread cga2000
On Sat, Aug 19, 2006 at 12:22:56AM EDT, Gary Johnson wrote:
 On 2006-08-18, Gary Johnson [EMAIL PROTECTED] wrote:
 
  For bulleted lists using '-',
  
  set com+=fb:-
  
  or '*',
  
  set com+=fb:*
  
  but those should already be part of the default 'comments' option
  unless you have changed it.
 
 I just checked again.  fb:- is there by default; I added fb:* in 
 my .vimrc and ftplugin/mail.vim.
 
I'll probably use the dot '.' .. hope it doesn't clash with anything..

Or maybe there's a :digraph that would look good and yet not cause
trouble in email, printouts, .. eg.

Thanks again,

cga


Re: How to insert text via script/function call ?

2006-08-18 Thread Meino Christian Cramer
From: A.J.Mechelynck [EMAIL PROTECTED]
Subject: Re: How to insert text via script/function call ?
Date: Fri, 18 Aug 2006 18:05:13 +0200

 Meino Christian Cramer wrote:
  From: A.J.Mechelynck [EMAIL PROTECTED]
  Subject: Re: How to insert text via script/function call ?
  Date: Fri, 18 Aug 2006 07:29:05 +0200
  
  Meino Christian Cramer wrote:
  Hi,
 
   I often need to place a header above a function defintion (C-source)
   fpr documentational purposes.
 
   What I treid is to write a short function for vim, which dioes insert
   the text skeleton -- but I did not find any already existing function
   in the API which does this for me. With :i I got weird effects --
   sure my fault, but... .
 
   How can I insert text via a script ?
 
   Kind regards,
   mcc
 
 
   
 
 
  If your text is in a file on its own, you can use :r with a line 
  number (the number of the line after which to insert, or 0 for before 
  first line, or . for after cursor line, or $ for after last line; 
  default is after cursor line) in the range position, i.e. just before 
  the r. The file name comes as an argument at the end.
 
  Example (after line 5):
 
 5r ~/template.txt
 
  If your text is in a register, you can use :put with a line number 
  (again) in the range position and the register name (including , which 
  must be escaped as \, for the default register; or + for the system 
  clipboard) after the :put.
 
  Example (before cursor line):
 
 .-1put \
 
 
  See
 :help :read
 :help :put
 
 
  Best regards,
  Tony.
 
  
  Hi Tony,
  
   thank you for your reply ! :)
  
   No, sorry...I was simply searching for a function call like
  
   printf( This is my text! )
  
   but instead of C and printing onto stdout it should be vim-script
   and the text should go right at the current cursor position.
  
   Thats all.
   No registers, no script magic, not extra files. Simply put a string
   after the cursor into the text.
  
   Keep hacking!
   mcc
  
  
  
 
 (Untested):
 Characterwise:
   exe normal aThis is my text!\Esc
 
 Linewise:
   exe normal oThis is my text!\Esc
 
 If I didn't goof, you can paste one of the above lines straight into 
 your script (via the clipboard).
 
 
 Best regards,
 Tony.
 

Hi Tony,

 this works so far...with an unwanted sideeffekt:

 Instead of

 This is my text!

 in my buffer I get

 This is my text!Esc

 in my text.

 When using 

 exe normal aThis is my text!\Esc

 instead, vim says in the commandline:

 E121: Undefined variable: Esc
 E15 Invalid expression: normalaThis is my textEsc

 .

 No way out ?

 Kind regards,
 mcc


Re: Tip: selecting a file to edit with the handy completion feature

2006-08-18 Thread Hari Krishna Dara

On Sat, 19 Aug 2006 at 8:37am, Fan Decheng wrote:

 Only recently did I read the vim manual for command line completion. In
 the documentation, I found that the following is a handy way to open a
 file when using the :e command.

 1. Type :e followed with a space.
 2. Type the first a few characters of the file you want to edit.
 3. Press CTRL-L. Vim will do completion like most UNIX shells do.
 4. Type more characters if the file name is not expected.
 5. Repeat step 3 to 4 until the file name is complete.
 Note: After pressing CTRL-L, if you still cannot remember the rest part
 of the file name, press CTRL-D to list all possible names. This works
 like the Bourne Again Shell.

 Happy Vimming!


For a much better completion option (using Vim7 popup completion), try
the LUWalk command in my lookupfile plugin:

http://www.vim.org/scripts/script.php?script_id=1581

As you type each component of the path, you will be shown matches in a
popup window. You can also use wildcards such as ** to search
subdirectories.

-- 
Thanks,
Hari

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Re: Paragraph formatting options

2006-08-18 Thread A.J.Mechelynck

cga2000 wrote:

On Sat, Aug 19, 2006 at 12:22:56AM EDT, Gary Johnson wrote:

On 2006-08-18, Gary Johnson [EMAIL PROTECTED] wrote:


For bulleted lists using '-',

set com+=fb:-

or '*',

set com+=fb:*

but those should already be part of the default 'comments' option
unless you have changed it.
I just checked again.  fb:- is there by default; I added fb:* in 
my .vimrc and ftplugin/mail.vim.



I'll probably use the dot '.' .. hope it doesn't clash with anything..

Or maybe there's a :digraph that would look good and yet not cause
trouble in email, printouts, .. eg.

Thanks again,

cga




If you're using Latin1 or UTF-8, you may try:

- Currency sign (decimal 164, ¤, ^KCu)
- Middle dot (decimal 183, ·, ^K.M)
- or even a lowercase o, but in that case you should make sure that it 
isn't recognised as a bullet unless followed by a space or tab.



Best regards,
Tony.


Re: Paragraph formatting options

2006-08-18 Thread Gary Johnson
On 2006-08-19, cga2000 [EMAIL PROTECTED] wrote:
 On Sat, Aug 19, 2006 at 12:15:10AM EDT, Gary Johnson wrote:
  On 2006-08-18, cga2000 [EMAIL PROTECTED] wrote:
  
 [help creating numbered and bulleted lists in Vim]
  
  For numbered lists,
  
  set fo+=n
  
  For bulleted lists using '-',
  
  set com+=fb:-
  
  or '*',
  
  set com+=fb:*
  
  but those should already be part of the default 'comments' option
  unless you have changed it.  (Odd that numbered lists and bulleted
  lists use different options.)
  See
  
  :help 'fo'
  :help 'com'
  
  I also have '2' as part of my 'formatoptions' string.  I don't think
  it affects lists, but you might try it if those other settings don't
  work as you'd like them to.
  
 Looks very promising. 
 
 I'm three hours behind/ahead of you (EST) .. so it's bedtime for me .. 

It's getting late here, too, but I just got a new Windows PC and two 
new flat-panel monitors that I share between the Windows PC and my 
Linux PC, so I'm trying to get everything configured the way I want.

 Main thing that I have to figure out is a simple way to get back to
 column 1 when starting a new list item.  When I am done entering item
 #1, I need to type 2. in columns 1 and 2 and if I just hit enter to
 start a new line, Vim jumps to column 4.  So I escape back to command
 mode .. Vim moves the cursor to column 1 .. I hit i .. 

Just hit Ctrl-D after the enter that finishes the item.  Actually,
you can hit Ctrl-D any time while you're typing the next numbered
line.  That will move the line one shift-width to the left, just as
'' does in normal mode.

 Also, I created a ten-item list and the text in item #10 and items #1
 to #9 is not aligned.  So I select the column that has the space that
 separated 1. .. 2. .. from the text Ctrl-V .. yank it .. and hit p
 causing Vim to indent the text in items 1-9 by an additional column.
 Need to check the help files .. see if there's a better way.

I usually usually use Ctrl-V to select the first column of text, 
then type 'I' and a space and Esc.  Your method is slightly 
better, as long as you're not using tabs and a deeply-indented list.

 Lastly.. I need to check what happens with fo+=a .. see if this plays
 well with automatic formatting of paragraphs.  Hopefully Vim will
 reflow text without losing track of the list indent.

It seems to work well most of the time, but there are a few cases 
where it doesn't, notably when a sentence ends in a number, such as 
a year or a model number, and that number wraps to the start of the 
next line.  Then vim insists on indenting the line following that 
number as though the number was a list item.  Like this, assuming a 
narrow 'textwidth':

Columbus sailed the ocean blue in
1492.  Then some more text just to 
   fill in the line.

Consequently, I never include 'n' and 'aw' in 'fo' at the same time.

 Thank you very much..

You're most welcome.

Regards,
Gary

-- 
Gary Johnson | Agilent Technologies
[EMAIL PROTECTED] | Wireless Division
 | Spokane, Washington, USA


Re: How to insert text via script/function call ?

2006-08-18 Thread A.J.Mechelynck

Meino Christian Cramer wrote:

From: A.J.Mechelynck [EMAIL PROTECTED]
Subject: Re: How to insert text via script/function call ?
Date: Fri, 18 Aug 2006 18:05:13 +0200


Meino Christian Cramer wrote:

From: A.J.Mechelynck [EMAIL PROTECTED]
Subject: Re: How to insert text via script/function call ?
Date: Fri, 18 Aug 2006 07:29:05 +0200


Meino Christian Cramer wrote:

Hi,

 I often need to place a header above a function defintion (C-source)
 fpr documentational purposes.

 What I treid is to write a short function for vim, which dioes insert
 the text skeleton -- but I did not find any already existing function
 in the API which does this for me. With :i I got weird effects --
 sure my fault, but... .

 How can I insert text via a script ?

 Kind regards,
 mcc


 



If your text is in a file on its own, you can use :r with a line 
number (the number of the line after which to insert, or 0 for before 
first line, or . for after cursor line, or $ for after last line; 
default is after cursor line) in the range position, i.e. just before 
the r. The file name comes as an argument at the end.


Example (after line 5):

5r ~/template.txt

If your text is in a register, you can use :put with a line number 
(again) in the range position and the register name (including , which 
must be escaped as \, for the default register; or + for the system 
clipboard) after the :put.


Example (before cursor line):

.-1put \


See
:help :read
:help :put


Best regards,
Tony.


Hi Tony,

 thank you for your reply ! :)

 No, sorry...I was simply searching for a function call like

 printf( This is my text! )

 but instead of C and printing onto stdout it should be vim-script
 and the text should go right at the current cursor position.

 Thats all.
 No registers, no script magic, not extra files. Simply put a string
 after the cursor into the text.

 Keep hacking!
 mcc




(Untested):
Characterwise:
exe normal aThis is my text!\Esc

Linewise:
exe normal oThis is my text!\Esc

If I didn't goof, you can paste one of the above lines straight into 
your script (via the clipboard).



Best regards,
Tony.



Hi Tony,

 this works so far...with an unwanted sideeffekt:

 Instead of

 This is my text!

 in my buffer I get

 This is my text!Esc

 in my text.


I get the text properly inserted. Are you sure that you used double 
quotes around the string and that it ended (before the closing double 
quote) with backslash, less-than, E-for-Echo, s-for-Sierra, 
c-for-Charlie, greater-than ? If it didn't, then you didn't use the 
lines above by copy-paste as I told you. Or else, maybe you have 
'compatible' set? (check it by :verbose set compatible? without the 
quotes but with the question mark).




 When using 


 exe normal aThis is my text!\Esc

 instead, vim says in the commandline:

 E121: Undefined variable: Esc
 E15 Invalid expression: normalaThis is my textEsc

 .

 No way out ?

 Kind regards,
 mcc




Try
:exe normal aThis is my text!\e
and make sure that you use double quotes, not single quotes.

see :help expr-string


Best regards,
Tony.