On Thu, 13 Jul 2006 at 10:37am, JD Miller wrote:

>
> " Comment out a line by inserting "# " then move to the lower line
> map <F10> i# <Esc>hj
>
> " Here I try to do the same thing but use the BufEnter event to make the
> comment character
> " change depending on the file type (*.asp).
>
> let comment_char="#"
> autocmd BufEnter *.asp let comment_char="'"
> execute "map <F10> i" . comment_char . " <Esc>hj"
>
> " But the comment_char variable never seems to see the let assignment in the
> " autocmd statement.  What have I missed here?  Is there a better approach?
> " Thank you.
>
>

The reason is, at the time the map is created, you are fixing the
comment_char based on the value at that time. In other means, you are
not using the dynamic value of "comment_char" variable. Try this
instead (assuming you have Vim7):

nnoremap <F10> i<C-R>=comment_char<CR><Esc>hj

-- 
HTH,
Hari

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to