Saturday, May 30, 2020

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

On 2020-05-31, Manas wrote:
> I am struggling to find a way to deal with the following problem.
>
> Suppose, I open 3 markdown files at once in separate tabs. Now I want some
> particular function for one of those files only. Like, I want to add time and
> date in front of each new line for that file. So I define a function to do so.
> But, that function is affecting other files too which I don't want.
>
> Is there some way to achieve that?

From ":help local-function":

There are only script-local functions, no buffer-local or
window-local functions.

However, you _can_ control how and when your function is executed.
For example, mappings and autocommands can be local to a buffer.
You can also have your function look at the current buffer name or
some other property of the buffer and decide whether to continue
executing or to return immediately.

How are you executing your function and what is it doing to affect
files or buffers that you don't want it to?

Regards,
Gary

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200531004843.GD15884%40phoenix.

No comments: