Thursday, October 23, 2014

Re: shortcuts for long filenames

Hi,

DwigtArmyOfChampions schrieb am 23.10.2014 um 14:58:
> Oftentimes I'm opening really long filenames in command mode, for
> example:
>
> :e> /var/www/html/sites/all/modules/jqueryui_theme/jqueryui_theme.module
>
> Is there a way to create aliases for this file? Or if not the whole
> file, how about part of the path, like everything up to and including
> "modules"? That's a lot of typing!

you can define a simple command line abbreviation

cnoreabbrev mods /var/www/html/sites/all/modules/

But that would trigger every time you write the word "mods" on the
command line.

A better version of this abbreviation is

cnoreabbrev <expr> mods getcmdtype() == ":" && getcmdline() =~ '\smods$' ? '/var/www/html/sites/all/modules/' : 'mods'

This abbreviation checks that you are in colon mode (and not at the
search prompt) and makes sure 'mods' was at least separated from other
text by a whitespace character. That way you prevent 'mods' from being
expanded if it part of a file path or file name.

If you want a different name for the abbreviation make sure to replace
'mods' in all three places.

Regards,
Jürgen

--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment