i
- 2024-09-24 - 2024/09/24/W11-Warning-File-has-changed-since-editing-started/

Occasionally I need to look at log files on a server to try and debug an issue. Sometimes I just tail the log file and watch it scroll by. This works most of the time on a dev instance. But on a production instance, there’s typically way too much activity, so often I’ll use trusty old vim so that I can scroll through, search, etc.

Unfortunately, a lot of times with an actively changing log file, vim will try to helpfully let you know that the file has been modified since you began editing. In a lot of cases, that is helpful, but in this scenario, it’s just plain annoying.

After repeatedly hitting “O” for OK or “L” to reload the file, I finally decided I needed to figure out how to make this go away. I found the answer!

In Vim, enter the following

:set autoread

Now, get to figuring out that bug!

Author: S. Eric Asberry
URL: https://blog.ericasberry.com/2024/09/24/W11-Warning-File-has-changed-since-editing-started/
- 2016-09-18 - 2016/09/18/Quick-tip-for-joining-lines-with-a-separator-in-vim/

Every so often I need to deal with some exported database id’s that come in the form of a CSV file.  The trouble is, instead of having the id’s one per line, I really need them on a single line, comma-separated so that I can use them in an IN clause in some kind of query.  I always remember this is easy to do in vim, but I can never remember the syntax.  So here it is, for my (and maybe somebody else’s) future reference:

:%s/\\n/,/

: to enter command mode
% to select all lines
Then the substitute command to search and replace all newlines in the selected block with a comma.  

Of course you could use the pipe character or whatever other delimiter you need in place of the comma.

Now that I’ve written it down somewhere hopefully I’ll never forget it!

Author: S. Eric Asberry
URL: https://blog.ericasberry.com/2016/09/18/Quick-tip-for-joining-lines-with-a-separator-in-vim/
keyboard_arrow_up