Re: Mapping using Let in Autocmd
On 2006-07-13, JD Miller <[EMAIL PROTECTED]> wrote: > " Comment out a line by inserting "# " then move to the lower line > map i# 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 i" . comment_char . " 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. On 2006-07-13, JD Miller <[EMAIL PROTECTED]> wrote: > Thanks much Hari, > > I added a space before the and your method works nicely. > > map i=comment_char hj Another approach to this would be to make the mapping local to the buffer, e.g., map i#hj autocmd BufEnter *.asp map i'hj HTH, Gary -- Gary Johnson | Agilent Technologies [EMAIL PROTECTED] | Wireless Division | Spokane, Washington, USA
Re: Mapping using Let in Autocmd
Thanks much Hari, I added a space before the and your method works nicely. map i=comment_char hj Jim -- View this message in context: http://www.nabble.com/Mapping-using-Let-in-Autocmd-tf1938850.html#a5318140 Sent from the Vim - General forum at Nabble.com.
Re: Mapping using Let in Autocmd
On Thu, 13 Jul 2006 at 10:37am, JD Miller wrote: > > " Comment out a line by inserting "# " then move to the lower line > map i# 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 i" . comment_char . " 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 i=comment_charhj -- HTH, Hari __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Mapping using Let in Autocmd
" Comment out a line by inserting "# " then move to the lower line map i# 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 i" . comment_char . " 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. -- View this message in context: http://www.nabble.com/Mapping-using-Let-in-Autocmd-tf1938850.html#a5313061 Sent from the Vim - General forum at Nabble.com.