Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set number
- syntax on
- set autoindent
- set smartindent
- set mouse=a
- set background=dark
- set noswapfile
- set noundofile
- set nobackup
- nnoremap <silent> > :call Indent()<CR>
- nnoremap <silent> < :call UnIndent()<CR>
- let g:indent = 2
- let g:tabchar = " "
- colorscheme hybrid
- augroup mygroup
- autocmd!
- autocmd BufWritePre * call DeleteBlanklineIndent()
- augroup END
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " setup / factory functions "
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- let &shiftwidth=g:indent
- let &softtabstop=g:indent
- let &tabstop=g:indent
- if g:tabchar == " "
- set expandtab
- endif
- function! GenIndent()
- call assert_equal(strlen(g:tabchar), 1)
- let res = ""
- let i = 0
- while i < g:indent
- let res = res . g:tabchar
- let i = i + 1
- endwhile
- return res
- endfunction
- function! Indent()
- let indent_str = GenIndent()
- let cur_line_no = line(".")
- let cur_line = getline(cur_line_no)
- call setline(cur_line_no, indent_str . cur_line)
- endfunction
- function! UnIndent()
- let cur_line_no = line(".")
- let cur_line = getline(cur_line_no)
- let start_str = cur_line[0:(g:indent - 1)]
- let i = 0
- while i < g:indent
- if start_str[0] =~ '\s'
- let start_str = start_str[1:]
- endif
- let i = i + 1
- endwhile
- call setline(cur_line_no, start_str . cur_line[(g:indent):])
- endfunction
- function! DeleteBlanklineIndent()
- let lastlineno = line("$")
- let i = 0
- while i < lastlineno
- let i = i + 1
- if getline(i) =~ "^\\s\\+$"
- call setline(i, "")
- endif
- endwhile
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement