stupid vim notes

I really need to just put my vimrc in a git repo on the tubes somewhere. I’m always forgetting these things. I’m not hardcore about custom configs, but this stuff really helps. If you’re not familiar with these things, this helps.

my ~/.vimrc file usually looks like this:

syntax on # enable coloring for source and scripts
set tabstop=2 # make tabs two spaces instead of five or whatever
set expandtab # uses spaces instead of tabs
set background=dark # make that dark blue text light blue because I use black backgrounds

When you open a dos text file on a unix box, sometimes it’s full of ^M characters. This is because of the CR/LF or CR difference. Sometimes it’s just visually annoying and distracting, sometimes a daemon crashs and burns because of them. I used to use :set filetype with unix/dos or something to convert files. These days I just open the file in vi/vim and do

:% s/^M$//

You need to enter the ^M by typing CTRL+V then CTRL+M.
:% means all lines
s is a substituion regex
^M$ is what you want to match, the $ meaning ‘at the end of the line’
the emptiness inside the // means you want to replace ^M with nothing

then save the file. ( :wq )

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.