2018-02-22 19:51:35 +01:00
""initial, more technical settings
2018-01-23 07:55:43 +01:00
"this sets what sort of folding method to use.
let foldtype = "basicindent"
set lazyredraw
set autoread
set history = 5000
filetype plugin on
"user interface stuff
2018-04-22 05:44:44 +02:00
"disables the autocommenting stuff.
set formatoptions - = o
set formatoptions - = r
set formatoptions - = c
2018-01-23 07:55:43 +01:00
2018-04-22 05:44:44 +02:00
"disable text wrapping via carriage returns, should only wrap visually
set textwidth = 0
set wrapmargin = 0
set wrap
set linebreak
set breakindent
2018-01-23 07:55:43 +01:00
2018-04-22 05:44:44 +02:00
"adds a ruler to the side of the screen
set number
2018-01-23 07:55:43 +01:00
2018-04-22 05:44:44 +02:00
"makes the ruler show how many lines away a given line is from your cursor
"set relativenumber
2018-01-23 07:55:43 +01:00
2018-04-22 05:44:44 +02:00
"displays the coordinates of your cursour in the statusbar
set ruler
2018-01-23 07:55:43 +01:00
2018-04-22 05:44:44 +02:00
"scrollofff sets the number of lines from the top or bottom of the screen before vim will scroll. sidescroll off does the same thing for the sides of the window
set scrolloff = 10
set sidescrolloff = 10
2018-01-23 07:55:43 +01:00
2018-04-22 05:44:44 +02:00
"better command line completion
set wildmenu
2018-01-23 07:55:43 +01:00
2018-04-22 05:44:44 +02:00
"ignore cases in search unless you have a capital letter in the search
set ignorecase
set smartcase
2018-01-23 07:55:43 +01:00
2018-04-22 05:44:44 +02:00
"this allows putting the cursor just after the last character of the line.
"set virtualedit=onemore
2018-01-23 07:55:43 +01:00
2018-04-22 05:44:44 +02:00
"show unfinished commands on the RIGHT side of the statusbar. yes, it is working.
set showcmd
2018-01-23 07:55:43 +01:00
2018-04-22 05:44:44 +02:00
"make regex a bit easier to type
set magic
set hidden
2018-01-23 07:55:43 +01:00
2018-04-22 05:44:44 +02:00
"always display status line
set laststatus = 2
2018-01-23 07:55:43 +01:00
2018-04-22 05:44:44 +02:00
"keycodes time out fast, mappings have a bit longer
set timeout timeoutlen = 1000 ttimeout ttimeoutlen = 10
2018-01-23 07:55:43 +01:00
2018-04-22 05:44:44 +02:00
"make it so the session feature wont overwrite our vimrc if the vimrc has newer bindings than this session.
set sessionoptions - = options
2018-01-23 07:55:43 +01:00
"tab stuff
2018-04-22 05:44:44 +02:00
set tabstop = 4
set shiftwidth = 4
set autoindent
2018-01-23 07:55:43 +01:00
"highlighting/colour stuff
2018-04-22 05:44:44 +02:00
"sets the colorscheme. to get a list of the available colors, do :colorscheme <Space> <C-d>
colorscheme ron
2018-01-23 07:55:43 +01:00
2018-04-22 05:44:44 +02:00
syntax enable
2018-01-23 07:55:43 +01:00
2018-04-22 05:44:44 +02:00
"highlight search results
set hlsearch
2018-01-23 07:55:43 +01:00
2018-04-22 05:44:44 +02:00
"search as you type
set incsearch
2018-01-23 07:55:43 +01:00
2018-04-22 05:44:44 +02:00
"<leader> L clears the search highlighting
noremap < leader > l :nohls < Enter >
2018-01-23 07:55:43 +01:00
"folding stuff TODO: implement other folding methods.
2018-04-22 05:44:44 +02:00
"give a bit of margin space for fold number
set foldcolumn = 3
set foldenable
"set the minimum number of screen lines for a fold to be closable.
set foldminlines = 3
"spacebar opens or closes a fold in normal mode
nmap < Space > za
"insert folding: really basic fold method. eventually I may make some custom folds, but with the foldtext fixed a bit, this shouldn't annoy me too much.
if foldtype = = # "basicindent"
"make vim fold automatically based on indentation.
set foldmethod = indent
"set the fold text for this method, in most cases, the line just above our fold is what we want, so we wont put any text into it. just level and linecount.
function ! Minimal_foldtext ( )
let lines_count = v :foldend - v :foldstart + 1
let lines_count_text = '| ' . printf ( "%10s" , lines_count . ' lines' ) . ' |'
let line_level_text = '| ' .printf ( "%5s" , 'level ' .v :foldlevel ) .' |'
let foldchar = matchstr ( &fillchars , 'fold:\zs.' )
let foldtextstart = lines_count_text
let foldtextend = line_level_text . repeat ( foldchar , 8 )
let foldtextlength = strlen ( foldtextstart . foldtextend ) + &foldcolumn
return foldtextstart . repeat ( foldchar , winwidth ( 0 ) - foldtextlength ) . foldtextend
endfunction
set foldtext = Minimal_foldtext ( )
endif
2018-01-23 07:55:43 +01:00
2018-02-17 23:39:46 +01:00
"useful keybinds
2018-04-22 05:44:44 +02:00
"spell checking
"toggle spell checking
map < leader > ss :setlocal spell ! < Enter >
"splitting pannes with <leader>| or -
nmap < leader > \| :vs < Enter >
nmap < leader > \- :sp < Enter >
" shortcuts using leader
" noremap <leader>sn ]s
" noremap <leader>sp [s
" noremap <leader>s? z=
"navigating splits: Control+hjkl will move from split to split
nmap < C - h > < C - w > h
nmap < C - j > < C - w > j
nmap < C - k > < C - w > k
nmap < C - l > < C - w > l
"command mode keybinds
"w!! writes using sudo
"cnoremap w!! w !sudo tee % >/dev/null