Monday, June 1, 2020

Re: function definition for only one file, not for other simultaneously opened files


On 01/06/20 10:13 am, Gary Johnson wrote:
You wrote that you want to have <Enter> insert the date at the start  of the next line, but only in one buffer.  Wouldn't making that  mapping buffer-local solve your problem?  Something like this?        inoremap <buffer> <CR> <CR><C-R>=PrependTime()<CR>        function! PrependTime()          return strftime("%c")      endfunction        See        :help map-<buffer>    You would just need to execute that mapping only in the one buffer  where you wanted that behavior.
Yes, that's what I wanted. Thanks a lot. Somehow I missed this.
If other buffers are throwing error E117, then you have <Enter>  (a.k.a. <CR>) mapped in buffers where it shouldn't be mapped.    Regards,  Gary  

After unmapping and remapping I checked everything works fine.

Thanks a lot everyone.

--
Manas
CSAM Undergraduate 2022

No comments:

Post a Comment