5 ms·
Keeping the swapfile on is really helpful when I accidentally open the same file in two different vim editors. But I do recommend configuring vim to place swapf
by lilyball 6y ago
Keeping the swapfile on is really helpful when I accidentally open the same file in two different vim editors. But I do recommend configuring vim to place swapfiles in a different location, so you’re not scattering them all over your disk.
- climb_stealth 6y agoI actually went full on in the other direction and often have multiple vim instances working on the same file. It feels so much better than having to deal with swap file error messages. With the below it reloads the file when the window gets into focus. Super helpful when working in lots of terminal tabs. You just have to get into a habit of saving after every change as it conflicts otherwise. " check for and load file changes when a window is focused. Together with " `noswapfile` this allows to edit the same file in multiple nvim instances and " have the changes reloaded whenever the focus is changed. autocmd WinEnter,BufWinEnter,FocusGained * checktime
- throwaway744678 6y agoCan't you also auto-save when losing focus?
- climb_stealth 6y agoHah, I would think so. I'm not really familiar with the scripting side and end up searching for solutions online. See [0] for something to try. [0] https://vim.fandom.com/wiki/Auto_save_files_when_focus_is_lost https://vim.fandom.com/wiki/Auto_save_files_when_focus_is_lo...
- MinusGix 6y agoMaybe could have it work on a cloned temp file, and then autosaving on losing focus. Opening the same real-file would lead to the same temp-file. Might be able to make manual :w save the temp to the real, but may be better to have it as a separate command.
- em-bee 6y agowhy would you need to open the same file in multiple tabs instead of switching tabs to get to the file. in the few cases where i really need to open the file multiple times i use tmux to allow a shared view.
- climb_stealth 6y agoMostly because I'm using kitty [0] and the tab and split-view handling in it is super quick and effortless. For example instead of opening a :vsplit in vim I just split my terminal and open a second instance on vim on the same file. You lose pretty much all the advanced buffer handling that vim offers, but I never used them much in the first place. It's a bit crude but I really like how it results in a uniform way of working in the terminal. As opposed to handling different files and processes depending on what applications is currently running. [0] https://sw.kovidgoyal.net/kitty/ https://sw.kovidgoyal.net/kitty/
- em-bee 6y agooh, i see. in large files you may want to see multiple sections to compare them. i usually use less for that, view (which is readonly vi) also works well. and of course i realize that opening multiple tmux views with the same window doesn't even help with that.