Skip to content

Instantly share code, notes, and snippets.

@emmajane
Created May 19, 2015 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emmajane/f63cf4849cf9557d80bf to your computer and use it in GitHub Desktop.
Save emmajane/f63cf4849cf9557d80bf to your computer and use it in GitHub Desktop.
" Personal settings
set guifont=Anonymous\ Pro:h13
set hidden " Let me switch buffers without an error message, hides the buffer and moves on.
set number
" Settings for line wrapping when editing prose
" probably not useful for writing code; you might want to disable this when coding
" http://contsys.tumblr.com/post/491802835/vim-soft-word-wrap
" http://vim.wikia.com/wiki/Word_wrap_without_line_breaks
set wrap " word wrap visually, not by changing the text in the buffer
set nolist " list disables the linebreak
set lbr " wrap based on word, not character
set formatoptions+=l " Do not reformat when typing on existing lines; use my defaults for new lines
" set formatoptions=1 " break on the previous word, do not include hard line breaks
set linebreak " set the line breaks visually
set textwidth=0 " Unset the 80 character break width, so it's all about window width.
set columns=80 " soft wrap at 80 columns, but don't force a line break
" set showbreak=\ \ " left wrap indent
set wrapmargin=2 " right wrap indent
set breakat=\ |@-+;:,./?^I " where to set the break
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
set foldcolumn=7
" end of prose configuration for line wrapping
"
" to force line wrapping at a specific width, enable the following:
" set tw=79
" set formatoptions+=t "do not exceed 79 characters
" to re-wrap a paragraph to your desired width with hard line breaks, use: gq
" to re-wrap a paragraph with soft line breaks, use:
" :set wrap linebreak nolist
"
"
" Activate vimroom for distraction-free writing
" http://projects.mikewest.org/vimroom/
let mapleader=","
nnoremap <silent> <Leader>mz <Plug>VimroomToggle
"
" http://alols.github.io/2012/11/07/writing-prose-with-vim/
" command! Prose inoremap <buffer> . .<C-G>u|
"\ inoremap <buffer> ! !<C-G>u|
"\ inoremap <buffer> ? ?<C-G>u|
"\ setlocal spell spelllang=sv,en
"\ nolist nowrap tw=74 fo=t1 nonu|
"\ augroup PROSE|
"\ autocmd InsertEnter <buffer> set fo+=a|
"\ autocmd InsertLeave <buffer> set fo-=a|
"\ augroup END
"command! Code silent! iunmap <buffer> .|
"\ silent! iunmap <buffer> !|
"\ silent! iunmap <buffer> ?|
"\ setlocal nospell list nowrap
"\ tw=74 fo=cqr1 showbreak=… nu|
"\ silent! autocmd! PROSE * <buffer>
" For navigating splits, shortening the CTRL-w hjkl to just CTRL-j etc.
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" For mac users (using the 'apple' key) to go directly to # tab
map <D-S-]> gt
map <D-S-[> gT
map <D-1> 1gt
map <D-2> 2gt
map <D-3> 3gt
map <D-4> 4gt
map <D-5> 5gt
map <D-6> 6gt
map <D-7> 7gt
map <D-8> 8gt
map <D-9> 9gt
map <D-0> :tablast<CR>
" The following function strips trailing whitespaces from a file.
function! <SID>StripTrailingWhitespaces()
" Preparation - save last search, and cursor position:
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up - restore previous search history, and cursor position:
let @/=_s
call cursor(l, c)
endfunction
" This command applies the previous function to any Drupal file on :w.
autocmd BufWritePre *.module,*.install,*.test,*.inc,*.profile,*.view :call <SID>StripTrailingWhitespaces()
" This allows us to use the same function to strip out whitespace anywhere,
" using the f5 key. Thanks Vim Scripts!
nnoremap <silent> <F5> :call <SID>StripTrailingWhitespaces()<CR>
" Drupal code formatting standards.
set expandtab " Expand tabs to spaces.
set tabstop=2 " Use 2 spaces, say, rather than 4.
set shiftwidth=2 " This is the amount of indentation.
set softtabstop=2 " This helps make sure that when you backspace in insert mode, it backspaces the entire tab.
set autoindent
set smartindent
" automatically load plugins put into the ~/.vim/bundle directory with pathogen
execute pathogen#infect()
" word count
map <D-g> g<C-g>
" Preferences for folding
" 0 = all sections folded
set foldlevelstart=0
let g:markdown_fold_style = 'nested'
" Space to toggle folds.
nnoremap <Space> za
vnoremap <Space> za
" "Refocus" folds
nnoremap ,z zMzvzz
" Make zO recursively open whatever top level fold we're in, no matter where the
" cursor happens to be.
nnoremap zO zCzO
" Turn on syntax highlighting.
syntax on
set nocompatible
if has("autocmd")
filetype plugin indent on
endif
" Drupal *.module and *.install files should be code highlighted like php.
autocmd BufRead,BufNewFile *.module,*.install,*.test,*.inc,*.profile,*.view set filetype=php
" Other filetypes.
autocmd BufRead,BufNewFile *.md set filetype=markdown
autocmd BufRead,BufNewFile *.dump set filetype=sql
" Source the vimrc file after saving it
autocmd bufwritepost .vimrc.after source ~/.vimrc.after
" use solarized colours
set background=dark
let g:solarized_termcolors=256
colorscheme solarized
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment