RE: Troubles configuring vim (multi-questions)

2007-04-16 Thread Gene Kwiecinski
By default Vim (and vi) has always put the cursor on the end of a
character that occupies multiple spaces on the screen. I don't know
why this decision was taken, unless it was to make it easier to spot
the difference between lines indented with tabs and those indented
with spaces, but the cursor has to appear somewhere and it might as

That's what I imagine, and appreciate it.  Otherwise, do a '0' and ride
the 'j' key a the way down a file.  If the cursor doesn't budge, how
would you be able to tell if it was a space or multiple spaces there, or
a tab character?  You'd have to go down-right-left, down-right-left,
down-right-left, etc., just to see if the cursor advances to position 1
(space), or skips to position 7 (tab).

Personally, I'd rather exfoliate with a cheese-grater than have to do
*that*...


Re: Troubles configuring vim (multi-questions)

2007-04-16 Thread Tim Chase

Otherwise, do a '0' and ride the 'j' key a the way down a
file.  If the cursor doesn't budge, how would you be able to
tell if it was a space or multiple spaces there, or a tab
character?


Well, if that information is truely useful and what you want to 
know, you can always


:set list

;)

-tim







Re: Troubles configuring vim (multi-questions)

2007-04-16 Thread Jean-Rene David
* Gene Kwiecinski [2007.04.16 11:45]:
 Displays ^I just fine, but trashes actual
 indentation, at least for me (dunno if there's
 any magical 'vim' setting, like :set
 keepindent or something).

set listchars+=tab:-

-- 
JR


Re: Troubles configuring vim (multi-questions)

2007-04-16 Thread Tim Chase
Well, if that information is truely useful and what you want to 
know, you can always

:set list


Displays ^I just fine, but trashes actual indentation, at least for me
(dunno if there's any magical 'vim' setting, like :set keepindent or
something).  Iow, I wanna be able to see

indented text...

and just see whether it's indented with spaces or tabs, not

^I^I^Iindented text...$

with everything squooshed to the left of the screen.

Now, maybe if there were a show character in list-mode, so it'd look
like

indented text

that'd work for me, too.


Looks like you want the listchars setting:

:set listchars+=tab:.

That will turn your above example into

  ...indented text

when you use :set list.  If there isn't a tab clause in your 
'listchars' setting, it defaults to the standard ^I that you 
see by default.


You can choose your characters to be anything[*] you like, and as 
they have their own syntax group, they should stand out and not 
get confused with regular characters.  To duplicate your above, 
you want your listchars to be   (with the space), which you'd 
have to enter as  :set listchars+=tab:\   (with the escaping 
backslash before the space) or possibly


:let listchars=listchars.'tab: '

You can read more at

:help 'listchars'

I personally find it horribly distracting 99.9% of the time, but 
for that 0.1% of the time that I find it useful, nothing compares 
to having the feature already available and just turning it on.  :)


-tim

(okay...not quite anything, I tried setting it with

:set listchars+=^I.

where ^I was a literal tab, and Vim choked on it...I suspect it's 
the same for other control characters, and perhaps other odd 
characters such as multi-byte characters or double-wide 
characters.  But ASCII 0x20-0x7e should work fine.  YMMV)




RE: Troubles configuring vim (multi-questions)

2007-04-16 Thread spencer . x . collyer
Try ':help listchars'






Gene Kwiecinski [EMAIL PROTECTED]
16/04/2007 16:36

 
To: Tim Chase [EMAIL PROTECTED], vim@vim.org
cc: 
Subject:RE: Troubles configuring vim (multi-questions)


Otherwise, do a '0' and ride the 'j' key a the way down a
file.  If the cursor doesn't budge, how would you be able to
tell if it was a space or multiple spaces there, or a tab
character?

Well, if that information is truely useful and what you want to 
know, you can always
:set list

Displays ^I just fine, but trashes actual indentation, at least for me
(dunno if there's any magical 'vim' setting, like :set keepindent or
something).  Iow, I wanna be able to see

 indented 
text...

and just see whether it's indented with spaces or tabs, not

 ^I^I^Iindented text...$

with everything squooshed to the left of the screen.

Now, maybe if there were a show character in list-mode, so it'd look
like

   indented text

that'd work for me, too.

Worse comes to worse, I just do /^I and have all tabs highlighted in
fiery-red, but I can't deal with too much of that, as it sunburns my
retinas fairly quickly.




-
This communication is for informational purposes only. It is not
intended as an offer or solicitation for the purchase or sale of
any financial instrument or as an official confirmation of any
transaction. All market prices, data and other information are not
warranted as to completeness or accuracy and are subject to change
without notice. Any comments or statements made herein do not
necessarily reflect those of JPMorgan Chase  Co., its subsidiaries
and affiliates.

This transmission may contain information that is privileged,
confidential, legally privileged, and/or exempt from disclosure
under applicable law. If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution, or
use of the information contained herein (including any reliance
thereon) is STRICTLY PROHIBITED. Although this transmission and any
attachments are believed to be free of any virus or other defect
that might affect any computer system into which it is received and
opened, it is the responsibility of the recipient to ensure that it
is virus free and no responsibility is accepted by JPMorgan Chase 
Co., its subsidiaries and affiliates, as applicable, for any loss
or damage arising in any way from its use. If you received this
transmission in error, please immediately contact the sender and
destroy the material in its entirety, whether in electronic or hard
copy format. Thank you.

Please refer to http://www.jpmorgan.com/pages/disclosures for
disclosures relating to UK legal entities.



RE: Troubles configuring vim (multi-questions)

2007-04-16 Thread Gene Kwiecinski
Try ':help listchars'

Tnx.  Kinda figured there was some option to do that, but never bothered
to look up what it might be.  Complacency and all...

Good to know, but I still just like the cursor jiggling back'n'forth
between col0 and col7 when I ride the down/'j' key.  It's so much
easier...  :D


Actually, the whole 'listchars' thing gives me some ideas...


Re: Troubles configuring vim (multi-questions)

2007-04-16 Thread A.J.Mechelynck

Gene Kwiecinski wrote:

Otherwise, do a '0' and ride the 'j' key a the way down a
file.  If the cursor doesn't budge, how would you be able to
tell if it was a space or multiple spaces there, or a tab
character?


Well, if that information is truely useful and what you want to 
know, you can always

:set list


Displays ^I just fine, but trashes actual indentation, at least for me
(dunno if there's any magical 'vim' setting, like :set keepindent or
something).  Iow, I wanna be able to see

indented text...

and just see whether it's indented with spaces or tabs, not

^I^I^Iindented text...$

with everything squooshed to the left of the screen.

Now, maybe if there were a show character in list-mode, so it'd look
like

indented text

that'd work for me, too.

Worse comes to worse, I just do /^I and have all tabs highlighted in
fiery-red, but I can't deal with too much of that, as it sunburns my
retinas fairly quickly.




About the fiery red highlight, change your colourscheme; or move it to (on 
Windows, but in Vim terminology) $HOME/vimfiles/colors/ under a changed name 
(create the directories if necessary) then change the highlight for the Search 
 and/or IncSearch groups.


About the width of tabs, see :help 'listchars':

With 'list' on, then if 'listchars' doesn't contain tab: each tab is 
replaced by ^I, trashing indentation. But if it contains tab:xy where x and 
y are any two characters (the same or different) then x marks the start of 
each tab and y the rest of it. Note that spaces, double quotes, bars and 
backslashes must be backslash-escaped.


Examples (assuming ts=8):

:set list listchars=tab:\ \ ,eol:¶
keep tabs as up to 8 spaces, show ends-of-lines with
the Pilcrow mark

:set list listchars=tab:\|_,eol:$
show each tab as one bar followed by 0 to 7 underlines,
ends-of-lines as dollar signs.

:set list listchars=tab:^\ ,trail:§,extends:,precedes:,nbsp:~
show:
- a hard tab as one caret followed by zero or more spaces
- end-of-line is not highlighted
- trailing spaces as §
- last character before overflow right in 'nowrap' mode as 
- first character after overflow left in 'nowrap mode as 
- no-break spaces as (blue) tildes

etc.

Best regards,
Tony.
--
According to Arkansas law, Section 4761, Pope's Digest:  No person
shall be permitted under any pretext whatever, to come nearer than
fifty feet of any door or window of any polling room, from the opening
of the polls until the completion of the count and the certification of
the returns.


Re: Troubles configuring vim (multi-questions)

2007-04-14 Thread Matthew Winn
On Fri, 13 Apr 2007 08:44:26 -0700 (PDT), OnionKnight
[EMAIL PROTECTED] wrote:

 No it didn't make a difference. When you put the cursor in normal mode over
 a tab character, which spans several characters, the cursor will be
 displayed at the end of that area whereas insert mode will put the cursor at
 the beginning of it.

By default Vim (and vi) has always put the cursor on the end of a
character that occupies multiple spaces on the screen. I don't know
why this decision was taken, unless it was to make it easier to spot
the difference between lines indented with tabs and those indented
with spaces, but the cursor has to appear somewhere and it might as
well be at the end as anywhere else.

You can :set virtualedit=all to allow the cursor to be placed anywhere
on the tab, but you need to take care not to damage your tab. If you
start inserting in front of the tab then the text goes before the tab
and the tab is shifted to the right as you'd expect, but if you insert
in the middle of the tab the tab is expanded into spaces before the
text is inserted.

-- 
Matthew Winn


Re: Troubles configuring vim (multi-questions)

2007-04-14 Thread Andy Wokula

OnionKnight schrieb:

I think I understand the difference now and my function is pretty neat now.
function! HomeKey ()
let c = col(.)
if c == 1
normal ^
else
normal ^
if col(.) = c
normal 0
endif
endif
endfunction


quote= comes handy:

   :noremap silent home @=col(.)==1?^:0cr
   :imap home c-ohome

Noremap because it also works for Visual mode.

--
Regards,
Andy

EOM


RE: Troubles configuring vim (multi-questions)

2007-04-13 Thread Eric Leenman

From: OnionKnight [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Troubles configuring vim (multi-questions)
Date: Thu, 12 Apr 2007 17:22:06 -0700 (PDT)


[deleted]


* I wanted the Home-button to act so that it first jumps to the first
non-whitespace character of the current line (i.e. skip the indentation) 
and
if Home is pressed when you're already at the first non-whitespace 
character

or before then it should jump to the real beginning of the line, column #1.
I made this function:
function! HomeKey ()
let c = col(.)
if c == 1
w
else
g0w
if col(.) = c
g0
endif
endif
endfunction
This doesn't want to work properly. It extends the command window and dumps
some code from the bottom of the .vimrc and then asks for pressing enter 
and

lastly jumps to line #180 in the same file. If c == 1 nothing happens, it
doesn't go all wild but that 'w' keypress isn't executed. Also I have
noticed that g0 doesn't really take you back to beginning of the line but
the beginning of the horizontal scroll. A problem, but it doesn't explain
why the code is acting crazy.

[deleted]


Try homeLikeVC++.vim from Luc Hermitte
Look at: 
http://hermitte.free.fr/vim/ressources/vimfiles/plugin/homeLikeVC++_vim.html



Rgds,
Eric

_
MSN is giving away a trip to Vegas to see Elton John.  Enter to win today. 
http://msnconcertcontest.com?icid-nceltontagline




Re: Troubles configuring vim (multi-questions)

2007-04-13 Thread A.J.Mechelynck

OnionKnight wrote:

inside a script you're in command-mode, and the command w you've meant
to should be in normal-mode, the correct way might be :normal w, :normal
g0w, etc...

Couldn't find anything about command-mode. How is it different from normal
mode? Is each line treated as one command? Like g0w is treated as g0w
instead of g0 and w?

[...]

Each script line is treated as one ex-command: if you use w in a script, Wim 
interprets it as write current file (as if you had used :w from the 
keyboard). That's not the same as Normal-mode w (go to next word), and 
Insert-mode w (insert a lowercase w into the buffer) is something else again.



Best regards,
Tony.
--
Real computer scientists only write specs for languages that might run
on future hardware.  Nobody trusts them to write specs for anything homo
sapiens will ever be able to fit on a single planet.


Re: Troubles configuring vim (multi-questions)

2007-04-13 Thread OnionKnight


Easwy Yang wrote:
 
 If you use Vim in windows, see here:
 http://www.vim.org/tips/tip.php?tip_id=1440
 http://www.vim.org/tips/tip.php?tip_id=1314
 
 In Unix, you can use
 gvim --remote-tab-silent filename
 
But there's no way to do that for just the drag-and-drop operation in gvim?
-- 
View this message in context: 
http://www.nabble.com/Troubles-configuring-vim-%28multi-questions%29-tf3569025.html#a9979098
Sent from the Vim - General mailing list archive at Nabble.com.



Re: Troubles configuring vim (multi-questions)

2007-04-13 Thread Yakov Lerner

On 4/13/07, OnionKnight [EMAIL PROTECTED] wrote:

Couldn't find anything about command-mode. How is it different from normal
mode?


Dont confuse 'commandline mode' with 'command mode'.

'comand mode' is same as 'normal mode', they are synonyms [1].

'commandline mode' is a mode which you enter with : from normal mode.
'commandline mode' is also the mode in which scripts are executed.
See more at ':hep vim-modes'


[1] :help normal-mode says:

   *Normal* *Normal-mode* *command-mode*
Normal mode In Normal mode you can enter all the normal editor
   commands.  If you start the editor you are in this
   mode (unless you have set the 'insertmode' option,
   see below).  This is also known as command mode.

Yakov

And yes, vi has the 7th mode.
It's called the 'confusion mode'.
It is a mode in which the beginner user of vi
mostly finds himself during his
first weeks/months/years of using vi.


Re: Troubles configuring vim (multi-questions)

2007-04-13 Thread Charles E Campbell Jr

OnionKnight wrote:


* Is it possible to make the cursor stay at it's position even after
scrolling it out of view? 


Not at the current time.


* At the beginning of an indented line, why does normal mode put the cursor
at the end of the first tab whereas insert mode is position at the beginning
of the line like I think it should? It's annoying to move around in code
like that.
 



I'm not entirely sure what you want here; does having

 set nosol

in your .vimrc help?


* Is it possible to enter insert mode for files that aren't modifiable?
Obviously any changes can't be saved but the buffer shouldn't be any
problems to modify.
 


set ma noro


* Is it possible to close tabs with the middle mouse button?
 



Try mapping it; put the following into your .vimrc:

 nmap middlemouse :tabccr


* I wanted the Home-button to act so that it first jumps to the first
non-whitespace character of the current line (i.e. skip the indentation) and
if Home is pressed when you're already at the first non-whitespace character
or before then it should jump to the real beginning of the line, column #1.
I made this function:
function! HomeKey ()
let c = col(.)
if c == 1
w
else
g0w
if col(.) = c
g0
endif
endif
endfunction
 



You're getting your modes confused.  If that if, for example, was 
executed in normal mode,
it would enter insert mode and insert an f character.  However, its in 
command mode; and that
w is being executed in command mode, too (and it means write the 
file).  Try using


 norm! w

instead.  Likewise with the g0w :

 norm! g0w

etc.


* In gvim, is it possible to have a drag-and-drop action open the dragged
file into a new tab instead of a new buffer? Using the menu is just tedious,
and you can't select multiple files either.
 



Can't answer that -- I never use the mouse to drag-and-drop.  Even if 
you set up some autocmds to do this,
if you drop the same file onto vim you'll still get extra tabs unless 
your code sweeps through all the tabs

and checks for a name match first.


* I want to check a string if it begins with something but I have no clue
why. I was thinking of a regexp but the only way to use matching regexps is
for highlights and substition regexps seems to operate on the whole file or
a selection and no way to use them on strings.
 

Regexp's have nothing in particular to do with highlights.  One can set 
'hls' mode and get matches to
show up, but that's like saying I want to build a cupboard but wood is 
always used to build houses.

Substitutes act over specific ranges:

 :7,10s/abc/def/

will only change lines 7-10, not the whole file.  By string, do you mean 
something with double-quotes?

Just search for it:   /BEGINNING_OF_STRING

Regards,
Chip Campbell



Re: Troubles configuring vim (multi-questions)

2007-04-13 Thread OnionKnight

I'm not entirely sure what you want here; does having
  set nosol
in your .vimrc help?
No it didn't make a difference. When you put the cursor in normal mode over
a tab character, which spans several characters, the cursor will be
displayed at the end of that area whereas insert mode will put the cursor at
the beginning of it.

Try mapping it; put the following into your .vimrc:
  nmap middlemouse :tabccr
But that's for the whole file? I was just thinking of when you middleclick
over the tab button like in Firefox or Opera.

You're getting your modes confused.
I think I understand the difference now and my function is pretty neat now.
function! HomeKey ()
let c = col(.)
if c == 1
normal ^
else
normal ^
if col(.) = c
normal 0
endif
endif
endfunction

Can't answer that -- I never use the mouse to drag-and-drop.  Even if 
you set up some autocmds to do this,
if you drop the same file onto vim you'll still get extra tabs unless 
your code sweeps through all the tabs
and checks for a name match first.
autocmds seems interesting. They're basically callbacks? Would applying some
command/function to BufRead that creates a new tab and assigns that tab with
the new buffer work? I don't really care if it's dragged and dropped or if
it was opened through some command. I was thinking that any opening of a new
file should be done by creating a tab for it, but I felt like taking a
minimalistic approach and allowing other forms of opening to coexist like
using windows or just creating a buffer.

By string, do you mean something with double-quotes?
I was thinking of an internal string, used in command mode, not having
anything to do with the document. But I found a solution in using =~ and
substitute().
-- 
View this message in context: 
http://www.nabble.com/Troubles-configuring-vim-%28multi-questions%29-tf3569025.html#a9981336
Sent from the Vim - General mailing list archive at Nabble.com.



Re: Troubles configuring vim (multi-questions)

2007-04-12 Thread panshizhu
OnionKnight [EMAIL PROTECTED] 写于 2007-04-13 08:22:06:
 I've been thinking of migrating to using vim (gvim) but I'm running into
lots
 of difficulties on the road I just can't solve, and the documentation
is...
 well, strange at best.
It seems that Vim had a longer learning curve than other editors (the only
exception is emacs, which has takes more than a life time to learn...).

So, when you've got used to it, you'll no longer found it strange, and it
will be powerful for you.

 * At the beginning of an indented line, why does normal mode put the
cursor
 at the end of the first tab whereas insert mode is position at the
beginning
 of the line like I think it should? It's annoying to move around in code
 like that.
The answer is probably: VI do it in that way, and vim need to be
compatible with VI.

 * Is it possible to enter insert mode for files that aren't modifiable?
 Obviously any changes can't be saved but the buffer shouldn't be any
 problems to modify.
Sure, this is the default behavior. If yours are not, maybe you've been
affected by system-wide startup scripts. try :set modifiable

 * I wanted the Home-button to act so that it first jumps to the first
 non-whitespace character of the current line (i.e. skip the indentation)
and
 the beginning of the horizontal scroll. A problem, but it doesn't explain
 why the code is acting crazy.
inside a script you're in command-mode, and the command w you've meant
to should be in normal-mode, the correct way might be :normal w, :normal
g0w, etc...


 * In gvim, is it possible to have a drag-and-drop action open the dragged
 file into a new tab instead of a new buffer? Using the menu is just
tedious,
 and you can't select multiple files either.
I don't use the mouse too often. I can use the vim buit-in file explorer
and open files inside vim, which have no interaction with the menu at all.
Remember: most vim features are invoked by command, not the menu.


 * I want to check a string if it begins with something but I have no clue
 why. I was thinking of a regexp but the only way to use matching regexps
is
 for highlights and substition regexps seems to operate on the whole file
or
 a selection and no way to use them on strings.
What do you meant by string?, if you think a string should begin with
quotation mark, then begin your search regexp with the quotation mark.

--
Sincerely, Pan, Shi Zhu. ext: 2606

Re: Troubles configuring vim (multi-questions)

2007-04-12 Thread OnionKnight

inside a script you're in command-mode, and the command w you've meant
to should be in normal-mode, the correct way might be :normal w, :normal
g0w, etc...
Couldn't find anything about command-mode. How is it different from normal
mode? Is each line treated as one command? Like g0w is treated as g0w
instead of g0 and w?

What do you meant by string?, if you think a string should begin with
quotation mark, then begin your search regexp with the quotation mark.
Not in the document, a string in the vimrc.
What I'm trying do to is that if I press F5, which is my run button, and
the file is located in my htdocs folder then it will be opened with my
browser pointing at the file as seen by the server.
elseif expand(%:p:h) == C:\\Program Files\\Apache\\htdocs
execute !\C:\\Program Files\\Mozilla Firefox\\firefox.exe\
http://localhost/; . expand(%)
It looks sorta like that right now. I want to check if the left side of the
== operator begins with the right side. In Perl or Ruby it would be done as
elseif expand(%:p:h) =~ /^C:\\Program Files\\Apache\\htdocs/
-- 
View this message in context: 
http://www.nabble.com/Troubles-configuring-vim-%28multi-questions%29-tf3569025.html#a9971777
Sent from the Vim - General mailing list archive at Nabble.com.



Re: Troubles configuring vim (multi-questions)

2007-04-12 Thread panshizhu
OnionKnight [EMAIL PROTECTED] 写于 2007-04-13 10:05:10:
 Couldn't find anything about command-mode. How is it different from
normal
 mode? Is each line treated as one command? Like g0w is treated as g0w
 instead of g0 and w?

Vim is a multi-mode editor, in different mode, it accepts completely
different set of commands.

So, commands accept in insert-mode may have completely different meaning in
normal-mode.
When you use normal-mode commands inside command-mode, vim will be crazy,
since the meaning of the command is completely different in command-mode
and normal-mode.

Inside vim, you can see :help index
then you'll got the idea what is the commands available in different mode.
(use Ctrl-] to follow a link in help, use Ctrl-O to jump back)


 elseif expand(%:p:h) == C:\\Program Files\\Apache\\htdocs
 It looks sorta like that right now. I want to check if the left side of
the
 == operator begins with the right side. In Perl or Ruby it would be done
as
 elseif expand(%:p:h) =~ /^C:\\Program Files\\Apache\\htdocs/

What you need to see may be :help eval
if you want to do regexp matching, you could use =~ instead of ==
see :help expression-syntax

|expr4| expr5 == expr5  equal
expr5 != expr5  not equal
expr5   expr5  greater than
expr5 = expr5  greater than or equal
expr5   expr5  smaller than
expr5 = expr5  smaller than or equal
expr5 =~ expr5  regexp matches
expr5 !~ expr5  regexp doesn't match

expr5 ==? expr5 equal, ignoring case
expr5 ==# expr5 equal, match case
etc.As above, append ? for ignoring case, # for
matching case

you can use regexp match to do your match.

--
Sincerely, Pan, Shi Zhu. ext: 2606