I want to add placeholders to some templates I have like
<+TITLE+> <+DATE+> etc. I then want to map a keyboard shortcut to do the following
 1. find next placeholder
 2. remove placeholder
 3. place cursor where placehoder where
 4. go into insert mode.

I started out on the command, but got kinda stuck. :map <C-j> /<+.\++><CR>:s/<+.\++>//<CR>'.i

it almost works, except that it places the cursor at the beginning of
the line instead of at the place of the placeholder.

Here's my first stab at the matter:

        :nnoremap <c-j> /<+.\{-1,}+><cr>c/+>/e<cr>

which is

/               find
<+.\{-1,}+>       a minimal tag
<cr>              (do the find)
c               change
/+>/e                to the "e"nd of the "+>"
<cr>              (end of the 2nd search)

The reason for using the minimal operator ("\{-1,}") is to ensure that there's at least something within (the "1" bit), but that you don't swallow multiple tags if they occur on the same line.

Just a few ideas,

-tim





Reply via email to