Moved file-specific stuff do functions
This commit is contained in:
parent
f542d8987f
commit
cba78ca0eb
1 changed files with 35 additions and 18 deletions
53
vimrc
53
vimrc
|
@ -87,8 +87,12 @@ noremap <leader>d "_d
|
||||||
noremap x "_x
|
noremap x "_x
|
||||||
noremap <leader>x x
|
noremap <leader>x x
|
||||||
|
|
||||||
|
" === GENERAL COMMANDS ===
|
||||||
|
command! L lopen | set number | set norelativenumber
|
||||||
|
|
||||||
" === GENERAL KEY MAPPINGS ===
|
" === GENERAL KEY MAPPINGS ===
|
||||||
let mapleader = "\\"
|
let mapleader = "\\"
|
||||||
|
nnoremap <S-l> :L<cr>
|
||||||
noremap <space> :
|
noremap <space> :
|
||||||
noremap <C-space> @:
|
noremap <C-space> @:
|
||||||
noremap Q @q
|
noremap Q @q
|
||||||
|
@ -159,7 +163,7 @@ digraph OE 214
|
||||||
digraph ss 223
|
digraph ss 223
|
||||||
|
|
||||||
" === GENERAL UTILITIES ===
|
" === GENERAL UTILITIES ===
|
||||||
function! Matchinglines(pattern)
|
function! MatchingLines(pattern)
|
||||||
let list = []
|
let list = []
|
||||||
let pattern = a:pattern
|
let pattern = a:pattern
|
||||||
exec "g/".pattern."/ call add(list, expand('%').'('.line('.').') : '.matchstr(getline('.'), '".pattern."'))"
|
exec "g/".pattern."/ call add(list, expand('%').'('.line('.').') : '.matchstr(getline('.'), '".pattern."'))"
|
||||||
|
@ -284,9 +288,16 @@ endif
|
||||||
" === FILETYPE SPECIFIC STUFF ===
|
" === FILETYPE SPECIFIC STUFF ===
|
||||||
|
|
||||||
" Vimscript Stuff
|
" Vimscript Stuff
|
||||||
au BufNewFile,BufRead *.vim,*vimrc :nnoremap <buffer> <F5> :so %<CR>
|
au BufNewFile,BufRead *.vim,*vimrc :call <sid>init_vim_file()
|
||||||
au BufNewFile,BufRead *.vim,*vimrc :nnoremap <leader>c A<space>"<space>
|
|
||||||
au BufNewFile,BufRead *.vim,*vimrc :nnoremap <leader>if ofunction! <C-o>m'()<enter>endfunction<C-o>`'<C-o>l
|
function! s:init_vim_file()
|
||||||
|
nnoremap <buffer> <F5> :so %<CR>
|
||||||
|
nnoremap <leader>c A<space>"<space>
|
||||||
|
nnoremap <leader>if ofunction! <C-o>m'()<enter>endfunction<C-o>`'<C-o>l
|
||||||
|
|
||||||
|
command! -buffer Functions lex MatchingLines("^\\s*fun\\(ction\\)\\?\\>!.*$")
|
||||||
|
command! -buffer Commands lex MatchingLines("^\\s*com\\(mand\\)\\?\\>!.*$")
|
||||||
|
endfunction
|
||||||
|
|
||||||
" --- C / C++ Stuff ---
|
" --- C / C++ Stuff ---
|
||||||
|
|
||||||
|
@ -298,21 +309,27 @@ au BufNewFile,BufRead *.c,*.cpp,*.h,*.hpp :nnoremap <buffer> <leader>im oint mai
|
||||||
au BufNewFile,BufRead *.c,*.cpp,*.h,*.hpp :nnoremap <buffer> ; m'$a;<C-c>`'
|
au BufNewFile,BufRead *.c,*.cpp,*.h,*.hpp :nnoremap <buffer> ; m'$a;<C-c>`'
|
||||||
|
|
||||||
" --- Ruby Stuff ---
|
" --- Ruby Stuff ---
|
||||||
" Insert Stuff
|
au BufNewFile,BufRead *.rb :call <sid>init_ruby_file()
|
||||||
au BufNewFile,BufRead *.rb :command! -buffer Defines lex Matchinglines("^\\s\\+def\\>")
|
|
||||||
au BufNewFile,BufRead *.rb :command! -buffer Classes lex Matchinglines("^\\s\\+class\\>")
|
function! s:init_ruby_file()
|
||||||
au BufNewFile,BufRead *.rb :command! -buffer Modules lex Matchinglines("^\\s\\+module\\>")
|
command! -buffer Defines lex MatchingLines("^\\s*def\\>.*$")
|
||||||
au BufNewFile,BufRead *.rb :nnoremap <buffer> <leader>ic oclass <C-o>m'<enter>end<esc>`'a
|
command! -buffer Functions Defines " Alias
|
||||||
au BufNewFile,BufRead *.rb :nnoremap <buffer> <leader>id odef <C-o>m'()<enter>end<esc>`'a
|
command! -buffer Methods Defines " Alias
|
||||||
" Other Stuff
|
command! -buffer Classes lex MatchingLines("^\\s*class\\>.*$")
|
||||||
au BufNewFile,BufRead *.rb setl expandtab
|
command! -buffer Modules lex MatchingLines("^\\s*module\\>.*$")
|
||||||
au BufNewFile,BufRead *.rb nnoremap <buffer> <F5> :w<CR>:!ruby %<CR>
|
|
||||||
au BufNewFile,BufRead *.rb nnoremap <buffer> <F6> :w<CR>:!ruby -wc %<CR>
|
nnoremap <buffer> <leader>ic oclass <C-o>m'<enter>end<esc>`'a
|
||||||
|
nnoremap <buffer> <leader>id odef <C-o>m'()<enter>end<esc>`'a
|
||||||
|
|
||||||
|
setl expandtab
|
||||||
|
nnoremap <buffer> <F5> :w<CR>:!ruby %<CR>
|
||||||
|
nnoremap <buffer> <F6> :w<CR>:!ruby -wc %<CR>
|
||||||
|
nnoremap <buffer> <leader>~ :call <SID>RubyComment(0)<CR>
|
||||||
|
nnoremap <buffer> <leader># :call <SID>RubyComment(1)<CR>
|
||||||
|
vnoremap <buffer> <leader>~ :call <SID>RubyComment(0)<CR>
|
||||||
|
vnoremap <buffer> <leader># :call <SID>RubyComment(1)<CR>
|
||||||
|
endfunction
|
||||||
|
|
||||||
au BufNewFile,BufRead *.rb :nnoremap <buffer> <leader>C :call <SID>RubyComment(0)<CR>
|
|
||||||
au BufNewFile,BufRead *.rb :nnoremap <buffer> <leader>c :call <SID>RubyComment(1)<CR>
|
|
||||||
au BufNewFile,BufRead *.rb :vnoremap <buffer> <leader>C :call <SID>RubyComment(0)<CR>
|
|
||||||
au BufNewFile,BufRead *.rb :vnoremap <buffer> <leader>c :call <SID>RubyComment(1)<CR>
|
|
||||||
function! s:RubyComment(a)
|
function! s:RubyComment(a)
|
||||||
if a:a==0
|
if a:a==0
|
||||||
silent! exec '.s/\m^\s*\zs#*//'
|
silent! exec '.s/\m^\s*\zs#*//'
|
||||||
|
|
Loading…
Reference in a new issue