Skip to content

Instantly share code, notes, and snippets.

@stungeye
Last active June 21, 2018 15:32
Show Gist options
  • Save stungeye/953546 to your computer and use it in GitHub Desktop.
Save stungeye/953546 to your computer and use it in GitHub Desktop.
Improving my VIM

Setting up Pathogen

mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim

Ensure that pathogen.vim ends up in ~/.vim/autoload

Colour Scheme

mkdir ~/.vim/colors cd ~/.vim/colors wget https://raw.githubusercontent.com/Lokaltog/vim-distinguished/develop/colors/distinguished.vim

Setting up NerdTree

cd ~./vim/bundle
git clone git://github.com/scrooloose/nerdtree.git

Setting up NerdCommenter

cd ~./vim/bundle
git clone git://github.com/scrooloose/nerdcommenter.git

Setting up Easy Motion

cd ~\.vim\bundle
git clone https://github.com/easymotion/vim-easymotion

Strangely, to get this working in Linux I had to edit the plugin\EasyMotion.vim file:

if exists('g:EasyMotion_loaded') || &cp

Enable Vim CLI mode and source .bashrc for dircolors

export EDITOR=/usr/bin/vim
set -o vi

if [ -f ~/.bashrc ]; then
  . ~/.bashrc
fi

##Config .vimrc

(Old see: https://gist.github.com/stungeye/2388378f12faba5f4094)

set nocompatible
autocmd!
filetype off
runtime! autoload/pathogen.vim
silent! call pathogen#infect()
silent! call pathogen#helptags()
filetype plugin indent on

scriptencoding utf-8
syntax enable

if has ('gui_running')
    if has('gui_gtk2')
        set guifont=Bitstream\ Vera\ Sans\ Mono\ 12
    else
        set guifont=Bitstream_Vera_Sans_Mono:h12
    end
    set guioptions-=T "Removes toolbar
else
    " Fix for ubuntu terminal
    " Had to also install solarized for Gnome terminal for this to work
    " http://www.webupd8.org/2011/04/solarized-must-have-color-paletter-for.html
    set t_Co=256
    " Comment the following two line if you don't need to support terminal-based vim.
    let g:solarized_termcolors=256
    let g:solarized_termtrans=1
endif

set background=dark
colorscheme solarized

set encoding=utf-8
set virtualedit=onemore "Allow for cursor beyond last char
set mouse=a     "Enable the mouse.
set nu          "Show line numbers
set showmatch   "Show matching parens/braces
set hlsearch    "Highlight search terms
set incsearch   "show search matches as you type
set ignorecase  "Case insensitive search
set smartcase   "Ignore case is search is all lower, otherwise don't.
set autoindent
set backspace=indent,eol,start
set shiftwidth=4
set expandtab
set tabstop=4
set softtabstop=4 
set visualbell
set nowrap

" Changed <leader> from \ to ,
let mapleader=','

"Yank until end of line
nnoremap Y y$  
"$ moves after the last character
nnoremap $ $l
"Change Working Directory to that of the current file
nmap <silent> <leader>cd :lcd %:h<CR>
"Visual mode shifting (does not exit visual mode)
vnoremap < <gv
vnoremap > >gv
"clear highlighted search
nmap <silent> <leader>/ :nohlsearch<CR>
"Yank and Past to OS clipboard with ,y and ,p
nmap <leader>y "+yy
nmap <leader>p "+p
" Edit the vimrc file
nmap <silent> <leader>ev :e $MYVIMRC<CR>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
" Force me to use hjkl
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>

"NerdTree
map <C-e> :NERDTreeToggle<CR>
nmap <leader>nt :NERDTreeFind<CR>

" Easy window navigation
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l

autocmd BufRead,BufNewFile *.haml setfiletype haml
autocmd BufRead,BufNewFile *.sass setfiletype sass
autocmd BufRead,BufNewFile *.php set ft=php.html "Allow HTML snippets from within PHP
autocmd FileType ruby,haml,sass setlocal tabstop=2 softtabstop=2 shiftwidth=2

HAML and SASS Support

http://github.com/tpope/vim-haml

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