aboutsummaryrefslogtreecommitdiff
path: root/vimrc
diff options
context:
space:
mode:
authorSergey Nazaryev <sergey@nazaryev.ru>2015-11-08 07:06:14 +0300
committerSergey Nazaryev <sergey@nazaryev.ru>2016-12-07 15:18:40 +0300
commitc08548201660447a70c39ef8bfed61c2d0981a52 (patch)
tree5b8685d2ee137d4c4857b88fd95fc2de5624bfb1 /vimrc
downloaddotfiles-c08548201660447a70c39ef8bfed61c2d0981a52.zip
dotfiles-c08548201660447a70c39ef8bfed61c2d0981a52.tar.gz
dotfiles-c08548201660447a70c39ef8bfed61c2d0981a52.tar.bz2
Initial release
Diffstat (limited to 'vimrc')
-rw-r--r--vimrc100
1 files changed, 100 insertions, 0 deletions
diff --git a/vimrc b/vimrc
new file mode 100644
index 0000000..6ea641a
--- /dev/null
+++ b/vimrc
@@ -0,0 +1,100 @@
+" .vimrc configuration by zar <sergey@nazaryev.ru>
+
+set langmap=ё`йqцwуeкrеtнyгuшiщoзpх[ъ]фaыsвdаfпgрhоjлkдlж\\;э'яzчxсcмvиbтnьmб\\,ю.Ё~ЙQЦWУEКRЕTНYГUШIЩOЗPХ{Ъ}ФAЫSВDАFПGРHОJЛKДLЖ:Э\\"ЯZЧXСCМVИBТNЬMЮ>Б<
+
+nohl " no highlight last search query in new files
+set tabpagemax=100 " maximum tab count is 100, not 10
+set encoding=utf-8 " always use utf-8
+set t_Co=256 " 256-color terminal mode
+set backspace=indent,eol,start " allow backspacing over everything in insert mode
+set smartindent " enable smart indent
+set history=7000 " keep 7000 lines of command line history
+set colorcolumn=70 " set colored column on 70 column
+set textwidth=69 " autosplit after 69 column
+set mouse=a " using mouse in terminal
+set wildmode=list:longest,full " sh-like autocompletion file names
+set wildmenu " enhanced cmd line completion
+set ruler " show the cursor position all the time
+set nowrap " don't wrap lines on screen
+set expandtab " convert all TAB to N spaces
+set shiftwidth=2 " where N is 2
+set tabstop=2 " width of tab in number of spaces
+set shortmess=atI " don't show startup screen
+set scrolloff=3 " scroll before N lines to bottom
+set number " show line numbers
+set showmatch " show matching bracket
+set title " set window title as filename
+set autoread " automatically read file when it changed in external editor
+set wrapscan " search continues over end of file
+set hlsearch " highlight all search results
+set incsearch " increment search
+set ignorecase " case-insensitive search
+set smartcase " uppercase causes case-sensitive search
+set pastetoggle=<F3> " paste mode toggle by button
+set laststatus=2 " always show status line
+set timeoutlen=1000 ttimeoutlen=0 " no timeout after exit from visual mode
+set esckeys " allow cursor keys in insert mode
+set nojoinspaces " only insert single space after a '.', '?' and '!' with a join command
+set smarttab " at start of line, <Tab> inserts shiftwidth spaces, <Bs> deletes shiftwidth spaces
+set novisualbell " no visual and sound bell
+set hidden " allow buffer switching without saving
+set virtualedit=onemore " allow for cursor beyond last character
+set lazyredraw " no lags
+set ttyfast " no lags
+"set nocompatible
+
+" Settings for specific file types
+autocmd FileType make set noexpandtab shiftwidth=8 softtabstop=0
+autocmd FileType c set noexpandtab shiftwidth=4 softtabstop=0
+autocmd FileType dts set noexpandtab shiftwidth=2 softtabstop=0
+
+" Style settings
+syntax on " turn on syntax highlight
+colorscheme elflord
+hi Visual ctermfg=7 ctermbg=0 cterm=none
+hi LineNr ctermfg=DarkGrey ctermbg=none
+match Error /\s\+$/ " match trailing whitespaces
+
+" Mappings
+let mapleader=","
+map <F2> <Esc>:!ctags -R<CR>
+map q <Esc>:q<CR>
+command! Cwd lcd %:p:h
+command! Sudo w !sudo tee % >/dev/null
+vnoremap < <gv
+vnoremap > >gv
+noremap <leader>ss :call StripTrailingWhitespace()<CR>
+
+" Strip trailing whitespace (,ss)
+function! StripTrailingWhitespace()
+ let save_cursor = getpos(".")
+ let old_query = getreg('/')
+ :%s/\s\+$//e
+ call setpos('.', save_cursor)
+ call setreg('/', old_query)
+endfunction
+
+if has("autocmd")
+ " jump to the last position when reopening a file
+ autocmd! BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
+
+ " autoreload .vimrc
+ autocmd! bufwritepost .vimrc source $MYVIMRC
+
+ " autostrip trailing whitespaces
+ autocmd! FileType c,cpp,java,go,php,javascript,puppet,python,rust,twig,xml,yml,perl,sql,vim,markdown autocmd BufWritePre <buffer> call StripTrailingWhitespace()
+
+ " autodetect file type for syntax highlighting
+ autocmd! BufEnter,InsertLeave * :filetype detect
+endif
+
+" Persistent undo
+if has('persistent_undo')
+ call system('mkdir -p ~/.vim/undo')
+ set undodir=~/.vim/undo
+ set undofile
+endif
+
+" Omni-complition
+filetype plugin on
+set omnifunc=syntaxcomplete#Complete