Live data from Hacker News

Five lines I put in a blank .vimrc

swordandsignals.com

31–40 of 133 posts

Re: Five lines I put in a blank .vimrc

#31
post #4

I'd prefer one line it and use the "long" names and add nocompatible set nocompatible hlsearch incsearch ignorecase number then sane tabs set et sts=4 sw=4

I switch between enough different projects with different coding styles that I have shortcuts to change between them:

    set expandtab
    set shiftwidth=4
    set softtabstop=4
    function Spaces(...)
        if a:0 == 1
            let l:width = a:1
        else
            let l:width = 4
        endif
        setlocal expandtab
        let &l:shiftwidth = l:width
        let &l:softtabstop = l:width
    endfunction
    command! T setlocal noexpandtab shiftwidth=8 softtabstop=0
    command! -nargs=? S call Spaces()
    autocmd BufNewFile,BufRead ~/src/linux/* T
    autocmd BufNewFile,BufRead ~/src/git/* T
    autocmd FileType html S 2
    autocmd FileType tex S 2
This sets the default to 4-space indents, but lets me do :T to switch to tabs (and does so automatically for Linux and Git which use that style), or :S N to switch to N-space indents (and automatically switches HTML and TeX to 2-space indents).

Re: Five lines I put in a blank .vimrc

#32
These seem a bit too opinionated to me, mostly because of 'set noswapfile'.

For me vim-sensible [1] has a more useful set of defaults (although more than five lines). Also, the readme of that project lists benefits of using a universal set of defaults.

[1] https://github.com/tpope/vim-sensible

Re: Five lines I put in a blank .vimrc

#33

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.

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.

Re: Five lines I put in a blank .vimrc

#34

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…

Interesting. The first thing I always do in a new is enable the line numbers. I pair-program a lot and find them to be invaluable when talking about the code.

I can see how line numbers would be immensely useful if I ever pair program remotely.

Re: Five lines I put in a blank .vimrc

#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 it might be pretty useful if I bothered to learn to use it!

Re: Five lines I put in a blank .vimrc

#36

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…

Thanks, I didn't know about putting everything on one line. I've updated the post to include this tip.

As for showing line numbers, I'm often doing this to read logs on a remote VM. In those scenarios, having easy access to where you are in the file is really helpful.

Re: Five lines I put in a blank .vimrc

#37
post #22
post #10

Earlier quoted context omitted.

Why nocompatible?

Not necessary, AFAIK, unless you invoke vim using the alias "vi". If you call "vim" it'll start in nocompatibe mode by default. The nocompatible mode means adding some features to vim rendering it "incompatible" with the original vi. For example in the original vi you can only undo the last action, with compatible mode on vim will mimic this behavior.

Takes a whole stroke off your shell game!

Re: Five lines I put in a blank .vimrc

#39
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 explain them anyhow.

Re: Five lines I put in a blank .vimrc

#40

In Firefox on macOS, the font fallback to "Apple Color Emoji" is doing really weird things on my machine (like cutting off the top of the number "5"). With that said, thanks for the tips—`set noswapfile` definitely fits my workflow more than not.

Oh wow I had no idea that it looks so bad on Firefox. Thanks for pointing it out, I will look for a fix.

Edit: fixed by removing "Apple Color Emoji" from the list. Thanks!

Post reply on HN