1

When writing or appending files using python inside vim, new files are not being created and existing files are not being changed. Creating and appending files in python script and atom text editor are working, it's only in vim where it doesn't work.

I'm guessing it could be a permission issue or a bad path but I've tried using an absolute path which didn't help.

Not sure where to look or where to change permission. I can add my .vimrc if needed or plugins.

Here is the python code - i use try to show there is no input/output error:

from pathlib2 import Path

p = Path('/Users/plutonium/Documents/Programs/Python/File')
q = p / 'a.ext'

try:
    with open(q,'w') as f:
        f.write('content')
except IOError:
    print('I/O Error...') # no error
finally:
    print('checked')
  • How are you running this? Do you see the “checked” output? – D. Ben Knoble May 5 '18 at 19:26
  • @DavidBenKnoble yes, it runs smoothly in python script and atom. its just in vim where it doesn't. not sure what is conflicting with it. maybe a permission issue? Although, i can't figure out what to look for or where. – hoodwinked May 5 '18 at 19:52
  • How are you running this in Vim – D. Ben Knoble May 5 '18 at 19:57
  • @DavidBenKnoble not sure what you mean. I guess to see the output i add this command in vim. :!python3 % – hoodwinked May 5 '18 at 20:41
  • it runs it in python script. It just doesn't create or append the files when using vim. – hoodwinked May 5 '18 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.