Let's say I have a text file opened in vim. I'd like to be able to edit this file from bash, let's say with the command echo "text" >> file while the file is already opened in vim. Ideally, vim would just refresh the new content and wouldn't bother with a .swp file, asking for what version I want to restore. Any idea how to do this?
Asked
Active
Viewed 47 times
1
DJMcMayhem
- 17,581
- 5
- 53
- 85
ChiseledAbs
- 181
- 5
1 Answers
2
I believe the option you're looking for is autoread. To use it put this in your vimrc:
set autoread
From :h 'autoread':
When a file has been detected to have been changed outside of Vim and it has not been changed inside of Vim, automatically read it again. When the file has been deleted this is not done.
Tumbler41
- 7,746
- 1
- 21
- 48
-
I don't see text updating in vim when I append text from bash to opened file – ChiseledAbs Jul 21 '16 at 21:54
-
1It only updates when vim gets focus again. I don't think there's a way to make it update when it doesn't have focus. – Tumbler41 Jul 21 '16 at 21:59
-
1@ChiseledAbs See: How can I make Vim autoread a file while it doesn't have focus? – Martin Tournoij Jul 21 '16 at 23:26