21

There are .vimrc related questions found here and here.

This question wants to deal with a minimalistic .vimrc file.

If you are on a new machine with no .vimrc file what are some 'must turn on' commands you use before doing any typing?

Community
  • 1
  • 1
Yada
  • 30,349
  • 24
  • 103
  • 144

10 Answers10

27

Here's my minimal settings with comments:

set backspace=2         " backspace in insert mode works like normal editor
syntax on               " syntax highlighting
filetype indent on      " activates indenting for files
set autoindent          " auto indenting
set number              " line numbers
colorscheme desert      " colorscheme desert
set nobackup            " get rid of anoying ~file
Yada
  • 30,349
  • 24
  • 103
  • 144
15

There is never a need for a minimalistic configuration. This solves everything:

wget -O ~/.vimrc http://github.com/lucasoman/Conf/raw/master/.vimrc
Lucas Oman
  • 15,597
  • 2
  • 44
  • 45
  • 3
    Better to clone it, so if you make changes locally you can just commit them back up to github. – iconoclast May 16 '10 at 02:23
  • 8
    Well, that assumes that git is installed or that I have permissions to install it. Cloning is preferable, but the above solution is universal. – Lucas Oman May 25 '10 at 17:48
  • using git rep for for environment setting is a great idea which is why I accepted the answer. – Yada Sep 09 '14 at 13:06
  • 2
    @LucasOman this .vimrc gives me error on opening any file *Error detected while processing /home/myname/.vimrc: line 8: E117: Unknown function: pathogen#runtime_append_all_bundles Press ENTER or type command to continue * – Patrick Oct 17 '14 at 06:49
  • @pythonlearner you must install pathogen package (depending the distro), and also you've got to change pathogen#runtime_append_all_bundles() by pathogen#infect() and the error disappear – jics Dec 16 '14 at 02:04
  • 2
    I liked your .vimrc but by no mean it can be considered minimalistic. It ha rulers, it uses pathogen and so on... I would consider @Yada answer more suitable for that. – tfcstack May 29 '15 at 06:22
  • It is an extremely insecure answer to tell somebody to just blindly run a bash oneliner that will install your latest personal `~/.vimrc`. – Jay Aug 09 '19 at 14:54
6

My config:

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=700

" Enable filetype plugins
filetype plugin on
filetype indent on

" Set to auto read when a file is changed from the outside
set autoread


"Always show current position
set ruler

" Ignore case when searching
set ignorecase

" When searching try to be smart about cases 
set smartcase

" Highlight search results
set hlsearch

" Show matching brackets when text indicator is over them
set showmatch


syntax enable


colorscheme desert
set background=dark

" Set extra options when running in GUI mode
if has("gui_running")
    set guioptions-=T
    set guioptions+=e
    set t_Co=256
    set guitablabel=%M\ %t
endif

" Set utf8 as standard encoding and en_US as the standard language
set encoding=utf8

" Use Unix as the standard file type
set ffs=unix,dos,mac

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
set noswapfile


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab

" Be smart when using tabs ;)
set smarttab

" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4

" Linebreak on 500 characters
set lbr
set tw=500

set ai "Auto indent
set si "Smart indent
set wrap "Wrap lines


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around, tabs, windows and buffers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Treat long lines as break lines (useful when moving around in them)
map j gj
map k gk



""""""""""""""""""""""""""""""
" => Status line
""""""""""""""""""""""""""""""
" Always show the status line
set laststatus=2

" Format the status line
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l

I found this:

http://amix.dk/vim/vimrc.html

just copy things that you want

Chalist
  • 3,160
  • 5
  • 39
  • 68
4

So many lines to choose from, but the ones I wouldn't be without and would highly recommend for all vimmers:

" remap jj to escape in insert mode
inoremap jj <Esc>

" swapping : and ; save a lot of unneeded shifting:
noremap ; :
noremap : ;

" The wish that grants more wishes (edit vimrc with \ev)
nnoremap <Leader>ev :tabnew<CR>:e ~/.vimrc<CR>
ErichBSchulz
  • 15,047
  • 5
  • 57
  • 61
3

This deviates a bit from the letter of the question, but is hopefully within the spirit. The very first thing I do on a new machine is set -o vi to get vi-style key bindings on the commandline.

John Hyland
  • 6,855
  • 28
  • 32
3

Here are some real good must have commands.

        " do not make vim compatible with vi.
    set nocompatible

        " number the lines.
    set number

        " show location of cursor using a horizontal line.
    set cursorline

        " keep cursor in the middle of the screen while scrolling up and down.
    set scrolloff=999

    " show auto complete menus.
    set wildmenu

    " Make wildmenu behave like bash completion. Finding commands are so easy now.
    set wildmode=list:longest

    " run the Bash script by pressing F6 without leaving VIM.
    map <f6> :w <CR>:!bash % <CR>

    " turn on syntax hightlighting.
    set syntax=on
userend
  • 1,701
  • 1
  • 13
  • 10
2

Lots of .vimrc ideas can be found here.

Chris R. Timmons
  • 2,187
  • 1
  • 13
  • 11
1

syntax enable
set background=dark for black xterms.
set autoindent when I'm going to develop.

Arkaitz Jimenez
  • 22,500
  • 11
  • 75
  • 105
1

Since I am on new machines a lot, I have put my minimalistic .vimrc on my homepage here. So I don't have to carry it around on an USB stick.

Don't know, if there's anything for you in it or not.

Rene

René Nyffenegger
  • 39,402
  • 33
  • 158
  • 293
1

My vimrc lives on my dropbox folder. But it's not minimalistic.

If I'm doing something really simple (not worth grabbing my real vimrc) I'll do the following:

:set nocompatible
:set number
:set showmatch
:map! <F3> <Esc>
alesplin
  • 1,332
  • 14
  • 23