I'd like to use VIM as a logfile-viewer. Is it possible to reload the current file in a regular time interval (~1s)?
相关问题
- I want to trace logs using a Macro multi parameter
- Error message 'No handlers could be found for
- convert logback.xml to log4j.properties
- Django management command doesn't show logging
- apache modules ap_log_perror is at a different lev
相关文章
- 如何让 vim 支持 .cshtml 文件的代码高亮
- how do I log requests and responses for debugging
- Auto-save in VIM as you type
- How can I use gcc's -I command to add recursiv
- Android Studio doesn't display logs by package
- Vim: overloaded mapping for multiple modes
- Stacktrace does not print in Glassfish 4.1 Cluster
- Out of curiosity — why don't logging APIs impl
use
:set autoread
I like it short and without a lot of hacking or external scripts. You can run this oneliner from ex (whithin vim) when needed (or put each command in vimrc, for when log-files are opened.)
(if you would want to jump (nearly) to the end of the file, just use "G" instead of "lh" with feedkeys)
Explanation:
autoread
: reads the file when changed from the outside (but it doesnt work on its own, there is no internal timer or something like that. It will only read the file when vim does an action, like a command in ex:!
CursorHold * checktime
: when the cursor isn't moved by the user for the time specified inupdatetime
(which is 4000 miliseconds by default)checktime
is executed, which checks for changes from outside the filecall feedkeys("lh")
: the cursor is moved once, right and back left. and then nothing happens (... which means, thatCursorHold
is triggered, which means we have a loop)To stop the scrolling when using
call feedkeys("G")
, execute:set noautoread
- now vim will tell, that the file was change ans ask if one wants to read the changes or not)I like the idea to watch logfiles in vim (instead of tail -f), e.g. when you are working in an ssh session without screen/tmux. Additionally you can copy directly from the logfile, if needed, or save the output directly or ... whatever you can do with vim :)
*from this answer (refering to an answer by PhanHaiQuang and a comment by flukus)
See this VIM tip. It offers tailing (like tail -f) together with log line numbering