On Wed, 7 Jun 2006, Hari Krishna Dara wrote:


On Wed, 7 Jun 2006 at 11:18am, Max Dyckhoff wrote:

I completely forgot about abbreviations, although the remap that I came
up with doesn't work badly at all because it does check the command pos,
and I never use any other :sf* command than sfind.

If you could send me a zip of your experimental plugin that would be
great, I'd love to give it a go! I'm using vim 7, if that helps.

Thanks!

Max

Sorry, I forgot that your map also has command position as restriction.
Note that abbreviations have an advantage that they don't timeout
[snip]

That's actually the main reason why I suggested cmapping ':' with the
command position restriction. You don't have to "wait" on it like other
mappings of more than one character. Plus, by default, entering leading
colons on the :cmdline is superfluous. Try "::::::echo '123'".

Max, my mistake on <silent>. I couldn't test the mapping, as I was on my
Linux box with Vim 6.3, so I just fired away. I'm glad that it worked
out :)
--
Gerald

-----Original Message-----
From: Hari Krishna Dara [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 07, 2006 11:16 AM
To: Max Dyckhoff
Cc: Gerald Lai; vim org
Subject: RE: Tab complete filenames


On Wed, 7 Jun 2006 at 9:29am, Max Dyckhoff wrote:

You're working on a large project, so I would advise caution when
doing
tab completion. If you happened to be waiting on an accidental
(slow)
completion like a<Tab>, then hit Ctrl-c to stop it.

Yes, I love how vim is nice and intuitive if Linux stuff is
ingrained in
your every move :)


Nope, no (easy) way. That's just how Vim was implemented. You
could
hack
the source code though.

If you don't have any other commands besides :Sfind beginning with
"Sf",
you can just do :Sf instead of the full :Sfind. It's an extra
Shift
keystroke.

That is a shame. Regrettably I have enough coding to do without
hacking
through the source for vim and getting it to compile on Windows; I'm
sure I could do it in Linux in a couple of minutes but that wouldn't
help me at work much! Curses. However I have found a rather nice
solution (see below).


An (untested) alternative I just thought of is to do something
like
this
(Vim 7):

   cnoremap <silent><expr>:
getcmdpos()==1?toupper(nr2char(getchar())):':'

That is rather great, although it doesn't work with the <silent> tag
in
there. That is, it DOES work, but it is somewhat confusing. Because
of
the <silent> the result of the ":getchar()" will not be displayed in
the
command line, meaning if you enter "::sf" then you will see on the
command line ":f ". Note the space after the "f". If you now press
backspace the command line changes to ":S". Removing the <silent>
makes
the remapping of : work perfectly.

However I was playing around and came up with an alternative mapping
which makes me grin all over. It is a really logical continuation of
the
remapping of : that you provided:

        cnoremap <expr>sf getcmdpos()==1?'Sf':'sf'

Brilliant! It works exactly as I want, and if you pause after the
"s"
before typing the "f" (for timeoutlen) then it aborts the remap and
gives you a lowercase "sf".

Thanks for your help Gerald, I hope this thread helps others in
their
time of need!

Max

I wasn't tracking the thread initially, but here is my input. Maps are
not the best approach for tasks like this, you should use
abbreviations.
With maps, if you type sf anywhere on the commandline, it will become
Sf. You don't want that to happen in a filename right (well, if you
are
on windows you might not care most of the time, but there are enough
other cases you should). I suggest you take a look at the cmdalias.vim
plugin that I wrong just for these cases. If you create an alias like
this:

call CmdAlias('sf', 'Sf')
call CmdAlias('sfind', 'Sfind')

it creates abbreviations such that they get changed only when they are
typed at the start of the command-line and when they are by themselves
(e.g, :sfix will not become :Sfix). I also added a tip recently which
shows how to use cmdalias.vim:

http://www.vim.org/tips/tip.php?tip_id=1247

I use cmdalias plugin heavily and haven't faced any issues.

I was also experimenting with a plugin that would lookup filenames as
you type. Except for a bug in Vim completion bothering me, it works
well, and is usable. Instead of using the 'path' setting, it uses tags
created specially for filenames, so it is a lot faster, you can use
regular expressions and you get a dropdown with all the matching
filenames. If you are interested, let me know I will send you a zip.

--
HTH,
Hari

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



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

Reply via email to