My vim config

Posted on July 07, 2018

System-wise (switch caps-lock with ctl):

Win10 (caps.reg):

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00

Ubuntu:
gnome-tweak-tool > Typing

Vim:

It depends on vundle:

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

vimrc:

set nocompatible              " be iMproved, required
filetype off                  " required

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

Plugin 'scrooloose/nerdtree'
Plugin 'Valloric/YouCompleteMe'

Plugin 'alvan/vim-closetag'

call vundle#end()            " required
filetype plugin indent on    " required



" NERDtree"
let NERDTreeWinPos='left'
let NERDTreeWinSize=21
let NERDTreeChDirMode=1
autocmd VimEnter * NERDTree 
let NERDTreeIgnore = ['\.pyc$']
map <F2> :NERDTreeToggle<CR>
augroup NERD
        au!
        autocmd VimEnter * NERDTree
        autocmd VimEnter * wincmd p
augroup END




set hlsearch
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,chinese,prc,taiwan,latin-1,gbk,ucs-bom,cp936
set fileencoding=utf-8
let &termencoding=&encoding
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim


"colorscheme torte 
"colorscheme desert 
colorscheme default
syntax enable
syntax on
set nu!
set showmatch
set nolinebreak
set wrap
set ai
set expandtab

set tabstop=2 expandtab shiftwidth=2 softtabstop=2
set bs=2
set scrolloff=5


" python
"au BufNewFile,BufRead *.py setl tabstop=4 expandtab shiftwidth=4 softtabstop=4 et
" cpp
"autocmd BufRead,BufNewFile *.c,*.C,*.H,*.h set filetype=cpp
"au BufNewFile,BufRead *.C setl tabstop=2 expandtab shiftwidth=2 softtabstop=2 et
"au BufNewFile,BufRead *.c setl tabstop=2 expandtab shiftwidth=2 softtabstop=2 et
"au BufNewFile,BufRead *.cpp setl tabstop=2 expandtab shiftwidth=2 softtabstop=2 et
"autocmd filetype cpp setl tabstop=2 expandtab shiftwidth=2 softtabstop=2 et
" html
"au BufNewFile,BufRead *.html setl tabstop=2 expandtab shiftwidth=2 softtabstop=2 et
" txt
"au BufNewFile,BufRead *.txt setl tabstop=2 expandtab shiftwidth=2 softtabstop=2 et


map <F5> :diffupdate<CR>

"Cool files 
au BufNewFile,BufRead *.cl set filetype=cool
" Cuda
au BufNewFile,BufRead *.cu set ft=cuda
if (&filetype == "objc")
  set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab
endif

au FileType make setlocal noexpandtab tabstop=4 
au FileType html setlocal noexpandtab tabstop=2 shiftwidth=2 

au BufNewFile,BufRead *.nasm set ft=nasm et ts=4  sw=4

" F8 --> Hex editor
noremap <F8> :call HexMe()<CR>
let $in_hex=0
function HexMe()
    set binary
    set noeol
    if $in_hex>0
        :%!xxd -r
        let $in_hex=0
    else
        :%!xxd
        let $in_hex=1
    endif
endfunction


"" compile
""map <F9> :! python '%'<cr>
"autocmd filetype python nnoremap <F9> :w <bar> exec '!python '.shellescape('%')<CR>
"autocmd filetype c nnoremap <F9> :w <bar> exec '!gcc '.shellescape('%').' -o '.shellescape('%:r').' && ./'.shellescape('%:r')<CR>
"autocmd filetype cpp nnoremap <F9> :w <bar> exec '!g++ '.shellescape('%').' -std=c++11 -g -o '.shellescape('%:r').' && ./'.shellescape('%:r')<CR>
"autocmd filetype cpp nnoremap <F10> :w <bar> exec '!g++ '.shellescape('%').' -std=c++11 -g -o '.shellescape('%:r').' &&  cat temp.txt \| ./'.shellescape('%:r')<CR>


function Compile_and_run()
    exec 'w'
    if &filetype == 'c'
        exec "! gcc % -o %<; time ./%<"
    elseif &filetype == 'cpp'
       exec "! g++ -std=c++11 % -o %<; time ./%<"
    elseif &filetype == 'java'
       exec "! javac %; time java %<"
    elseif &filetype == 'sh'
       exec "! bash %"
    elseif &filetype == 'python'
       exec "! python3 %"
    endif
endfunction

" Quick run via <F5>
nnoremap <F9> :call Compile_and_run() <CR>
nnoremap <F3> :! bash ./sync.sh <CR>

filetype indent on
let g:ycm_autoclose_preview_window_after_completion=1
let g:ycm_server_python_interpreter = '/usr/bin/python3'

 

Vim-like Tmux

# remap prefix from 'C-b' to 'C-a'
# unbind C-b
# set-option -g prefix C-a
# bind-key C-a send-prefix

# split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %

# switch panes
bind j select-pane -D
bind k select-pane -U
bind h select-pane -L
bind l select-pane -R

 

None