Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- " BASIC SETUP:
- " the <leader> is (comma)
- " ***************************************************************************
- set autoread " Set to auto read when a file is changed from the outside
- set backspace=indent,eol,start " more powerful backspacing
- set clipboard=unnamed " access your system clipboard
- set cmdheight=2 " Height of the command bar
- syntax enable " enable syntax highlighting and plugin (for netrw)
- set encoding=utf8 " Set utf8 as standard encoding and en_US as the standard language
- set expandtab " convert tabs into spaces
- set ffs=unix,dos,mac " Use Unix as the standard file type
- set foldmethod=indent " Code folding
- set foldlevel=99
- set history=500 " Sets how many lines of history VIM has to remember
- set incsearch " incremental search
- set laststatus=2 " Always show the status line
- set list " Show trailing white space
- set listchars=tab:>·,trail:~,extends:>,precedes:<,space:. " eol:¬,tab:>·,trail:~,extends:>,precedes:<,space:.
- set mouse=nicr
- set magic " For regular expressions turn magic on
- set nocompatible " enter the current millenium
- set number " always show line numbers
- set hidden
- set ruler " Always show current position
- set scrolloff=3 " when scrolling, keep cursor 3 lines away from screen border
- set shiftwidth=2 " amount of block indenting
- set smarttab " uses the shiftwidth instead of tabstop to delete indented line
- set synmaxcol=200 " performance ???
- set tabstop=2 " press tab, 2 spaces forward, 1 tab == 2 spaces
- set wrap " Wrap lines
- filetype plugin indent on " required
- " OTHER BASIC SETUP (TWEAKS)
- " ***************************************************************************
- let mapleader = ","
- let maplocalleader = ","
- set termguicolors
- nnoremap <leader>N :setlocal number!<cr> " Toggle line numbers
- " 1 comma+s to save
- " 2 comma+q to quit (does not save, watch out!)
- " 3 quit all without saving
- nnoremap <leader>ss :w<cr>
- nnoremap <leader>q :q!<cr>
- nnoremap <leader>qa :qa!<cr>
- let $MYVIMRC="/home/you_username/.vimrc"
- " Reload vimrc
- nnoremap <leader>rv :source<Space>$MYVIMRC<cr>
- " Edit vimrc
- nnoremap <leader>ev :tabnew $MYVIMRC<cr>
- " Copy & paste to clipboard
- noremap <Leader>Y "+y
- noremap <Leader>P "+p
- " change Escape key behaviour
- " :imap ii <Esc>
- imap <leader>q <Esc>
- inoremap jj <Esc>
- " Enable folding with the z
- nnoremap <leader> z
- " Buffer key mappings
- nnoremap <leader>l :bn<cr>
- nnoremap <leader>h :bp<cr>
- nnoremap <leader>0 :bf<cr>
- nnoremap <leader>9 :bl<cr>
- nnoremap <leader>dd :bd<cr>
- " Managing tabs
- nnoremap tn :tabnew<Space>
- nnoremap tk :tabnext<CR>
- nnoremap tj :tabprev<CR>
- nnoremap th :tabfirst<CR>
- nnoremap tl :tablast<CR>
- nnoremap tc :tabclose<CR>
- " :W sudo saves the file
- " (useful for handling the permission-denied error)
- command W w !sudo tee % > /dev/null
- " navigate split screens easily
- nmap <silent> <c-k> :wincmd k<CR>
- nmap <silent> <c-j> :wincmd j<CR>
- nmap <silent> <c-h> :wincmd h<CR>
- nmap <silent> <c-l> :wincmd l<CR>
- " Stay in visual mode when indenting. You will never have to run gv after
- " performing an indentation.
- " Pressing Shift-< or Shift-> will let you indent/unident selected lines,
- " allow it to occur multiple times in visual mode
- vnoremap < <gv
- vnoremap > >gv
- " Commenting
- " comma-1 insert "!" commenting
- nnoremap <leader>1 :norm i!<cr>
- vnoremap <leader>1 :norm i!<cr>
- " comma-' insert """ commenting
- nnoremap <leader>' :norm i"<cr>
- vnoremap <leader>' :norm i"<cr>
- " comma-3 insert "#" commenting
- nnoremap <leader>3 :norm i#<cr>
- vnoremap <leader>3 :norm i#<cr>
- " comma-- insert "--" commenting
- nnoremap <leader>- :norm i--<cr>
- vnoremap <leader>- :norm i--<cr>
- " comma-6 uncomment
- nnoremap <leader>6 :norm ^x<cr>
- vnoremap <leader>6 :norm ^x<cr>
- " Ignore compiled files
- set wildignore=*.o,*~,*.pyc
- if has("win16") || has("win32")
- set wildignore+=.git\*,.hg\*,.svn\*
- else
- set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
- endif
- " Make Y yank everything from the cursor to the end of the line. This makes Y
- " act more like C or D because by default, Y yanks the current line (i.e. the
- " same as yy).
- noremap Y y$
- " autocompletion of files and commands behaves like shell
- " (complete only the common part, list the options that match)
- set wildmode=list:longest
- " FINDING FILES: **********************************************************
- " search down into subfolders
- " provides tab-completion for all file-related tasks
- set path+=**
- " display all matching files when we tab complete
- set wildmenu
- set wildmode=list:longest,full
- set lazyredraw
- " NOW WE CAN:
- " - hit tab to :find by partial match
- " - use * to make it fuzzy
- " THINGS TO CONSIDER:
- " - :b lets you autocomplete any open buffer
- " END FINDING FILES: **********************************************************
- " FILE BROWSING: *********************************************************
- " tweaks for browsing
- let g:netrw_banner=0 " disable annoying banner
- let g:netrw_browse_split=4 " open in prior window
- let g:netrw_altv=1 " open splits to the right
- let g:netrw_liststyle=3 " tree view
- let g:netrw_list_hide=netrw_gitignore#Hide()
- let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+'
- " NOW WE CAN:
- " - :edit a folder to open a file browser
- " - <CR>/v/t to open in an h-split/v-split/tab
- " - check |netrw-browse-maps| for more mappings
- " END FILE BROWSING: *********************************************************
- " Enable 256 colors palette in Gnome Terminal
- if $COLORTERM == 'gnome-terminal'
- set t_Co=256
- endif
- set background=dark
- " Set extra options when running in GUI mode
- if has("gui_running")
- set guioptions-=T
- set guioptions-=e
- set t_Co=256
- set guitablabel=%M\ %t
- set cursorcolumn!
- " Set up the gui cursor to look nice
- set guicursor=n-v-c:block-Cursor-blinkon0
- set guicursor+=ve:ver35-Cursor
- set guicursor+=o:hor50-Cursor
- set guicursor+=i-ci:ver25-Cursor
- set guicursor+=r-cr:hor20-Cursor
- set guicursor+=sm:block-Cursor-blinkwait175-blinkoff150-blinkon175
- endif
- " better backup, swap and undos storage
- set directory=~/.vim/dirs/tmp " directory to place swap files in
- set backup " make backup files
- set backupdir=~/.vim/dirs/backups " where to put backup files
- set undofile " persistent undos - undo after you re-open the file
- set undodir=~/.vim/dirs/undos
- set viminfo+=n~/.vim/dirs/viminfo
- " store yankring history file there too
- let g:yankring_history_dir = '~/.vim/dirs/'
- " create needed directories if they don't exist
- if !isdirectory(&backupdir)
- call mkdir(&backupdir, "p")
- endif
- if !isdirectory(&directory)
- call mkdir(&directory, "p")
- endif
- if !isdirectory(&undodir)
- call mkdir(&undodir, "p")
- endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement