Live data from Hacker News

Five lines I put in a blank .vimrc

swordandsignals.com

101–110 of 133 posts

Re: Five lines I put in a blank .vimrc

#101
post #85
post #76

Earlier quoted context omitted.

> I don't think the problem is actually swap files themselves, though, but the user experience with them. Agreed, the UX is 99% the reason of me hating swap files. More often than not I choose recover, only to discover the diff is literally null. Come on, you could not check for that before interrupting? And then in any case you have double the annoyance with that recovered buffer as the old swap remains and you have…

> only to discover the diff is literally null. Note that you can save the trouble of running diff by watching for the message "Buffer contents equals file contents." Only when they're different, you'll want to write the file to another place and diff it. What bugs me a lot is that, even if the contents are equal, it doesn't cleanup the swap file... is there maybe a command for that so I don't have to go back to my te…

I don’t think you even need to write, I have this shortcut[0]:

    nmap d :w !diff -u % -
It writes the buffer’s content to diff’s stdin, and diff gets passed the filename (hence the current on disk content) to compare vs stdin (hence the current buffer content).

Only I wish it were run automatically by vim in aforementioned cases before whining (case a: recover, run the above, if no diff stop complaining; case b: rewind til last save, run the above, if no diff then replay and save without complaining)

[0]: https://github.com/lloeki/vimfiles/blob/9c50f3be60e536518beb...

Re: Five lines I put in a blank .vimrc

#102
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…

inoremap jk inoremap kj are essential to me... press both at the same time and you exit insert mode regardless of which one gets pressed slightly faster and you never leave the home row and if you press it when you are not in insert mode it's basically a nop unless you are at the start or end of the file. even if you are you might move down or up a line accidentally but i've never had that happen personally.

This is the first thing in my config, whenever I try to setup in a new system. Now "kj" and ":w" has become more like a muscle memory, even when I am just staring at the abyss...

Re: Five lines I put in a blank .vimrc

#103
I have a .vimrc I set up a decade or so ago. I can't remember what's in it, just that I have to comment out a few lines every time I copy it from a Mac to Linux or vice versa.

In retrospect, I probably should have just gotten used to whatever the default is, because using Vim without my .vimrc doesn't actually feel like Vim to me.

Re: Five lines I put in a blank .vimrc

#104
post #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.

I use syncthing to sync a directory, then symlink my dotfiles into place from the synced directory to the location where they are expected.

A few are in a git repo, such as my homedir's Makefile:

https://git.eeqj.de/sneak/hacks

Re: Five lines I put in a blank .vimrc

#105

Earlier quoted context omitted.

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.

I guess I don't see a lot of situations where I use systems so casually that I don't have config options set. Even when I was managing a bunch of systems I would push out the same config on them all.

One scenario I could see this fitting is when having to connect to some docker container and test a change on the fly.

That's a bit naughty but sometimes needed to prove something useful.

In that case you've got an effemeral file system, and probably had to install Vim in the first place, knowing that that when you close the container all will be forgotten.

Ofcourse in that situation you probably don't need to disable the Vim swap files, so that's one less thing to changet the defaults on.

I often use Busybox for that kind of thing as you're usually missing other useful OS stuff and its little Vi clone is usually enough.

Re: Five lines I put in a blank .vimrc

#106
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…

Personally I get round some of these problems by using :x instead of :wq for write/quit.

It's one letter shorter and less likely to be confused.

Re: Five lines I put in a blank .vimrc

#107
Holy crap, first 4 lines are cancer! HATE hilight, incremental, very much want case sensitivity, and don’t need wasted space and attention with numbering every line. Current line (and column) in status bar is enough.

No swap file is good though.

Re: Five lines I put in a blank .vimrc

#108
post #61

Earlier quoted context omitted.

If your vim is compiled with the correct flag for GUI operations (I forget which), you can yank/delete text into the * or + registers to make it available to the system clipboards. This won't bring the line numbers, and lets you avoid using the mouse.

I use vim in a terminal, the way the gods intended, not gvim. ;-P But apparently according to peer comments, there are ways to yank into clipboards, which is pretty cool.

Not only that but if you set your mouse up correctly then you can use the mouse for selections and have it respect window splits too.

That works in tmux too. So you can have use the terminal but have it behave as a GUI app in most respects. For example being able to use a touchpad to quicly enlarge/resize splits or scroll a window can be quite useful.

Re: Five lines I put in a blank .vimrc

#109

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…

It's not a big deal. You can just hit K on any you're not sure about to see the help. Might need to set keywordprg=:help.
Post reply on HN