Live data from Hacker News

Five lines I put in a blank .vimrc

swordandsignals.com

21–30 of 133 posts

Re: Five lines I put in a blank .vimrc

#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 course. For vim newbies, relative lines might also be worth checking out: "set relativenumber".

One thing that really annoys me is :Wq or :Q not being commands. Or typing only Q because you didn't hit the : and accidentally entering ex mode. Or hitting F1 instead of escape. I can recommend:

    command Wq wq
    command WQ wq
    command W w
    command Q q
    nnoremap Q 
    map  
    imap  
Or for the non-newbie that has the 'too many terminals' problem, "set title" will give your terminals more useful titles. There are a bunch more things, of course, but these are the lines in my vimrc that I think are useful to most people.

Re: Five lines I put in a blank .vimrc

#22
post #10
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

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.

Re: Five lines I put in a blank .vimrc

#23
post #3

I'm not going to set noswf . However, I run into the problem the writer mentions all the time where I'm opening an already opened file. Is it possible to just switch to the already opened file?

Yes, it is (at least on Mac in 2013): https://youtu.be/aHm36-na4-4?t=749

Re: Five lines I put in a blank .vimrc

#24

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…

    set list listchars+=space:•
This adds a lot of clutter! It's better to show only indentations (of course, using tabs):

    set listchars=tab:├─

Re: Five lines I put in a blank .vimrc

#25

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 one reason - my options may not change the behaviour of a file not being written to the correct inode, so you have a point for some build systems.

I actually learned rather much reading this, thank you for sharing!

Re: Five lines I put in a blank .vimrc

#26
post #16

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…

Funny you say that about the visual noise because as someone who’s dyslexic, I find line numbers actually help with readability since it is easier for me to remember a number than it is text. I also find it especially useful in vi when working with config files. I’m sure you are aware of this feature but in case others aren’t, in vi if you type numbers before a command, it runs that commend n times. So you can quickl…

Indeed, to your last sentence.

I use shift+v and a j/k relative jump to select a range of lines, then do the operation. Which is undeniably the slower way.

Didn’t know how dyslexia affects this, I will keep that in mind in case I happen to work with someone with it.

Re: Five lines I put in a blank .vimrc

#27

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.

I laughed at the poetry of the line "I don’t really want Vim to litter my filesystem with all of these piles of nervous energy."

Truth

Re: Five lines I put in a blank .vimrc

#29

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 have never considered disabling hjkl, quite an interesting idea.

Re: Five lines I put in a blank .vimrc

#30

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.
Post reply on HN