Thursday, October 23, 2014

Re: shortcuts for long filenames

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!

Have you considered tags? Often people don't create tags files by hand,
but use a tool such as ctags, but you can hand create them or write your
own tag file creation tool. The general original format is

<tagname> <tab> <filename> <tab> <movement> <newline>

Where the movement is an ex-mode movement such as a line number or
/search/. In true vi you can put an ex-mode command, including edits,
in the movement, vim is more restrictive.

Say you create a tag file with this tag:

jquitheme /var/www/html/sites/all/modules/jqueryui_theme/jqueryui_theme.module 1

Then you can use ":tag jquitheme" to go to the top line of it. You can
also use "vi -t jquitheme" to start the editor there.

If you don't think you have used tags before, you are probably wrong.
The vim help system is just a special form of them.

:help tagsrch.txt
open the file with all tag search help

:help tags-file-format
open tagsrch.txt to the section with file format help

:help tag-security
open tagsrch.txt to the section explaining the true vi
security hole

:help 'tags
open options.txt to the section explaining how to set the
filenames to use for tag lookups


If you use tags names that match keywords in your code, you can do
more powerful things like use <ctrl-]> while the cursor is on that
keyword to jump to that tag. Find out what that function does at
a keystroke! Then use <ctrl-t> to pop the stack and return your
cursor to where you were before the <ctrl-]>.


Elijah

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