Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit cece3b9de9370d0d2b8871dc2648401e381ef8b1 @txus txus committed Mar 20, 2012
Showing with 346 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +122 −0 Readme.md
  3. +223 −0 vimrc
@@ -0,0 +1 @@
+bundle
122 Readme.md
@@ -0,0 +1,122 @@
+# vimfiles
+
+These are the new Codegram vimfiles!
+
+## Installing
+
+Clone this repo:
+
+ $ git clone https://github.com/codegram/vimfiles.git ~/.vim
+ $ rm ~/.vimrc && ln -s ~/.vim/vimrc ~/.vimrc
+
+Install [Vundle](https://github.com/gmarik/vundle):
+
+ $ git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
+
+Set up your `~/vimrc.local` with your custom plugins, themes, for example:
+
+ " Color theme
+ Bundle 'sjl/badwolf'
+ colorscheme badwolf
+
+Open up Vim, and issue this command:
+
+ :BundleInstall
+
+TA-DA! Everything's done!
+
+## Custom mappings
+
+* The leader key is `,` (comma).
+
+### Moving
+* Arrow keys are disabled.
+* `jk` is mapped to `<ESC>`, so you don't have to reach out to `<ESC>`.
+
+### Search
+* `,<Space>` clears the search.
+
+### Buffers
+* `,w` maps to `:w!`: it saves the current buffer.
+* `,q` maps to `:wqa!`: it saves all buffers and quits.
+* `<tab>` / `<S-tab>` rotates among open buffers.
+* `<leader>d` closes the current buffer.
+* `<leader>D` closes ALL the buffers.
+
+### Splits
+* `,v` opens a new vertical split.
+* `<C-h>` switches to the left split.
+* `<C-j>` switches to the split below.
+* `<C-k>` switches to the split above.
+* `<C-l>` switches to the right split.
+
+### Other
+
+* `<F2>` to toggle Paste mode (to paste stuff from the system clipboard).
+* `,gb` in Visual mode to perform a `git blame` on the selected lines.
+* `,r` runs the current buffer in the current RVM Ruby, including `lib` and
+ `test`.
+* `<tab>` in Insert mode either indents or autocompletes, depending on the
+ context.
+
+## Plug-ins
+
+### [ack](https://github.com/mileszs/ack.vim)
+
+Use Ack to search through your code.
+
+* `,a` performs an Ack search.
+* `<C-n>` / `<C-p>`: Rotate among results.
+
+### [vim-autoclose](https://github.com/Townk/vim-autoclose)
+
+Auto-closes, parens, curly braces, everything.
+
+### [ctags](https://github.com/vim-scripts/ctags)
+
+First, `brew install ctags` and run the `tags` command (found in our
+[dotfiles](http://github.com/codegram/dotfiles)) on your working directory to
+generate the tag list.
+
+* `<C-]>` to go to the definition of the word under the cursor (constant,
+ method, whatever
+* `<C-p>` to come back.
+* `<F7>` / `<F9>` to rotate among multiple definitions of the same tag.
+
+### [ctrlp](https://github.com/kien/ctrlp)
+
+Fuzzy-find and open files at top speed!
+
+* `,o` To open the Ctrl-p window. Start typing a file name and press Enter.
+ Plus, if you add a colon and an action it will be performed afterwards
+ (`:45` will open the file and go to the line 45).
+
+### [vim-endwise](https://github.com/tpope/vim-endwise)
+
+Puts `end` after a method definition, if clause, etc. (Ruby)
+
+### [vim-fugitive](https://github.com/tpope/vim-powerline)
+
+Use Git from Vim.
+
+* `,gs`: Git status.
+* `,gc`: Git commit.
+
+### [vim-powerline](https://github.com/Lokaltog/vim-powerline)
+
+A fancy status line.
+
+### [vim-rails](https://github.com/tpope/vim-rails)
+
+Integration with Rails.
+
+### [vim-surround](https://github.com/tpope/vim-surround)
+
+* `cs"'` changes surround from `"` to `'`.
+* `ysiw"` surrounds inside the word with `"`.
+
+### [vim-tcomment](https://github.com/jmartindf/vim-tcomment)
+
+Comments any kind of code.
+
+* `,co`: In visual mode, comments the selected block.
223 vimrc
@@ -0,0 +1,223 @@
+" vimrc
+" Author: Codegram
+" Source: https://github.com/codegram/vimfiles
+
+set nocompatible
+filetype off
+
+set rtp+=~/.vim/bundle/vundle/
+call vundle#rc()
+
+" ----------
+" Leader key
+" ----------
+let mapleader = ","
+let maplocalleader = "."
+
+" -------
+" BUNDLES
+" -------
+Bundle 'gmarik/vundle'
+
+Bundle 'mileszs/ack.vim'
+Bundle 'tpope/vim-surround'
+Bundle 'tpope/vim-endwise'
+Bundle 'Townk/vim-autoclose'
+Bundle 'jmartindf/vim-tcomment'
+Bundle 'Lokaltog/vim-powerline'
+Bundle 'kien/ctrlp.vim'
+
+Bundle 'tpope/vim-rails'
+Bundle 'tpope/vim-fugitive'
+Bundle 'tpope/vim-cucumber'
+Bundle 'bbommarito/vim-slim'
+
+Bundle 'vim-scripts/ctags.vim'
+
+" Default color theme
+Bundle 'sjl/badwolf'
+colorscheme badwolf
+
+" ------------
+" VIM SETTINGS
+" ------------
+filetype plugin indent on
+" colorscheme badwolf
+syntax on
+
+set autoindent
+set autoread
+set backspace=indent,eol,start
+set binary
+set cinoptions=:0,(s,u0,U1,g0,t0
+set completeopt=menuone,preview
+set expandtab
+set foldcolumn=0
+set foldlevel=9
+set foldmethod=indent
+set hidden
+set history=1000
+set hlsearch
+set ignorecase
+set incsearch
+set gdefault
+set laststatus=2
+set list
+set listchars=trail:·
+set modelines=5
+set nobackup
+set noeol
+set nofoldenable
+set noswapfile
+set number
+set numberwidth=4
+set ruler
+set shell=/bin/bash
+set shiftwidth=2
+set showcmd
+set showmatch
+set smartcase
+set tabstop=2
+set softtabstop=2
+set title
+set encoding=utf-8
+set scrolloff=3
+set autoindent
+set smartindent
+set showmode
+set wildmenu
+set wildmode=list:longest
+set visualbell
+set cursorline
+set ttyfast
+set textwidth=78
+set wildignore=.svn,CVS,.git,.hg,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif
+set grepprg=ack
+set textwidth=79
+set formatoptions=n
+set colorcolumn=79
+set tw=79
+set t_Co=256
+
+if has("gui_running")
+ set guioptions-=T " no toolbar set guioptions-=m " no menus
+ set guioptions-=r " no scrollbar on the right
+ set guioptions-=R " no scrollbar on the right
+ set guioptions-=l " no scrollbar on the left
+ set guioptions-=b " no scrollbar on the bottom
+ set guioptions=aiA
+ set mouse=v
+endif
+set guifont=Monaco:h12
+
+" --------
+" MAPPINGS
+" --------
+
+nnoremap <up> <nop>
+nnoremap <down> <nop>
+nnoremap <left> <nop>
+nnoremap <right> <nop>
+inoremap <up> <nop>
+inoremap <down> <nop>
+inoremap <left> <nop>
+inoremap <right> <nop>
+
+nnoremap j gj
+nnoremap k gk
+
+imap jk <ESC>
+nnoremap ; :
+
+" Search
+nmap <Space> /
+nnoremap / /\v
+vnoremap / /\v
+
+" Clear search
+nnoremap <leader><space> :noh<cr>
+
+" Saving and buffer stuff
+nmap <leader>q :wqa!<CR>
+nmap <leader>w :w!<CR>
+
+" Switch between / delete buffers
+noremap <tab> :bn<CR>
+noremap <S-tab> :bp<CR>
+nmap <leader>d :bd<CR>
+nmap <leader>D :bufdo bd<CR>
+nmap <silent> <leader>b :FufBuffer<CR>
+
+" Splits
+nnoremap <leader>v :vs<CR>
+nnoremap <C-h> <C-w>h
+nnoremap <C-j> <C-w>j
+nnoremap <C-k> <C-w>k
+nnoremap <C-l> <C-w>l
+
+" Paste mode
+set pastetoggle=<F2>
+
+" Git blame
+vmap <Leader>gb :<C-U>!git blame <C-R>=expand("%:p") <CR> \| sed -n <C-R>=line("'<") <CR>,<C-R>=line("'>") <CR>p<CR>
@fesplugas

fesplugas Apr 13, 2012

I also used this but now I use fugitive.

+
+" Execute current buffer as ruby
+map <leader>r :!ruby -I"lib:test" %<cr>
+
+" Tab autocompletes / indents depending on the context
+function! InsertTabWrapper()
+ let col = col('.') - 1
+ if !col || getline('.')[col - 1] !~ '\k'
+ return "\<tab>"
+ else
+ return "\<c-p>"
+ endif
+endfunction
+inoremap <tab> <c-r>=InsertTabWrapper()<cr>
+inoremap <s-tab> <c-n>
+
+" ----------------
+" PLUG-IN SETTINGS
+" ----------------
+
+" Powerline (fancy status bar)
+let g:Powerline_symbols = 'fancy'
+let g:Powerline_cache_enabled = 1
+
+" Ack (Regex-based search)
+nmap <leader>a :Ack
+" Rotating among results
+map <C-n> :cn<CR>
+map <C-p> :cp<CR>
+
+" Fugitive (Git)
+nmap <leader>gs :Gstatus
+nmap <leader>gc :Gcommit
+
+" TComment
+map <Leader>co :TComment<CR>
@fesplugas

fesplugas Apr 13, 2012

Why mapping when you can use gcc on a visual block or gc on current line?

+
+" AutoClose
+let g:AutoClosePairs = {'(': ')', '{': '}', '[': ']', '"': '"', "'": "'", '#{': '}'}
+let g:AutoCloseProtectedRegions = ["Character"]
+
+" Ctags
+" You can use Ctrl-] to jump to a function.... Ctrl-p will jump back
+map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR>
+map <C-p> :pop<CR>
@fesplugas

fesplugas Apr 13, 2012

ctrl-t will jump back.

+
+" You can cycle through multiple function definitions using
+" these mappings. This maps to my windows key + left/right arrows
+map <F7> :tnext<CR>
+map <F9> :tprev<CR>
+
+" Ctrl-p
+let g:ctrlp_map = '<leader>o'
@fesplugas

fesplugas Apr 13, 2012

Why renaming this mapping when it's already set for you? I've the following mappings:

map <C-g> :CtrlP<SPACE>
map <C-e> :CtrlPMRU<CR>
map <C-b> :CtrlPBuffer<CR>
+
+" --------------------
+" CUSTOM CONFIGURATION
+" --------------------
+let my_home = expand("$HOME/")
+if filereadable(my_home . '.vimrc.local')
+ source ~/.vimrc.local
+endif

0 comments on commit cece3b9

Please sign in to comment.