Live data from Hacker News

Five lines I put in a blank .vimrc

swordandsignals.com

61–70 of 133 posts

Re: Five lines I put in a blank .vimrc

#61

Why not one line? set hls ic is nu noswf On a serious note, personally disabling line numbers is the first thing I do in a new editor. Reduces visual noise—status line usually shows current line number anyway, jumping to a line might take a second and I found I don’t need to know my line numbers more frequently than once per month or so. What I do like to enable in an editor is visible whitespace characters (helps no…

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

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.

Re: Five lines I put in a blank .vimrc

#62

Earlier quoted context omitted.

Line number are super helpful for navigating in vim, though. :54 when you’re on line 20 is much faster than any alternative.

Some folk like `34d` so they don't need to press shift. And sometimes set relative line numbers so they don't need to do the subtraction. Others just search for known text, which IMO is a habit I need to get into. I "got" hjkl after I disabled the cursor keys for a day, but I never followed up and disabled hjkl (or maybe even w and b!?) to get super efficient.

You can just use 54gg, no shift involved.

Re: Five lines I put in a blank .vimrc

#63

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…

You should end your swapfile directory setting with two slashes, i.e.:

  set directory=~/.vim/swapfiles//,.
From the help text for "directory":

> For Unix and Win32, if a directory ends in two path separators "//", the swap file name will be built from the complete path to the file with all path separators replaced by percent '%' signs (including the colon following the drive letter on Win32). This will ensure file name uniqueness in the preserve directory.

Re: Five lines I put in a blank .vimrc

#64
Line numbers can be quite handy when coding with somebody over a video connection. Instead of saying "I think the problem is 8 or 9 lines up from the cursor", it's just easier to say "look at line 314" or whatever. I seldom use j and k to go more than a line or two, preferring absolute or relative line jumps, and I find absolute jumps easier to do accurately, especially if I'm tired.

Re: Five lines I put in a blank .vimrc

#65

Earlier quoted context omitted.

Line number are super helpful for navigating in vim, though. :54 when you’re on line 20 is much faster than any alternative.

Some folk like `34d` so they don't need to press shift. And sometimes set relative line numbers so they don't need to do the subtraction. Others just search for known text, which IMO is a habit I need to get into. I "got" hjkl after I disabled the cursor keys for a day, but I never followed up and disabled hjkl (or maybe even w and b!?) to get super efficient.

I often navigate with the search. It's fast as I usually know where I want to go.

Also with the right setting(I think incsearch) Vim immediately jumps to the first result as you type, so I often use search to quickly peek at some code and then jump back with Esc when it doesn't warrant splitting the buffer.

But I do still struggle a bit with moving within the line - w and b tend to "get caught" in long series of different symbol categories that Vim will all see as separate words/tokens. At least I got my setup with the "camelcasemotion" plugin working, which is a great help with long identifier names.

Re: Five lines I put in a blank .vimrc

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

I hit :w so reflexively and regularly in working files that swap files only occasionally saves my butt: when I've done substantial work in a new buffer that I haven't figured out how to name yet and there's a crash.

This happens just often enough that I have to regard it as useful, but it's also less common than crashes that leave me with swaps to contend with across a dozen files that really were pretty much fine. This is a frequent annoyance.

So: occasional big help vs frequent annoyance.

I don't think the problem is actually swap files themselves, though, but the user experience with them. What vim does is prompt you to choose what to do before you've even had a chance to compare the swap with what's saved, and provides no help with the comparison. What'd be nice is if it gave you some kind of visualization of a diff between the two and then prompted you for a choice.

Re: Five lines I put in a blank .vimrc

#67
post #13

Tastes differ; I would never set 'ignorecase' as a default, and instead of 'number', which is only occasionally necessary and most of the time is visually disturbing, I'd set 'ruler', or a slightly more fancy 'statusline'. The most important one, however, for me is 'set guicursor+=a:blinkon0'.

I went back and forth with ignorecase until I discovered that placing \c in the search pattern will make that search case insensitive. This makes it much easier to do the odd case insensitive search but keep the default case sensitivity. (\C does the opposite if your default preference is the other way).

Re: Five lines I put in a blank .vimrc

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

I hit :w so reflexively and regularly in working files that swap files only occasionally saves my butt: when I've done substantial work in a new buffer that I haven't figured out how to name yet and there's a crash. This happens just often enough that I have to regard it as useful, but it's also less common than crashes that leave me with swaps to contend with across a dozen files that really were pretty much fine. T…

100% agree on that last paragraph.

For what it's worth, Vim never crashes on me. For me swap files are mostly helpful with broken connections, killed VMs that apparently still had a vim session open in a faraway terminal, or other such situations.

Re: Five lines I put in a blank .vimrc

#69
post #60

Earlier quoted context omitted.

I would type "8j8j8j8jjj". I type "8j" (and "8k") a lot.

I bind those commands to "shift-j" and "shift-k" and heavily abuse them. It's not pretty, one could argue that the mouse is more efficient for such movements, but for me it's faster in practice than moving my hand to the mouse/trackpad, or than looking up a line number (either absolute or relative) and then typing it. And it has no mental burden.

I usually go with { and } for those to jump between paragraphs, as that is usually a sensible distance of movement. But your approach is also an interesting addition as it's more consistent.

Re: Five lines I put in a blank .vimrc

#70

Why not one line? set hls ic is nu noswf On a serious note, personally disabling line numbers is the first thing I do in a new editor. Reduces visual noise—status line usually shows current line number anyway, jumping to a line might take a second and I found I don’t need to know my line numbers more frequently than once per month or so. What I do like to enable in an editor is visible whitespace characters (helps no…

For spaces, I have:

    set listchars=tab:>-

    set listchars+=trail:⋄
This shows markers for tabs and trailing whitespaces.

The latter will make you very sad when you browse other people's code.

Post reply on HN