1

I know that vim retains some meta information about a file (like cursor position before you last closed it, file type if you have manually set it)

How can I reset this information? I'm in a very weird situation where I have a file x and I have a file y that is just a symlink to x.

I'm getting a weird error whenever I try to edit y but I don't encounter it when editing x directly, indicating that this has something to do with the file state rather than the error being legitimate (error message is about a plugin but removing that plugin doesn't stop vim from trying to invoke functions in that plugin in the file y, though it does not give any error in file x or any other symlinks of x)

How do I just reset the file y? I've tried deleting and restoring it, to no avail. I cannot rename it, it's a configuration file so it must be present in a certain location.


Answers to some follow up questions:

  1. Are the file extensions same? Yes, and so is :set ft?.
  2. Are any plugins that save / restore session state? I have inspected the plugins and does not seem that's the case
  3. Is :scriptnames same between both the files? Yes
Peeyush Kushwaha
  • 302
  • 1
  • 11
  • Note: I couldn't find an appropriate tag for this question, edits welcome – Peeyush Kushwaha Nov 24 '20 at 07:08
  • 2
    Try deleting the .viminfo file in your home directory, though I have doubts about this being the cause: https://vi.stackexchange.com/questions/10671/what-are-the-viminfo-and-netrwhist-files – Endre Both Nov 24 '20 at 08:40
  • What plugin functions does Vim try to invoke? – Endre Both Nov 24 '20 at 08:40
  • 1
    What is the error? – Rich Nov 24 '20 at 09:48
  • @EndreBoth remove from where? removing ~/.viminfo does not seem to reset file state (vim still remembers last edit position). – Peeyush Kushwaha Nov 24 '20 at 10:36
  • @EndreBoth and @Rich it's error detected while processing function AutoPairsInsert: line 1: E121: Undefined variable: b:autopairs_enabled but IMO that's garbage. I removed autopairs extension, removed syntax highlight extension for the file, changed file type, all to no avail – Peeyush Kushwaha Nov 24 '20 at 10:39
  • Use :scriptnames from both x and y to see which Vim scripts get loaded with each and then see whether there's a difference. Do files x and y have different extensions that would trigger different filetypes? (Also, try :set ft? to inspect it with each file.) Do you have any plug-in that's restoring views or sessions? Please [edit] your question to include answers to these follow ups. – filbranden Nov 24 '20 at 16:16
  • @filbranden done. But honestly I do not want to "debug" this issue any further, I want to first try something that will remove file-related data like "last edit position". .viminfo didn't, sadly. Was it supposed to? – Peeyush Kushwaha Nov 25 '20 at 16:49
  • @EndreBoth actually that worked! I don't know, I must have messed up before and not removed the .viminfo file (but thought I did). When I did it now, it did reset the last edit position and ALSO fixed the issue! You may post it as an answer and I'll accept it – Peeyush Kushwaha Nov 25 '20 at 16:55
  • @PeeyushKushwaha - Hm, I'm still wondering. Filbranden's suggestions seem to make a lot of sense. But at least you've got rid of the error message :). – Endre Both Nov 29 '20 at 09:13
  • I am not completely sure it will work, but have you tried :bd on both files? Then reopen them. Then maybe save state wshada for nvim. – eyal karni Nov 30 '20 at 12:26

0 Answers0