On Sep 24, 6:52 am, Steven Woody <[email protected]> wrote:
> On Wed, Sep 23, 2009 at 7:38 PM, Henrik Öhman <[email protected]> wrote:
> Yeah, I have ctags, but could you explain these nnoremap commands, look hard
> to me :)

Here's a detailed berakdown of one of the mappings.

Use an expression mapping to allow expression evaluation

    nnoremap <expr> gf

Run the taglist() function on the file name under the cursor (expand
('<cfile>')). taglist() returns a list of tags matching the filename.
Use the empty() function to check if there was a matching tag.

empty(taglist(expand('<cfile>')))

Using the ternary operator, chose a command depending on the result of
empty() above. If the list of matches returned by taglist() was empty,
revert to the original 'gf' command. Otherwise, if we found a matching
tag, run ':tag' on the file name under the cursor.

? "gf" : ":ta <C-r><C-f><CR>"

The relevant help topics are
* :help <expr>
* :help expand(
* :help taglist(
* :help empty(
* :help expr1
* :help :tag
* :help c_CTRL-R_CTRL-F

Don't forget to use the --extra=+f option to ctags. This is required
to create an entry in the tags file for each source file.

Henrik.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to