Thursday, October 23, 2014

Re: shortcuts for long filenames

On 2014-10-23 05:58, DwigtArmyOfChampions wrote:
> 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!

A couple ideas in addition to Jürgen's good suggestions:

- you can use tab-completion, so you could type

:e /v<tab>/www/h<tab>/si<tab>/all/m<tab>/jq<tab>

or something like that


- You can store the things you want in a variable/register and then
recall them on the command-line using control+R to insert them:

:let @m='/var/www/html/sites/all/modules/' " do this once
:e <C-R>mjq<tab>jq*theme.module

where the "<C-R>m" inserts the contents of the register "m" in
which you stored the path you want. You can even set up multiple
registers if you have multiple paths. You can also use variables
if you prefer more descriptive (and less-likely to get tromped by
yanking/pasting), so you could do

:let mod='/var/www/html/sites/all/modules/' " do this once
:e <C-R>=mod<CR>jq<tab>jq*theme.module

- if you have other files open in the same directory, you can use the
'autochdir' setting to enter that directory which would make it as
simple as going into a sibling file's window/buffer and then
issuing

:e jq*theme.module

or some such command because you don't need to enter the path


I'm sure there are other snippets/plugins that would make this easy
as well, but the above have sufficed for me when I've had such a need.

-tim







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