" Neovim init file for Harald Eilertsen " filetype on syntax on colorscheme nord "substrata set number filetype indent on set nowrap set tabstop=2 set shiftwidth=2 set expandtab set smartindent set autoindent set guioptions-=T set statusline=%q%m%r\ %f%=%y\ %c,%l/%L\ %{FugitiveStatusline()} " highlight cursor line set cursorline " highlight search matches set hlsearch " show matching parenthesis/brackets set showmatch " remove whitespace on write autocmd BufWritePre * :%s/\s\+$//e " press esc to cancel search noremap :nohlsearch:echo " Arrow keys move visually up/down. noremap gk noremap gj " toggle nerdtree with ctrl-o map :NERDTreeToggle " Toggle word-wrap mode " This will also fix movement keys so they move by visual " lines instead of physical lines in word-wrap mode. " See https://vim.fandom.com/wiki/Move_cursor_by_display_lines_when_wrapping noremap w :call ToggleWrap() function ToggleWrap() if &wrap echo "Wrap OFF" setlocal nowrap set virtualedit=all silent! nunmap silent! nunmap silent! nunmap silent! nunmap silent! iunmap silent! iunmap silent! iunmap silent! iunmap else echo "Wrap ON" setlocal wrap linebreak nolist set virtualedit= setlocal display+=lastline noremap gk noremap gj noremap g noremap g inoremap gk inoremap gj inoremap g inoremap g endif endfunction " Suppress excessive tex errors let g:tex_no_error=1 function SaveSession() if !empty(v:this_session) echo "Saving session " . v:this_session execute "mksession! " . v:this_session endif endfunction autocmd VimLeave * :call SaveSession() :nmap :wacall SaveSession():so ~/.vim/sessions/