"If you're in insert mode, use <C-o> to perform an action of block mode without pressing <Esc>. "For example, <C-o> :w is the same as <Esc>:w<CR>i. "Insert the result of a command with :r !<your cmd> or :. ! <your cmd> "For auto entering "autocmd BufNewFile *.cpp r ~/prog/base.cpp "Read http://stackoverflow.com/questions/726894/what-are-the-dark-corners-of-vim-your-mom-never-told-you-about "Mapping Ctrl + s for save "Requires 'stty -ixon' to be written in bashrc (to disable control flow) nnoremap <C-S> :w <CR> inoremap <C-S> <Esc> :w <CR> "Ctrl + V is used for paste, visual block is now Ctrl + Q nnoremap <C-V> "+p inoremap <C-V> <Esc><C-V> vnoremap <C-C> "+y vnoremap <C-X> "+x vmap <C-V> d"+P "Commands when shift remaing pressed while pressing quit / write :command WQ wq :command Wq wq :command W w :command Q q "For navigating tabs like other applications nnoremap <C-PageDown> gt nnoremap <C-PageUp> gT nnoremap <C-O> :tabnew <Space> nnoremap <C-T> :tabnew <Space> "Open new panes to right and bottom set splitright set splitbelow "Direct navigation in split mode nnoremap <C-Up> <C-W><Up> nnoremap <C-Down> <C-W><Down> nnoremap <C-Right> <C-W><Right> nnoremap <C-Left> <C-W><Left> "Trying to close nnoremap <C-E> :q <CR> "mapping increment / decrement, are not in use much "nnoremap <C-I> <C-A> "nnoremap <C-D> <C-X> "Select All option, conflicts with the increment option nnoremap <C-A> ggVG "Auto Bracket completion inoremap { {}<Left> inoremap {<CR> {<CR>}<Esc>O inoremap {{ { inoremap {} {} ""inoremap ( ()<Left> inoremap <expr> ( matchstr(strpart(getline('.'), col('.')-1, 1), '[0-9A-Za-z_]') == "" ? "()<Left>" : "(" inoremap <expr> ) strpart(getline('.'), col('.')-1, 1) == ")" ? "\<Right>" : ")" inoremap " ""<Left> inoremap ' ''<Left> inoremap [ []<Left> inoremap <expr> ] strpart(getline('.'), col('.')-1, 1) == "]" ? "\<Right>" : "]" "Place 2 spaces instead of a tab filetype plugin indent on syntax on set shiftwidth=2 set expandtab set softtabstop=2 set shiftround " when shifting a non-aligned set of lines, align them to the next tabstop set nu " show line numbers set cursorline " underline current line "while scrolling keep cursor at the middle set scrolloff=999 "Fold using indentation set foldmethod=indent nnoremap fm :set foldmethod=manual <CR> "Unfold all in beginning set foldlevel=99 "Shortcut for fold, place the cursor on start of indent block (like while(), if, etc and press ff nnoremap ff jzc nnoremap uu zo nnoremap UU zR set hlsearch " highlight all matching entries set incsearch " search as you type set ignorecase set smartcase " smartcase search " Taken from Misof's vimrc: https://people.ksp.sk/~misof/programy/vimrc.html " if I press <tab> in command line, show me all options if there is more than one set wildmenu " y and d put stuff into system clipboard (so that other apps can see it) ""set clipboard=unnamed,unnamedplus " while typing a command, show it in the bottom right corner set showcmd " enough with the @@@s, show all you can if the last displayed line is too long set display+=lastline " show chars that cannot be displayed as <13> instead of ^M set display+=uhex " some tweaks taken from vimbits.com: " reselect visual block after indent/outdent vnoremap < <gv vnoremap > >gv " make Y behave like other capitals map Y y$ " force saving files that require root permission cmap w!! %!sudo tee > /dev/null % "Indentation may cause trouble in pasting blocks of programs. "Use :set paste while pasting and :set nopaste to exit paste mode "For syntastic plugin "https://github.com/scrooloose/syntastic execute pathogen#infect() "start NerdTree on startup and start in main window autocmd VimEnter * NERDTree autocmd VimEnter * wincmd p "Setting NERDTree Window Size let g:NERDTreeWinSize=20 if has("gui_running") set guioptions-=T "no menu bar set guioptions-=r "no scorllbar on right set guioptions-=l "no scorllbar on left set lines=35 set columns=120 nnoremap <C-O> :browse tabnew <CR> endif " Scala syntax "augroup filetypedetect " au! BufRead,BufNewFile *.scala, set filetype=scala "augroup END " mapping Caps Lock to <Esc> ""xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape'