Live data from Hacker News

Five lines I put in a blank .vimrc

swordandsignals.com

41–50 of 133 posts

Re: Five lines I put in a blank .vimrc

#41
post #2

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.

I 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 fi…

Can't you also auto-save when losing focus?

Re: Five lines I put in a blank .vimrc

#42

It’s not enough. You should go all the way: set nobackup set nowritebackup set noundofile set noswapfile I explain why at https://lee-phillips.org/badvim/ Also, it’s best to just have one instance of Vim running, in server mode, so you can send files to it from the command line.

Why would you not just set the location of the backup and swapfiles to a fixed place in your system? Try this: set backupdir=~/.vim/backups,. set directory=~/.vim/swapfiles,. It will only write in the current directory, if ~/.vim/backups does not exist, and the dot is just there for portability, so nothing breaks when using my vimrc on a new system. Edit: Upon actually reading your blog-post, I understand at least on…

In fact, I think your idea is better, and I’ll probably switch to doing that some day, just in case one of these files turns out to save me.

Edit: Hmmm. I’ll have to think some more about it. Anyway, glad you found my witeup useful.

Re: Five lines I put in a blank .vimrc

#43

Earlier quoted context omitted.

Line numbers are great, until you try to cut and paste. But then again, VI/M wasn't designed for GUIs.

I don’t copy and paste, I just don’t see the need for line numbers. But then I also code with syntax highlighting off about half of the time.

Very interesting, I don't think I've ever talked to someone who would choose to disable syntax highlighting. Do the colors actively annoy you or is it just that you don't care?

Re: Five lines I put in a blank .vimrc

#44

I find it odd that you would use the short version of a command in a config file. Brevity is important when you are doing repetitive tasks. In a config file (or code), clarity is more important that brevity. I know you could argue that you know VI so well that you know these commands off the top of your head.. even so, it's particularly pointless to list them this way in a blog where you have to turn around and expla…

As discussed in the article, the point is to quickly set up vim on fresh linux installations (e.g. virtual machines). For the vim on your own pc, you would likely use the full version, in addition to whatever extra config you prefer.

Re: Five lines I put in a blank .vimrc

#45
post #35
post #21

The swap file saved my work a number of times. If you never use recover and use Vim regularly, then go ahead and disable it; if you haven't used it because you don't know how to use it or you only rarely use Vim, then I'd encourage you to either try it first or leave it enabled (as it is by default) until it becomes a nuisance. And like u/strogonoff, I also disable line numbers, but that's just personal preference of…

> Or typing only Q because you didn't hit the : and accidentally entering ex mode. I'm not certain this is different (because I don't use either deliberately) but I'm forever hitting q (not even trying to quit) and entering some kind of macro recording mode. I think the only reason I haven't yet disabled it like you suggest (after doing it for years now) is that... Well 'some kind of macro recording' does sound like…

Macros are really nice, you can automate transforming several lines of text with them. The Vim plugin in Intellij supports them. Worth learning IMHO.

Re: Five lines I put in a blank .vimrc

#46

I find it odd that you would use the short version of a command in a config file. Brevity is important when you are doing repetitive tasks. In a config file (or code), clarity is more important that brevity. I know you could argue that you know VI so well that you know these commands off the top of your head.. even so, it's particularly pointless to list them this way in a blog where you have to turn around and expla…

Yes, I definitely am much descriptive for the config file on my personal computer. The configs I'm recommending here is more for ephemeral machines that you are using just to look at files (such as sshing into a VM that was created to run integration tests). For those cases, being able to quickly type something into the .vimrc and improve your experience is nice.

Re: Five lines I put in a blank .vimrc

#47
Kinda derailing the thread but might ask anyway, does anyone got recommendations on dot files synchronization through personal devices? I'm currently using a git+ss repo on a personal server.

I wonder if there are more convenient ways to do this.

Re: Five lines I put in a blank .vimrc

#48

Earlier quoted context omitted.

Line numbers are great, until you try to cut and paste. But then again, VI/M wasn't designed for GUIs.

I don’t copy and paste, I just don’t see the need for line numbers. But then I also code with syntax highlighting off about half of the time.

Yay im not alone!

I've always found syntax highlighting super distracting, but everyone i have met thinks im crazy.

Otoh i do love me line numbers.

Re: Five lines I put in a blank .vimrc

#49
I guess it depends if you are doing systems admin or coding, but when I'm coding, I've gotten very dependent on Fuzzy Search like what Sublime Text introduced.

So for me, installing CtrP or FZF is pretty much mandatory (I've settled on FZF). I know this is about config options, and this is an extension, but for me, fuzzy search is pretty much essential for coding once you get to a moderate sized code-base.

Re: Five lines I put in a blank .vimrc

#50

Earlier quoted context omitted.

I 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 fi…

Can't you also auto-save when losing focus?

Hah, 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_lo...

Post reply on HN