Created
December 29, 2017 15:02
-
-
Save nobitagit/caecd5882a8a3f7563bcc751c9e5417d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
" alternatively, pass a path where Vundle should install plugins | |
"call vundle#begin('~/some/path/here') | |
" let Vundle manage Vundle, required | |
Plugin 'VundleVim/Vundle.vim' | |
Plugin 'tpope/vim-fugitive' | |
Plugin 'scrooloose/nerdtree' | |
Plugin 'vim-airline/vim-airline' | |
Plugin 'vim-airline/vim-airline-themes' | |
Plugin 'dracula/vim' | |
Plugin 'mhartington/oceanic-next' | |
" The following are examples of different formats supported. | |
" Keep Plugin commands between vundle#begin/end. | |
" plugin on GitHub repo | |
"" Plugin 'tpope/vim-fugitive' | |
" plugin from http://vim-scripts.org/vim/scripts.html | |
" Plugin 'L9' | |
" Git plugin not hosted on GitHub | |
"" Plugin 'git://git.wincent.com/command-t.git' | |
" git repos on your local machine (i.e. when working on your own plugin) | |
"" Plugin 'file:///home/gmarik/path/to/plugin' | |
" The sparkup vim script is in a subdirectory of this repo called vim. | |
" Pass the path to set the runtimepath properly. | |
"" Plugin 'rstacruz/sparkup', {'rtp': 'vim/'} | |
" Install L9 and avoid a Naming conflict if you've already installed a | |
" different version somewhere else. | |
" Plugin 'ascenator/L9', {'name': 'newL9'} | |
" All of your Plugins must be added before the following line | |
call vundle#end() " required | |
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 | |
set background=dark | |
set number | |
set relativenumber | |
set hlsearch | |
set ruler | |
" automatically run nerdtree on startup | |
" autocmd vimenter * NERDTree | |
" nerdtree when opening a dir | |
autocmd StdinReadPre * let s:std_in=1 | |
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif | |
" close Nerdtree when it is the last window open | |
" autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | |
" Configure backspace so it acts as it should act | |
set backspace=eol,start,indent | |
set whichwrap+=<,>,h,l | |
" Ignore case when searching | |
set ignorecase | |
" When searching try to be smart about cases | |
set smartcase | |
" Highlight search results | |
set hlsearch | |
" Makes search act like search in modern browsers | |
set incsearch | |
" Show matching brackets when text indicator is over them | |
set showmatch | |
" How many tenths of a second to blink when matching brackets | |
set mat=2 | |
" Properly disable sound on errors on MacVim | |
if has("gui_macvim") | |
autocmd GUIEnter * set vb t_vb= | |
endif | |
" Add a bit extra margin to the left | |
set foldcolumn=0 | |
" search on all subdirs when using find | |
set path+=** | |
" remove all scrollbars from the gui | |
set guioptions= | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Colors and Fonts | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Enable syntax highlighting | |
syntax enable | |
" colorscheme dracula | |
colorscheme OceanicNext | |
let g:airline_theme='dracula' | |
"set guifont=Monaco:h11 | |
" Enable 256 colors palette in Gnome Terminal | |
set t_Co=256 | |
if has("gui_macvim") | |
set guioptions-=T | |
set guioptions-=e | |
set t_Co=256 | |
set guitablabel=%M\ %t | |
endif | |
" Set utf8 as standard encoding and en_US as the standard language | |
set encoding=utf8 | |
if has("gui_running") | |
let g:airline_powerline_fonts = 1 | |
"set guifont=Inconsolata-g\ for\ Powerline:h12 | |
set guifont=Roboto\ Mono\ Light\ for\ Powerline:h12 | |
"set guifont=Meslo\ LG\ L\ DZ\ Regular\ for\ Powerline:h12 | |
endif | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Text, tab and indent related | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Use spaces instead of tabs | |
set expandtab | |
" Be smart when using tabs ;) | |
set smarttab | |
" 1 tab == 2 spaces | |
set shiftwidth=2 | |
set tabstop=2 | |
" Linebreak on 500 characters | |
set lbr | |
set tw=500 | |
set ai "Auto indent | |
set si "Smart indent | |
set wrap "Wrap lines | |
"set listchars=eol:¬,tab:>·,trail:~,extends:>,precedes:<,space:␣ | |
set listchars=tab:>·,trail:␣,extends:>,precedes:<,space:␣ | |
set list | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Remappings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" make Wq work anyway | |
command! Wq :wq | |
"""""""""""""""""""""""""""""" | |
" => Status line | |
"""""""""""""""""""""""""""""" | |
" Always show the status line | |
set laststatus=2 | |
" Format the status line | |
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c | |
" Delete trailing white space on save, useful for some filetypes ;) | |
fun! CleanExtraSpaces() | |
let save_cursor = getpos(".") | |
let old_query = getreg('/') | |
silent! %s/\s\+$//e | |
call setpos('.', save_cursor) | |
call setreg('/', old_query) | |
endfun | |
if has("autocmd") | |
autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces() | |
endif | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Helper functions | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Returns true if paste mode is enabled | |
function! HasPaste() | |
if &paste | |
return 'PASTE MODE ' | |
endif | |
return '' | |
endfunction | |
" Don't close window, when deleting a buffer | |
command! Bclose call <SID>BufcloseCloseIt() | |
function! <SID>BufcloseCloseIt() | |
let l:currentBufNum = bufnr("%") | |
let l:alternateBufNum = bufnr("#") | |
if buflisted(l:alternateBufNum) | |
buffer # | |
else | |
bnext | |
endif | |
if bufnr("%") == l:currentBufNum | |
new | |
endif | |
if buflisted(l:currentBufNum) | |
execute("bdelete! ".l:currentBufNum) | |
endif | |
endfunction | |
function! CmdLine(str) | |
exe "menu Foo.Bar :" . a:str | |
emenu Foo.Bar | |
unmenu Foo | |
endfunction | |
function! VisualSelection(direction, extra_filter) range | |
let l:saved_reg = @" | |
execute "normal! vgvy" | |
let l:pattern = escape(@", "\\/.*'$^~[]") | |
let l:pattern = substitute(l:pattern, "\n$", "", "") | |
if a:direction == 'gv' | |
call CmdLine("Ack '" . l:pattern . "' " ) | |
elseif a:direction == 'replace' | |
call CmdLine("%s" . '/'. l:pattern . '/') | |
endif | |
let @/ = l:pattern | |
let @" = l:saved_reg | |
endfunction | |
" avoid line numbers when copying with a mouse | |
se mouse+=a | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment