Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 152 lines (121 sloc) 4.69 kb
63af46f Martin Grenfell add the useful parts of my vimrc
authored
1 "Use Vim settings, rather then Vi settings (much better!).
2 "This must be first, because it changes other options as a side effect.
3 set nocompatible
4
5 "allow backspacing over everything in insert mode
6 set backspace=indent,eol,start
7
8 "store lots of :cmdline history
9 set history=1000
10
11 set showcmd "show incomplete cmds down the bottom
12 set showmode "show current mode down the bottom
13
14 set incsearch "find the next match as we type the search
15 set hlsearch "hilight searches by default
16
17 set nowrap "dont wrap lines
18 set linebreak "wrap lines at convenient points
19
20 "statusline setup
21 set statusline=%t "tail of the filename
22 set statusline+=[%{strlen(&fenc)?&fenc:'none'}, "file encoding
23 set statusline+=%{&ff}] "file format
24 set statusline+=%h "help file flag
25 set statusline+=%m "modified flag
26 set statusline+=%r "read only flag
27 set statusline+=%y "filetype
28 set statusline+=%= "left/right separator
29 set statusline+=%c, "cursor column
30 set statusline+=%l/%L "cursor line/total lines
31 set statusline+=\ %P "percent through file
32 set laststatus=2
33
34 "indent settings
35 set shiftwidth=4
36 set softtabstop=4
37 set expandtab
38 set autoindent
39
40 "folding settings
41 set foldmethod=indent "fold based on indent
42 set foldnestmax=3 "deepest fold is 3 levels
43 set nofoldenable "dont fold by default
44
45 set wildmode=list:longest "make cmdline tab completion similar to bash
46 set wildmenu "enable ctrl-n and ctrl-p to scroll thru matches
47
48 "display tabs and trailing spaces
49 set list
50 set listchars=tab:▷⋅,trail:⋅,nbsp:⋅
51
52 set formatoptions-=o "dont continue comments when pushing o/O
53
54 "vertical/horizontal scroll off settings
55 set scrolloff=3
56 set sidescrolloff=7
57 set sidescroll=1
58
59 "load ftplugins and indent files
60 filetype plugin on
61 filetype indent on
62
63 "turn on syntax highlighting
64 syntax on
65
66 "some stuff to get the mouse going in term
67 set mouse=a
68 set ttymouse=xterm2
69
70 "tell the term has 256 colors
71 set t_Co=256
72
73 "hide buffers when not displayed
74 set hidden
75
76 "make <c-l> clear the highlight as well as redraw
77 nnoremap <C-L> :nohls<CR><C-L>
78 inoremap <C-L> <C-O>:nohls<CR>
79
80 "map Q to something useful
81 noremap Q gq
82
83 "make Y consistent with C and D
84 nnoremap Y y$
85
86 "visual search mappings
87 function! s:VSetSearch()
88 let temp = @@
89 norm! gvy
90 let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')
91 let @@ = temp
92 endfunction
93 vnoremap * :<C-u>call <SID>VSetSearch()<CR>//<CR>
94 vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR>
95
96
f170376 Martin Grenfell add some more to the vimrc
authored
97 "jump to last cursor position when opening a file
98 "dont do it when writing a commit log entry
63af46f Martin Grenfell add the useful parts of my vimrc
authored
99 autocmd BufReadPost * call SetCursorPosition()
100 function! SetCursorPosition()
101 if &filetype !~ 'commit\c'
102 if line("'\"") > 0 && line("'\"") <= line("$")
103 exe "normal g`\""
104 endif
105 end
106 endfunction
107
f170376 Martin Grenfell add some more to the vimrc
authored
108 "define :Lorem command to dump in a paragraph of lorem ipsum
109 command! -nargs=0 Lorem :normal iLorem ipsum dolor sit amet, consectetur
110 \ adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore
111 \ magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
112 \ ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
113 \ irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
114 \ fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
115 \ proident, sunt in culpa qui officia deserunt mollit anim id est
116 \ laborum
117
118 "define :HighlightExcessColumns command to highlight the offending parts of
119 "lines that are "too long". where "too long" is defined by &textwidth or an
120 "arg passed to the command
121 command! -nargs=? HighlightExcessColumns call s:HighlightExcessColumns('<args>')
122 function! s:HighlightExcessColumns(width)
123 let targetWidth = a:width != '' ? a:width : &textwidth
124 if targetWidth > 0
125 exec 'match Todo /\%>' . (targetWidth+1) . 'v/'
126 else
127 echomsg "HighlightExcessColumns: set a &textwidth, or pass one in"
128 endif
129 endfunction
63af46f Martin Grenfell add the useful parts of my vimrc
authored
130
131 "simple template system
132 command! -complete=customlist,<SID>AvailableTemplates -n=1
133 \ Template :call <SID>InsertTemplate('<args>')
134
135 function! <SID>InsertTemplate(name)
136 "read in the template
137 execute 'read ~/.vim/templates/' . &filetype . '/' . a:name
138
139 "if the cursor was previously on a blank line, delete it
140 if getline(line(".")-1) =~ '^\s*$'
141 exec line(".")-1 . 'd'
142 endif
143 endfunction
144
145 function! <SID>AvailableTemplates(lead, cmdline, cursorpos)
146 let templateDir = expand('~/.vim/templates/' . &filetype . '/')
147 let files = split(globpath(templateDir, a:lead . '*'), '\n')
148
149 "chop off the templateDir from each file
150 return map(files, 'strpart(v:val,strlen(templateDir))')
151 endfunction
Something went wrong with that request. Please try again.