Skip to content

Instantly share code, notes, and snippets.

Forked from napcs/.vimrc
Last active Dec 31, 2021
What would you like to do?
Set up Vim on Mac or Linux. curl | sh
"this is the cconfiguration file for linux and mac systems
"symlink this to your home folder as .vimrc
call pathogen#runtime_prepend_subdirectories(expand('~/.vim/bundles'))
call pathogen#helptags()
"call pathogen#runtime_append_all_bundles()
source ~/.vimrc_main
"These options and commands enable some very useful features in Vim, that
" no user should have to live without.
" Windows Compatible {
" On Windows, also use '.vim' instead of 'vimfiles'; this makes synchronization
" across (heterogeneous) systems easier.
"if has('win32') || has('win64')
"set runtimepath=$VIMRUNTIME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after
" }
" Set 'nocompatible' to ward off unexpected things that your distro might
" have made, as well as sanely reset options when re-sourcing .vimrc
set nocompatible
" Attempt to determine the type of a file based on its name and possibly its
" contents. Use this to allow intelligent auto-indenting for each filetype,
" and for plugins that are filetype specific.
filetype indent plugin on
filetype plugin on
"helptags ~/.vim/doc
" Enable syntax highlighting
set t_Co=256
colorscheme NVL_twilight
syntax on
" Swap file settings
set directory^=$HOME/.vim_swap// "put all swap files together in one place
" Must have options
" These are highly recommended options.
set cursorline
" One of the most important options to activate. Allows you to switch from an
" unsaved buffer without saving it first. Also allows you to keep an undo
" history for multiple files. Vim will complain if you try to quit without
" saving, and swap files will keep you safe if your computer crashes.
set hidden
" Better command-line completion
set wildmenu
" Show partial commands in the last line of the screen
set showcmd
" Highlight searches (use <C-L> to temporarily turn off highlighting; see the
" mapping of <C-L> below)
set hlsearch
" Modelines have historically been a source of security vulnerabilities. As
" such, it may be a good idea to disable them and use the securemodelines
set nomodeline
" Usability options {{{1
" These are options that users frequently set in their .vimrc. Some of them
" change Vim's behaviour in ways which deviate from the true Vi way, but
" which are considered to add usability. Which, if any, of these options to
" use is very much a personal preference, but they are harmless.
" Use case insensitive search, except when using capital letters
set ignorecase
set smartcase
" Allow backspacing over autoindent, line breaks and start of insert action
set backspace=indent,eol,start
" When opening a new line and no filetype-specific indenting is enabled, keep
" the same indent as the line you're currently on. Useful for READMEs, etc.
set autoindent
" Stop certain movements from always going to the first character of a line.
" While this behaviour deviates from that of Vi, it does what most users
" coming from other editors would expect.
set nostartofline
" Display the cursor position on the last line of the screen or in the status
" line of a window
set ruler
" Always display the status line, even if only one window is displayed
set laststatus=2
" Instead of failing a command because of unsaved changes, instead raise a
" dialogue asking if you wish to save changed files.
set confirm
" Use visual bell instead of beeping when doing something wrong
set visualbell
" And reset the terminal code for the visual bell. If visualbell is set, and
" this line is also included, vim will neither flash nor beep. If visualbell
" is unset, this does nothing.
set t_vb=
" Enable use of the mouse for all modes
set mouse=a
" Set the command window height to 2 lines, to avoid many cases of having to
" 'press <Enter> to continue'
set cmdheight=2
" Display line numbers on the left
set number
" Quickly time out on keycodes, but never time out on mappings
set notimeout ttimeout ttimeoutlen=200
" Indentation options
" Indentation settings according to personal preference.
" Indentation settings for using 2 spaces instead of tabs.
" Do not change 'tabstop' from its default value of 8 with this setup.
set shiftwidth=2
set softtabstop=2
set expandtab
set nowrap
" Indentation settings for using hard tabs for indent. Display tabs as
" two characters wide.
set shiftwidth=2
set tabstop=2
" Mappings {{{1
" Useful mappings
let mapleader = ";"
" Map Y to act like D and C, i.e. to yank until EOL, rather than act as yy,
" which is the default
map Y y$
" Map <C-L> (redraw screen) to also turn off search highlighting until the
" next search
nnoremap <C-L> :nohl<CR><C-L>
" NERDTree and buffer shorcuts
nmap <F3> :bp<CR>
nmap <F4> :bn<CR>
nmap <F5> :NERDTreeToggle<CR>
" PuTTY friendly versions of the above
nmap <C-\> :NERDTreeToggle<CR>
"nmap <C-[> :bp<CR>
"nmap <C-]> :bn<CR>
" Tabs
"nmap <Leader>tt :tabnew<CR>
"nmap <F11> :tabp<CR>
"nmap <F12> :tabn<CR>
"nmap <Leader>tw :bd<CR>
"nmap <leader>tb :tabfirst<CR>
"nmap <leader>tb :tablast<CR>
" Rails.vim shortcuts
nmap <Leader><C-R>m :Rmodel<CR>
nmap <Leader><C-R>v :Rview<CR>
nmap <Leader><C-R>c :Rcontroller<CR>
nmap <Leader><C-R>a :A<CR>
nmap <Leader><C-R>r :R<CR>
" ack.vim shortcuts
nmap <Leader><C-f> :Ack "
"nmap <Leader><C-t> :AckG
" ctrlp.vim shortcuts
nmap <Leader><C-t> :CtrlP<CR>
" Show syntax highlighting groups for word under cursor
nmap <C-S-P> :call <SID>SynStack()<CR>
function! <SID>SynStack()
if !exists("*synstack")
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
if exists(":Tabularize")
nmap <Leader>a= :Tabularize /=<CR>
vmap <Leader>a= :Tabularize /=<CR>
nmap <Leader>a: :Tabularize /:\zs<CR>
vmap <Leader>a: :Tabularize /:\zs<CR>
" Unbinding tslime and turbux defaults
"vunmap <C-c><C-c>
"nunmap <C-c><C-c>
"nunmap <C-c>v
"vunmap <Leader>t
"nunmap <Leader>t
"nunmap <Leader>T
" tslime and turbux commands
"vmap <Leader>t <Plug>SendSelectionToTmux
"nmap <Leader>t <Plug>NormalModeSendToTmux
"nmap <Leader>T <Plug>SetTmuxVars
vmap <Leader>m <Plug>SendSelectionToTmux
nmap <Leader>m <Plug>NormalModeSendToTmux
nmap <Leader>M <Plug>SetTmuxVars
nmap <Leader>r <Plug>SendTestToTmux
nmap <Leader>R <Plug>SendFocusedTestToTmux
autocmd BufNewFile,BufReadPost *.*.coffee set filetype=coffee
autocmd BufNewFile,BufReadPost Guardfile set filetype=ruby
autocmd BufNewFile,BufReadPost Gemfile set filetype=ruby
autocmd BufNewFile,BufReadPost Vagrantfile set filetype=ruby
autocmd BufNewFile,BufReadPost *.ru set filetype=ruby
# Script to install vim configuration files
# Tested with OSX and Ubuntu.
# Will need modifications for windows if home dir is not set
# Easiest way to use this is to run this from your home folder in Terminal:
# curl | sh
# You'll need Vim, Git and Curl installed to use this script with bash.
mkdir -p .vim/autoload
mkdir -p .vim/backup
mkdir -p .vim/bundles
cd .vim/bundles
git clone git://
git clone git://
git clone git://
git clone git://
git clone git://
git clone git://
git clone
git clone git://
git clone git://
git clone git://
git clone git://
git clone git://
git clone git://
git clone git://
git clone git://
git clone
cd ../..
curl -L > .vim/autoload/pathogen.vim
curl -L > .vimrc
curl -L > .vimrc_main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment