Created
October 11, 2022 11:29
-
-
Save SteelPh0enix/b5e8e5456c01eee3675c748abcfaaa37 to your computer and use it in GitHub Desktop.
My current .vimrc file
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
" vimrc based on https://github.com/amix/vimrc/blob/master/vimrcs/basic.vim | |
" written by SteelPh0enix | |
" Set how many lines of history are remembered | |
set history=500 | |
" Enable filetype plugins | |
filetype plugin on | |
filetype indent on | |
" dark background | |
set background=dark | |
" Set auto-read when file is changed from outside | |
set autoread | |
au FocusGained,BufEnter * checktime | |
" Set mapleader for shortcuts | |
let mapleader = "," | |
" Leader shortcuts | |
nmap <leader>w :w<cr> | |
" set endline to unix | |
set ffs=unix,dos,mac | |
" Enable syntax colouring | |
syntax enable | |
" Enable wildmenu | |
set wildmenu | |
" show line numbers | |
set number | |
set relativenumber | |
" Always show current position in file | |
set ruler | |
" fix the backspace | |
set backspace=eol,start,indent | |
set whichwrap+=<,>,h,l | |
" Search settings | |
set smartcase | |
set ignorecase | |
set hlsearch | |
set incsearch | |
" Don't redraw while executing macros | |
set lazyredraw | |
" Magic for regex | |
set magic | |
" Highlight matching brackets | |
set showmatch | |
" Standard encoding | |
set encoding=utf8 | |
" Disable backups | |
set nobackup | |
set nowb | |
set noswapfile | |
" Tab settings | |
set expandtab " spaces instead of tabs | |
set smarttab | |
set shiftwidth=4 | |
set tabstop=4 | |
" linebreak on 100 characters | |
set lbr | |
set tw=100 | |
set ai " auto-indent | |
set si " smart indent | |
set wrap " wrap lines | |
" Visual mode pressing * or # searches for the current selection | |
" Super useful! From an idea by Michael Naumann | |
vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR> | |
vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR> | |
" Map <Space> to / (search) and Ctrl-<Space> to ? (backwards search) | |
map <space> / | |
map <C-space> ? | |
" Disable highlight when <leader><cr> is pressed | |
map <silent> <leader><cr> :noh<cr> | |
" Status line | |
set laststatus=2 | |
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c | |
" helper functions | |
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 | |
function! HasPaste() | |
if &paste | |
return 'PASTE MODE ' | |
endif | |
return '' | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment