解説付きおすすめvim設定
vimrcのおすすめ設定です。
一部コメント書いているので、適宜コメントアウトして使ってください。 特に下の方は、HTMLやTex用です。
set autoread
set hidden
set showcmd
set number " line number
set title
set showmatch
set autoindent
set smartindent " c-like auto indent
set virtualedit=onemore
set cursorline " highlight cursor line
set laststatus=2
set wildmode=list:longest
nnoremap j gj
nnoremap k gk
syntax enable
inoremap [ []<left>
inoremap { {}<left>
inoremap ( ()<left>
inoremap " ""<left>
inoremap ' ''<left>
set list listchars=tab:\▸\-
set expandtab " tab to space
set tabstop=4 " apparent number of spaces
set shiftwidth=4 " indent width
set ignorecase " case-insensitive search
set smartcase " case-sensitive search
set incsearch " incremental search
set wrapscan
set hlsearch
nmap <Esc><Esc> :nohlsearch<CR><Esc>
set background=dark
"colorscheme solarized
"let g:solarized_termcolors=256
" auto comp
inoremap {<CR> {<CR>}<left><Up><End><CR>
" open new split panes to right and bottom, which feels more natural
set splitbelow
set splitright
" quicker window movement
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
""""
"html omnifunc
filetype plugin on
augroup MyXML
autocmd!
"autocmd Filetype html inoremap <buffer> </ </<C-x><C-o><ESC>F>a
autocmd Filetype html inoremap <buffer> </ </<C-x><C-o>
autocmd Filetype xml inoremap <buffer> </ </<C-x><C-o>
autocmd BufNewFile,BufRead *.html setlocal tabstop=2 shiftwidth=2
autocmd BufNewFile,BufRead *.css setlocal tabstop=2 shiftwidth=2
autocmd BufNewFile,BufRead *.js setlocal tabstop=2 shiftwidth=2
augroup END
" latex auto trans
autocmd BufWritePre *.tex :call FixPunctuation()
function! FixPunctuation() abort
let l:pos = getpos('.')
silent! execute ':%s/。/./g'
silent! execute ':%s/、/,/g'
silent! execute ':%s/\\\@<!\s\+$//'
call setpos('.', l:pos)
endfunction