Skip to content

Instantly share code, notes, and snippets.

@mahyaret
Last active July 4, 2020 12:20
Show Gist options
  • Save mahyaret/f157a7d7a47c618da7f7d098aba60deb to your computer and use it in GitHub Desktop.
Save mahyaret/f157a7d7a47c618da7f7d098aba60deb to your computer and use it in GitHub Desktop.
Vim
set hidden
set timeout ttimeoutlen=50
" folding thte code
set foldmethod=indent
set nofoldenable
" za: Toggle code folding.
" zR: Open all folds.
" zM: Close all folds.
" zo: Open current fold.
" zc: Close current fold.
let g:airline#extensions#tabline#enabled = 1
" changing the leader key
let mapleader = ","
let g:mapleader = ","
" for moving lines using leader+j/k
nnoremap <Leader>j :m .+1<CR>==
nnoremap <Leader>k :m .-2<CR>==
inoremap <Leader>j <Esc>:m .+1<CR>==gi
inoremap <Leader>k <Esc>:m .-2<CR>==gi
vnoremap <Leader>j :m '>+1<CR>gv=gv
vnoremap <Leader>k :m '<-2<CR>gv=gv
set directory^=$HOME/.vim/tmp// " saving swp file in .vim/tmp
colorscheme gruvbox
set background=dark " Setting dark mode
" to be able to copy to x clipboard
set clipboard=unnamed
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
""" for windows
"" set rtp+=$HOME/vimfiles/bundle/Vundle.vim/
"" call vundle#begin('$HOME/vimfiles/bundle/')
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" theme
Plugin 'morhetz/gruvbox'
" file drawer
Plugin 'preservim/nerdtree'
" scroll like sublime
Plugin 'severin-lemaignan/vim-minimap'
" search using :Ack [pattern]
Plugin 'mileszs/ack.vim'
" fuzzy file finder
Plugin 'kien/ctrlp.vim'
" git tool
Plugin 'tpope/vim-fugitive'
" Autocomplete
Plugin 'ycm-core/YouCompleteMe'
" julia support for vim
Plugin 'JuliaEditorSupport/julia-vim'
" status bar
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
" communicating with tmux
Plugin 'benmills/vimux'
" All of your Plugins must be added before the following line
call vundle#end() " required
""" for windows
"" call vundle#end('$HOME/vimfiles/bundle/')
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
" default behavior for back space
set backspace=indent,eol,start
" enable syntax highlighting
syntax enable
" show line numbers
set number
" set tabs to have 4 spaces
set ts=4
" indent when moving to the next line while writing code
set autoindent
" expand tabs into spaces
set expandtab
" when using the >> or << commands, shift lines by 4 spaces
set shiftwidth=4
" show a visual line under the cursor's current line
set cursorline
" show the matching part of the pair for [] {} and ()
set showmatch
" enable all Python syntax highlighting features
let python_highlight_all = 1
" disable arrow keys for practice!
nnoremap <Left> :echo "No left for you!"<CR>
vnoremap <Left> :<C-u>echo "No left for you!"<CR>
inoremap <Left> <C-o>:echo "No left for you!"<CR>
nnoremap <Right> :echo "No right for you!"<CR>
vnoremap <Right> :<C-u>echo "No right for you!"<CR>
inoremap <Right> <C-o>:echo "No right for you!"<CR>
nnoremap <Up> :echo "No up for you!"<CR>
vnoremap <Up> :<C-u>echo "No up for you!"<CR>
inoremap <Up> <C-o>:echo "No up for you!"<CR>
nnoremap <Down> :echo "No down for you!"<CR>
vnoremap <Down> :<C-u>echo "No down for you!"<CR>
inoremap <Down> <C-o>:echo "No down for you!"<CR>
" auto start nerdTree
autocmd vimenter * NERDTree
" open nerdtree with shortcut
map <C-n> :NERDTreeToggle<CR>
" fix nerdtree behavior after :bd
noremap <leader>x :bp<cr>:bd #<cr>
" switching between buffers
map <leader>n :bn<cr>
map <leader>p :bp<cr>
" splitting window
map <leader>" :split<cr>
map <leader>% :vsplit<cr>
" easier split navigation
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" zoom into the pane
nnoremap <leader>z <C-W>o
" prompt for a command to run
map <Leader>vc :VimuxPromptCommand<CR>
" inspect runner pane
map <Leader>vi :VimuxInspectRunner<CR>
" run last command executed by VimuxRunCommand
map <Leader>vl :VimuxRunLastCommand<CR>
""" for gvim set the font
"" set guifont=Fira_Mono_Medium:h10
set guifont=FiraCodeNerdFontComplete-Retina:h12
" for scrolling
let g:minimap_show='<leader>ms'
let g:minimap_update='<leader>mu'
let g:minimap_close='<leader>gc'
let g:minimap_toggle='<leader>gt'
" for searching
let g:ackprg = 'ag --nogroup --nocolor --column'
" d => "delete"
" leader d => "cut"
nnoremap x "_x
nnoremap d "_d
nnoremap D "_D
vnoremap d "_d
nnoremap <leader>d ""d
nnoremap <leader>D ""D
vnoremap <leader>d ""d
" useful mappings for YouCompleteMe
nnoremap <leader>gl :YcmCompleter GoToDeclaration<CR>
nnoremap <leader>gf :YcmCompleter GoToDefinition<CR>
nnoremap <leader>gg :YcmCompleter GoToDefinitionElseDeclaration<CR>
" search enhancements
set ignorecase
set smartcase
set incsearch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment