Re: Two problems

2006-11-15 Thread Gary Johnson
On 2006-11-15, Chuck Mason [EMAIL PROTECTED] wrote:

 In gvim you can do iDelEsc or 0iBS to join lines. So the need for
 (J) is superfluous.  Why is there no antithesis to J for splitting
 lines?

Because In The Beginning was Vi, and Vi viewed Files as consisting 
of sequences of Lines, each Line being a sequence of zero or more 
ASCII Characters ending in a Newline.  Editing was done by 
manipulating lines and the characters _within_ lines; the 
terminating newline was never manipulated directly--the user didn't 
even have to know how lines were separated.  You could split one 
line into two lines by typing Return or Enter in insert mode or 
replace mode, but the only way to join two lines into one line was 
to use the join command (:join or J).

This behavior was common in editors at the time.  The model of 
treating a file as a single sequence of characters is more recent.  
Vim has added features to allow users to manipulate files in that 
manner if they choose, but these features have had to use the 
limited set of keys that were available after vi had defined most of 
them.

So, the reason for the J command was the necessity having such a 
command in a line-oriented editor, not to save key strokes.  There 
was no need for a special command to split lines:  typing Return or 
Enter already did that.  (By that reasoning, one could argue that o 
and O are superfluous as well.  I don't have a good answer for that, 
other than that inserting lines may have been considered by the 
designer of vi to be more common that splitting lines.)

HTH,
Gary

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


Re: Two problems

2006-11-15 Thread Russell Bateman
What Gary says  is historically true, but I would point out that it was 
the fact that deep underneath vi was sitting on ed. Many full-screen 
versions of line editors, like teco, suffered from having their wings 
tied down close to the lowest assumptions and could not spread them and 
soar.


I remember the first time I used h to back up past the beginning of a 
line in Vim and fainted dead-away seeing the cursor reappear at the end 
of the previous line. I had been using Vim as a replacement for vi on 
Windows for a couple of years already before it happened. It's not that 
it's amazing functionality, it's that it was completely unexpected after 
a couple of decades as a vi jockey. Even today, I never really use that 
capability because somehow it just ain't vi, but I admit that it is the 
most natural thing in the world to do.


Starting in 1984 and for many years (until I lost the faith around the 
Mac OS 8 time frame) I had a parallel night life on the Macintosh and I 
long wanted an editor that supported the mouse the way I had come to 
expect on that platform plus all the plutonium-powered movement and 
text-editing commands of vi. For me, Vim has made good on this promise 
although I admit that I never actually block text with a click-and-drag 
except if I have to cooperate with another, broken application. Just 
being able to put the cursor using the mouse in moments where I seem to 
have gravitated to doing that has been bliss. With ctags and now an 
Intellisense-like capability, wow! And the best part of all is that it's 
on every platform I use (Linux, various Unices and Windows).


I love this Vim! It's God's own editor.



Gary Johnson wrote:

On 2006-11-15, Chuck Mason [EMAIL PROTECTED] wrote:

  

In gvim you can do iDelEsc or 0iBS to join lines. So the need for
(J) is superfluous.  Why is there no antithesis to J for splitting
lines?



Because In The Beginning was Vi, and Vi viewed Files as consisting 
of sequences of Lines, each Line being a sequence of zero or more 
ASCII Characters ending in a Newline.  Editing was done by 
manipulating lines and the characters _within_ lines; the 
terminating newline was never manipulated directly--the user didn't 
even have to know how lines were separated.  You could split one 
line into two lines by typing Return or Enter in insert mode or 
replace mode, but the only way to join two lines into one line was 
to use the join command (:join or J).


This behavior was common in editors at the time.  The model of 
treating a file as a single sequence of characters is more recent.  
Vim has added features to allow users to manipulate files in that 
manner if they choose, but these features have had to use the 
limited set of keys that were available after vi had defined most of 
them.


So, the reason for the J command was the necessity having such a 
command in a line-oriented editor, not to save key strokes.  There 
was no need for a special command to split lines:  typing Return or 
Enter already did that.  (By that reasoning, one could argue that o 
and O are superfluous as well.  I don't have a good answer for that, 
other than that inserting lines may have been considered by the 
designer of vi to be more common that splitting lines.)


HTH,
Gary




Re: Two problems

2006-09-15 Thread Meino Christian Cramer
From: Pete Johns [EMAIL PROTECTED]
Subject: Re: Two problems
Date: Fri, 15 Sep 2006 14:19:22 +1000

Hi Pete !

 Thank you for disassembling the hex into mnemonics! :O)

 One question remains in my head:

 if /.\{73,}/ find all lines, for what is the g for?
 I mean...more than finding the whole line in the whole line make
 no sense to me (and obviously only to me ;) ...

 Vim - the text assemble ;)))

 Keep hacking!
 mcc



 On Fri, 2006-09-15 at 04:57:24 +0200, Meino Christian Cramer sent:
 Hi Pete!
 
 Hi!
 
 
 thank you very much for this line of code -- works like a
 charme!
 
 Delighted to hear it.
 
 
 The only bad thing is: I dont understand completly, how it
 works
 
 He he... I'm glad that someone's taken this apart :-)
 
 1,$for the beginning of the text til its end do
 
 And there's a 'g'...
 
 
 /.\{73,}/  find all lines longer than 72 chars and for each do
 
 Yup.
 
 
 normal ??? go into normal mode ???
  v ? visual mode (and for what is the   good for?)
  
 
 normalv}gq isn't an editor command, so you have to split 'normal'
 and 'v'. There may be a better way of doing this.
 
 
 }gq only white noise for mea C-programme I
 would say, that there is on } too many in the whole expression
 but simultaneously I know, that I am wrong.???
 
 } is a motion: it moves one paragraph forward.
 
 See :help }
 
 gq formats the highlighted lines.
 
 See :he gq
 
 There are other ways of solving this problem, I am sure, but I
 like the way this works because it leaves paragraphs alone that
 are shorter then 73 characters wide, rather than expanding them.
 
 Cheers;
 
 
 
 --paj
 --
 Pete Johns   http://johnsy.com/
 Contact Information  http://johnsy.com/contact/
 More On OptusNet   http://johnsy.com/20060912132225
 dsc00220  http://johnsy.com/albums/flickr/210370644
 


Re: Two problems

2006-09-15 Thread A.J.Mechelynck

Meino Christian Cramer wrote:

From: Pete Johns [EMAIL PROTECTED]
Subject: Re: Two problems
Date: Fri, 15 Sep 2006 14:19:22 +1000

Hi Pete !

 Thank you for disassembling the hex into mnemonics! :O)

 One question remains in my head:

 if /.\{73,}/ find all lines, for what is the g for?
 I mean...more than finding the whole line in the whole line make
 no sense to me (and obviously only to me ;) ...

 Vim - the text assemble ;)))

 Keep hacking!
 mcc



/.\{73,}/ by itself would just find the _next_ line longer than 72, 
possibly wrapping to the beginning if it wasn't found after the cursor.


g/pattern/excommand is the :g[lobal] command (see :help :g): it 
executes :excommand on all lines matching /pattern/. The name of the 
grep program comes from the Vi command :g/re/p where re means 
regular expression (i.e. pattern) and p means :p[rint].



Best regards,
Tony.


Re: Two problems

2006-09-15 Thread Meino Christian Cramer
From: A.J.Mechelynck [EMAIL PROTECTED]
Subject: Re: Two problems
Date: Fri, 15 Sep 2006 16:54:02 +0200

 Meino Christian Cramer wrote:
  From: Pete Johns [EMAIL PROTECTED]
  Subject: Re: Two problems
  Date: Fri, 15 Sep 2006 14:19:22 +1000
  
  Hi Pete !
  
   Thank you for disassembling the hex into mnemonics! :O)
  
   One question remains in my head:
  
   if /.\{73,}/ find all lines, for what is the g for?
   I mean...more than finding the whole line in the whole line make
   no sense to me (and obviously only to me ;) ...
  
   Vim - the text assemble ;)))
  
   Keep hacking!
   mcc
 
 
 /.\{73,}/ by itself would just find the _next_ line longer than 72, 
 possibly wrapping to the beginning if it wasn't found after the cursor.
 
 g/pattern/excommand is the :g[lobal] command (see :help :g): it 
 executes :excommand on all lines matching /pattern/. The name of the 
 grep program comes from the Vi command :g/re/p where re means 
 regular expression (i.e. pattern) and p means :p[rint].
 
 
 Best regards,
 Tony.

...and then I was struck by (en-)lightning ! WOOOSH!

 g/Thanks a lot, Tony! :)

 Have a nive weekend !
 mcc
  


Re: Two problems

2006-09-15 Thread Meino Christian Cramer
From: Pete Johns [EMAIL PROTECTED]
Subject: Re: Two problems
Date: Fri, 15 Sep 2006 14:19:22 +1000



snip
...
snip

Hi Pete,

 ...please check this with your genious vimly mind...  :)  -- BIG smiley!

 
 Your initial command set was:

 1,$g/.\{73,}/normal v}gq

 Which does -- if I understand correctly in the meantime -- find any
 more-than-72chars-long line and reformats it.

 But if there is a text like this:

Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very 
Very long line
fun! Thisscript()
 does nothing special
endfunction

 become this:

Very Very Very Very Very Very Very Very Very Very Very Very Very Very
Very Very Very long line fun! Thisscript() does nothing special
endfunction

 (I am still writing my mail with emacs and mew, since I haven't found
 an equal replacement for that, so reformatting is not truely done
 with your comamnd but with emacs Alt-Q command...)

 due to the final } in the command set -- it jumps behind the
 endfunction in this case.

 But I only want to reformat the longish line. The result should be
 this:

Very Very Very Very Very Very Very Very Very Very Very Very Very Very
Very Very Very long line
fun! Thisscript()
 does nothing special
endfunction


 Would it help to change the command set to

 1,$g/.\{73,}/normal v$gq

 

 Have a nice weekend !
 mcc


Re: Two problems

2006-09-15 Thread A.J.Mechelynck

Meino Christian Cramer wrote:

From: Pete Johns [EMAIL PROTECTED]
Subject: Re: Two problems
Date: Fri, 15 Sep 2006 14:19:22 +1000



snip
...
snip

Hi Pete,

 ...please check this with your genious vimly mind...  :)  -- BIG smiley!

 
 Your initial command set was:


 1,$g/.\{73,}/normal v}gq

 Which does -- if I understand correctly in the meantime -- find any
 more-than-72chars-long line and reformats it.

 But if there is a text like this:

Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very 
Very long line
fun! Thisscript()
 does nothing special
endfunction

 become this:

Very Very Very Very Very Very Very Very Very Very Very Very Very Very
Very Very Very long line fun! Thisscript() does nothing special
endfunction

 (I am still writing my mail with emacs and mew, since I haven't found
 an equal replacement for that, so reformatting is not truely done
 with your comamnd but with emacs Alt-Q command...)

 due to the final } in the command set -- it jumps behind the
 endfunction in this case.

 But I only want to reformat the longish line. The result should be
 this:

Very Very Very Very Very Very Very Very Very Very Very Very Very Very
Very Very Very long line
fun! Thisscript()
 does nothing special
endfunction


 Would it help to change the command set to

 1,$g/.\{73,}/normal v$gq

 

 Have a nice weekend !
 mcc



You could simply do

:%g/.{73,}/normal gqq

see help gqq

This would of course keep the hard line break (if there is one) between 
...Very Very Very and Very Very Very long line. You can't have it both ways.



Best regards,
Tony.


Re: Two problems

2006-09-15 Thread Pete Johns
On Fri, 2006-09-15 at 20:20:58 +0200, A.J.Mechelynck sent:
You could simply do

:%g/.{73,}/normal gqq

see help gqq

This would of course keep the hard line break (if there is one)
between ...Very Very Very and Very Very Very long line. You
can't have it both ways.

Indeed. The alternative solution would be to insert a blank line
above each function definition (if one did not exist), which may
improve the clarity of the document.

Just a thought...


--paj
-- 
Pete Johns   http://johnsy.com/
Contact Information  http://johnsy.com/contact/
TFI Friday!http://johnsy.com/20060915095839
dsc00893  http://johnsy.com/albums/flickr/243791420


pgp1fC4KQFQyS.pgp
Description: PGP signature


Re: Two problems

2006-09-14 Thread Andrea Spadaccini
Ciao Peter,

 The Vim Book (http://iccf-holland.org/click5.html#oualline) will get
 you up to speed quickly on most of Vim's important features, and
 teach you how to use some important tools you might miss otherwise.
 Most complex commands can still be reduced down to one or two
 keystrokes, just post again if you need help with anything.

Well.. the vim book is for vim 5.7.. Are there any plans to make a new
version for vim 7.x?

I would buy it if only it was up-to-date! :)

-- 
[ Andrea Spadaccini - a.k.a. Lupino - from Catania - ICQ #: 91528290 ]
[ GPG ID: 5D41ABF0 - key on keyservers - Gentoo GNU / Linux - 2.6.17 ]
[ Linux Registered User 313388 - @: a.spadaccini(at)catania.linux.it ]


signature.asc
Description: PGP signature


Re: Two problems

2006-09-14 Thread Andy Wokula
Pete Johns schrieb:
  For all lines longer than 72 characters, reformat the
  paragraph from that line..
 1,$g/.\{73,}/normal v}gq

or just

:set tw=72   if set otherwise
:g/./normal gqq

Andy





___ 
Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: 
http://mail.yahoo.de


Re: Two problems

2006-09-14 Thread Peter Hodge

--- Andrea Spadaccini [EMAIL PROTECTED] wrote:
 
 Well.. the vim book is for vim 5.7.. Are there any plans to make a new
 version for vim 7.x?
 
 I would buy it if only it was up-to-date! :)


Many of Vim's best features were included in 5.7.  It is still a great book to
get you from a novice to intermediate user quickly.

regards,
Peter



 
 -- 
 [ Andrea Spadaccini - a.k.a. Lupino - from Catania - ICQ #: 91528290 ]
 [ GPG ID: 5D41ABF0 - key on keyservers - Gentoo GNU / Linux - 2.6.17 ]
 [ Linux Registered User 313388 - @: a.spadaccini(at)catania.linux.it ]
 




 
Do you Yahoo!? 
Take part in Total Girl’s Ultimate Slumber Party and help break a world record 
http://www.totalgirl.com.au


RE: Two problems

2006-09-14 Thread Max Dyckhoff
Ah, I can understand that. I have (so far) in my professional career never had 
the joy of maintaining someone else's code, or when I have it is written with 
nice guidelines that avoid lng lines ;)

Hope you get on well with it!

Max



 -Original Message-
 From: Meino Christian Cramer [mailto:[EMAIL PROTECTED]
 Sent: Thursday, September 14, 2006 7:21 PM
 To: Max Dyckhoff
 Cc: vim@vim.org
 Subject: Re: Two problems

 From: Max Dyckhoff [EMAIL PROTECTED]
 Subject: RE: Two problems
 Date: Wed, 13 Sep 2006 20:30:15 -0700

 Hi Max,

  thanks  a lot for your help ! :)
  (sorry for the late reply...)

  I am maintaining a source code from someone else
  (which left the company) and some of the
  lines of code are long.

  While reviewing the code I find myself often doing
  iC-jEsc and was curious whether someone of the
  vim-profeesionels would do this shorter and more
  elegant.

  Thanks a lot again!
  mcc




  I can't offer anything else immediately (I have a load of mappings
  and functions but they are all pretty tailored to my needs!), but I
  was interested why you would want to split a line in two like
  that. Can you give us an example?
 
  I'm not criticising, I'm just nosy :)
 
  Max
 
  FWIW: the most recent addition to my .vimrc is this, for after 14
  hours of coding when my eyesight starts to fail me. Simple, but it
  has saved my eyes!
 
 
  :let g:maxd_FontSize=10
  :let g:maxd_FontOpts=b
  :let g:maxd_Font=consolas
 
  :map C-S-kPlus:call ChangeFontSize(up)CR
  :map C-S-kMinus   :call ChangeFontSize(down)CR
  :map C-S-kMultiply:call ChangeFontSize()CR
 
  function! ChangeFontSize(updown)
  if (a:updown==up)
  let g:maxd_FontSize= g:maxd_FontSize + 1
  elseif (a:updown==down)
  let g:maxd_FontSize= g:maxd_FontSize - 1
  endif
  exec set
 guifont=.g:maxd_Font.:h.g:maxd_FontSize.:.g:maxd_FontOpts
  endfunction



Re: Two problems

2006-09-14 Thread Meino Christian Cramer
From: Pete Johns [EMAIL PROTECTED]
Subject: Re: Two problems
Date: Thu, 14 Sep 2006 13:46:42 +1000



 On Thu, 2006-09-14 at 04:45:12 +0200, Meino Christian Cramer sent:
 2.) Currently I am reading the ascii version of the vimtips
 file.  One thing I would like to change physically (that means:
 The file should be changed that way, not only the visual
 representation...) are the super long lines into 72 chars ones.
 My attempt to do this was
 
  gqG
 
 which reformats /everything/ (even the embedded scripts). As
 long as it was floating text, the result was ok, but the
 scripts were obfuscated.
 
  I would like to apply the gq-command only to lines longer than
  72 chars -- so the scripts were automagically skipped (as I
  hope...).
 
 How can I accomplish this ?
 
 Here's my attempt:
 
  For all lines longer than 72 characters, reformat the
  paragraph from that line..
 1,$g/.\{73,}/normal v}gq
 
 Hope this helps;
 
 
 --paj
 
 -- 
 Pete Johns   http://johnsy.com/
 Contact Information  http://johnsy.com/contact/
 More On OptusNet   http://johnsy.com/20060912132225
 dsc00220  http://johnsy.com/albums/flickr/210370644

Hi Pete!

 thank you very much for this line of code -- works like a charme!

 The only bad thing is: I dont understand completly, how it
 works

 This far I got:

 1,$for the beginning of the text til its end do
 /.\{73,}/  find all lines longer than 72 chars and for each do
 normal ??? go into normal mode ???
  v ? visual mode (and for what is the   good for?) 
 }gq only white noise for mea C-programme I would
say, that there is on } too many in the whole expression
but simultaneously I know, that I am wrong.???

 Keep hacking!
 mcc
 
  


Re: Two problems

2006-09-14 Thread Pete Johns
On Fri, 2006-09-15 at 04:57:24 +0200, Meino Christian Cramer sent:
Hi Pete!

Hi!


thank you very much for this line of code -- works like a
charme!

Delighted to hear it.


The only bad thing is: I dont understand completly, how it
works

He he... I'm glad that someone's taken this apart :-)

1,$for the beginning of the text til its end do

And there's a 'g'...


/.\{73,}/  find all lines longer than 72 chars and for each do

Yup.


normal ??? go into normal mode ???
 v ? visual mode (and for what is the   good for?)
 

normalv}gq isn't an editor command, so you have to split 'normal'
and 'v'. There may be a better way of doing this.


}gq only white noise for mea C-programme I
would say, that there is on } too many in the whole expression
but simultaneously I know, that I am wrong.???

} is a motion: it moves one paragraph forward.

See :help }

gq formats the highlighted lines.

See :he gq

There are other ways of solving this problem, I am sure, but I
like the way this works because it leaves paragraphs alone that
are shorter then 73 characters wide, rather than expanding them.

Cheers;



--paj
--
Pete Johns   http://johnsy.com/
Contact Information  http://johnsy.com/contact/
More On OptusNet   http://johnsy.com/20060912132225
dsc00220  http://johnsy.com/albums/flickr/210370644



pgpCPeNAGzZPh.pgp
Description: PGP signature


Re: Two problems

2006-09-13 Thread Peter Hodge
Hello,

--- Meino Christian Cramer [EMAIL PROTECTED] wrote:
 
  1.) Splitting line into two from normal mode.
  My current concept (hu...great word...;) to split a line into
  two is (starting and ending in normal mode, which is wanted):
  
   i Ctrl-j esc
 
  Are there any shorter ways to split a line, may be without the
  detour around insert mode ?


I found the following mapping helpful:

  nmap TAB i#ESCr

Basically that lets you hit TAB in normal mode and insert a single character.
 With that mapping in place, you could use TABENTER to insert a linebreak
quickly.

regards,
Peter



 
On Yahoo!7 
Answers: 25 million answers and counting. Learn something new today 
http://www.yahoo7.com.au/answers


Re: Two problems

2006-09-13 Thread Meino Christian Cramer
From: Peter Hodge [EMAIL PROTECTED]
Subject: Re: Two problems
Date: Thu, 14 Sep 2006 13:10:43 +1000 (EST)

 Hello,
 
 --- Meino Christian Cramer [EMAIL PROTECTED] wrote:
  
   1.) Splitting line into two from normal mode.
   My current concept (hu...great word...;) to split a line into
   two is (starting and ending in normal mode, which is wanted):
   
  i Ctrl-j esc
  
   Are there any shorter ways to split a line, may be without the
   detour around insert mode ?
 
 
 I found the following mapping helpful:
 
   nmap TAB i#ESCr
 
 Basically that lets you hit TAB in normal mode and insert a single 
 character.
  With that mapping in place, you could use TABENTER to insert a linebreak
 quickly.
 
 regards,
 Peter
 

Oh, real nice! Very handy! It solves another problem on-the-fly
even before I can post it. Do you have more of these multi-solver tips
for me, Peter ??? :)))

Thanks a lot! :O)
mcc


 


RE: Two problems

2006-09-13 Thread Max Dyckhoff
I can't offer anything else immediately (I have a load of mappings and 
functions but they are all pretty tailored to my needs!), but I was interested 
why you would want to split a line in two like that. Can you give us an example?

I'm not criticising, I'm just nosy :)

Max

FWIW: the most recent addition to my .vimrc is this, for after 14 hours of 
coding when my eyesight starts to fail me. Simple, but it has saved my eyes!


:let g:maxd_FontSize=10
:let g:maxd_FontOpts=b
:let g:maxd_Font=consolas

:map C-S-kPlus:call ChangeFontSize(up)CR
:map C-S-kMinus   :call ChangeFontSize(down)CR
:map C-S-kMultiply:call ChangeFontSize()CR

function! ChangeFontSize(updown)
if (a:updown==up)
let g:maxd_FontSize= g:maxd_FontSize + 1
elseif (a:updown==down)
let g:maxd_FontSize= g:maxd_FontSize - 1
endif
exec set   
guifont=.g:maxd_Font.:h.g:maxd_FontSize.:.g:maxd_FontOpts
endfunction


 -Original Message-
 From: Meino Christian Cramer [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, September 13, 2006 8:23 PM
 To: vim@vim.org
 Subject: Re: Two problems

 From: Peter Hodge [EMAIL PROTECTED]
 Subject: Re: Two problems
 Date: Thu, 14 Sep 2006 13:10:43 +1000 (EST)

  Hello,
 
  --- Meino Christian Cramer [EMAIL PROTECTED] wrote:
  
1.) Splitting line into two from normal mode.
My current concept (hu...great word...;) to split a line into
two is (starting and ending in normal mode, which is wanted):
  
   i Ctrl-j esc
  
Are there any shorter ways to split a line, may be without the
detour around insert mode ?
 
 
  I found the following mapping helpful:
 
nmap TAB i#ESCr
 
  Basically that lets you hit TAB in normal mode and insert a single
 character.
   With that mapping in place, you could use TABENTER to insert a
 linebreak
  quickly.
 
  regards,
  Peter
 

 Oh, real nice! Very handy! It solves another problem on-the-fly
 even before I can post it. Do you have more of these multi-solver tips
 for me, Peter ??? :)))

 Thanks a lot! :O)
 mcc