Skip to content

Instantly share code, notes, and snippets.

@simonista
Last active December 22, 2024 17:35
Show Gist options
  • Save simonista/8703722 to your computer and use it in GitHub Desktop.
Save simonista/8703722 to your computer and use it in GitHub Desktop.
A basic .vimrc file that will serve as a good template on which to build.
" Don't try to be vi compatible
set nocompatible
" Helps force plugins to load correctly when it is turned back on below
filetype off
" TODO: Load plugins here (pathogen or vundle)
" Turn on syntax highlighting
syntax on
" For plugins to load correctly
filetype plugin indent on
" TODO: Pick a leader key
" let mapleader = ","
" Security
set modelines=0
" Show line numbers
set number
" Show file stats
set ruler
" Blink cursor on error instead of beeping (grr)
set visualbell
" Encoding
set encoding=utf-8
" Whitespace
set wrap
set textwidth=79
set formatoptions=tcqrn1
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set noshiftround
" Cursor motion
set scrolloff=3
set backspace=indent,eol,start
set matchpairs+=<:> " use % to jump between pairs
runtime! macros/matchit.vim
" Move up/down editor lines
nnoremap j gj
nnoremap k gk
" Allow hidden buffers
set hidden
" Rendering
set ttyfast
" Status bar
set laststatus=2
" Last line
set showmode
set showcmd
" Searching
nnoremap / /\v
vnoremap / /\v
set hlsearch
set incsearch
set ignorecase
set smartcase
set showmatch
map <leader><space> :let @/=''<cr> " clear search
" Remap help key.
inoremap <F1> <ESC>:set invfullscreen<CR>a
nnoremap <F1> :set invfullscreen<CR>
vnoremap <F1> :set invfullscreen<CR>
" Textmate holdouts
" Formatting
map <leader>q gqip
" Visualize tabs and newlines
set listchars=tab:▸\ ,eol
" Uncomment this to enable by default:
" set list " To enable by default
" Or use your leader key + l to toggle on/off
map <leader>l :set list!<CR> " Toggle tabs and EOL
" Color scheme (terminal)
set t_Co=256
set background=dark
let g:solarized_termcolors=256
let g:solarized_termtrans=1
" put https://raw.github.com/altercation/vim-colors-solarized/master/colors/solarized.vim
" in ~/.vim/colors/ and uncomment:
" colorscheme solarized
@0x5448
Copy link

0x5448 commented Oct 5, 2018

There is this white flash on the screen if the cursor can't go further, what part of the code does it, I don't want that.

@raudraroop Line 28: set visualbell does this

@Olimejj
Copy link

Olimejj commented Mar 21, 2019

Thanks, I finally figured out the vimrc file :) This template is what finally did it for me.

@Blithe-Chiang
Copy link

Thanks

Copy link

ghost commented Jun 8, 2019

Thank you! It looks good and easy to amend and update :)

@xxzelatron
Copy link

if I use :set paste while pasting some lines, it is also modifying existing lines in file.how to avoid this?
If I paste without paste mode i.e. in insert mode then it is adding indentation for every line

@almokhtarbr
Copy link

thanks

@mfrlinux
Copy link

Thank you! Very good!

@marquelamar
Copy link

Thanks.Again.

@banditelol
Copy link

banditelol commented Nov 5, 2019

Thanks You :)
btw can anyone tell me what the "rn1" part of formatoptions does?

EDIT
nvm, just found out the options exist in fo-table

@MoatazAbdAlmageed
Copy link

Thanks, I will try

@jerry-peng
Copy link

Thnx m8

@haphamdev
Copy link

Thank you a lot for this nice file.

@LowProKill
Copy link

Looks good mate. Thanks

@davivcgarcia
Copy link

Perfect! ;-)

Copy link

ghost commented Apr 26, 2020

super nice, thanks.
On Firefox C-a selects all text (useful to copy on the raw file for the color scheme)

@hugowan
Copy link

hugowan commented May 13, 2020

nice work

@liam102
Copy link

liam102 commented May 29, 2020

Could someone please explain why does the keymap adds \v before search terms?

@oantolin
Copy link

Could someone please explain why does the keymap adds \v before search terms?

It enables "very magic" regex syntax, which roughly means that characters that have a special meaning in regexes need not be escaped to have that special meaning. For example, normally to group a subregex you need to escape the parenthesis with a backslash: \(this is grouped\). With very magic syntax unescaped parenthesis have that function. Similarly alternation is usually \|, and with very magic syntax it is just |. But don't take my word for it, ask Vim: :help \v.

@damog
Copy link

damog commented Nov 9, 2020

Thanks a lot 👍

@cesarGTZtapia
Copy link

Thanks!

Copy link

ghost commented Feb 5, 2021

thanks.. really helpful 👍

@sriashi
Copy link

sriashi commented Mar 7, 2021

Thank you!

@SubhamShaww
Copy link

This is great and super helpful. thanks

@HsuChiChen
Copy link

thx

@o-az
Copy link

o-az commented Sep 17, 2021

Thank you sir

@AlexWilkinsonnn
Copy link

AlexWilkinsonnn commented Apr 6, 2022

Thanks! I had to change map <leader><space> :let @/=''<cr> " clear search -> map <leader><space> :let @/=''<cr> to prevent the visual bell going off. Also had to do the same to L91.

@jgalva
Copy link

jgalva commented Nov 8, 2022

Good stuff, thank you! :-)

@julianlg92
Copy link

Thank you!!!!

@dazza26
Copy link

dazza26 commented Oct 20, 2023

I installed and uncommented colorscheme solarized but imo it looks much better without that coloscheme enabled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment