scriptencoding utf-8 " TODO: " Make a mapping that I like for helpclose " Make a better mapping to jump back to last buffer " This is where most of my basic keymapping goes. " " Plugin keymaps will all be found in `./after/plugin/*` nnoremap nnoremap " Switch between tabs nnoremap gt nnoremap gT inoremap :echom "--> k <-- " inoremap :echom "--> j <-- " inoremap :echom "--> l <-- " inoremap :echom "--> h <-- " " Opens line below or above the current line inoremap o inoremap O " call describe("mode", "remap", ...) " idescribe " description. " inoremap my mapping here other stuff """ asdf " inoremap asdf my mapping here other stuff " \ asdf " Set kj to be escape in insert mode inoremap kj " For long, wrapped lines nnoremap k gk " For long, wrapped lines nnoremap j gj " For moving quickly up and down, " Goes to the first line above/below that isn't whitespace " Thanks to: http://vi.stackexchange.com/a/213 nnoremap gj :let _=&lazyredraw:set lazyredraw/\%=virtcol(".")v\S:nohl:let &lazyredraw=_ nnoremap gk :let _=&lazyredraw:set lazyredraw?\%=virtcol(".")v\S:nohl:let &lazyredraw=_ " Run the last command nnoremap c : " Map execute this line function! s:executor() abort if &ft == 'lua' call execute(printf(":lua %s", getline("."))) elseif &ft == 'vim' exe getline(">") endif endfunction nnoremap x :call executor() vnoremap x :exe join(getline("'<","'>"),'') nnoremap v :w:Vader % " Execute this file function! s:save_and_exec() abort if &filetype == 'vim' :silent! write :source % elseif &filetype == 'lua' :silent! write :luafile % endif return endfunction nnoremap x :call save_and_exec() " Remove whitespace nnoremap sws :%s/\s\+$// " Easier Moving between splits nnoremap nnoremap nnoremap nnoremap " Make windows to be basically the same size nnoremap = = " Sizing window horizontally nnoremap < nnoremap > nnoremap 5< nnoremap 5> " Sizing window vertically " taller nnoremap + " shorter nnoremap - " Move easily to the next error nnoremap l :lnext nnoremap h :lprevious " Fun C to write the result of a command at the end of the function " function signature nnoremap fs ^yt{$%"_ddI} /* pa*/ " Get autoload names easily imap au auto,e " Undo toggle nnoremap ut :GundoToggle " Random number into vim inoremap nr :py import vim, random; vim.current.line += str(random.randint(0,9))A " Helpful delete/change into blackhole buffer nmap d "_d nmap c "_c nmap d "_d nmap c "_c " Change the working directory for everybody nnoremap cd :windo lcd if has('nvim') " Make esc leave terminal mode tnoremap tnoremap " Easy moving between the buffers tnoremap h tnoremap j tnoremap k tnoremap l nnoremap h nnoremap j nnoremap k nnoremap l " Try and make sure to not mangle space items tnoremap tnoremap endif " Clears hlsearch after doing a search, otherwise just does normal stuff nnoremap {-> v:hlsearch ? ":nohl\" : "\"}() if v:false " TODO: Explore why I wrote this for someone and why I thought it was good. augroup complete_tab_search autocmd! autocmd CmdlineEnter /,\? :set incsearch autocmd CmdlineLeave /,\? :set noincsearch autocmd CmdlineEnter /,\? :cnoremap autocmd CmdlineLeave /,\? :cunmap augroup END endif " Change the current word in insertmode. " Auto places you into the spot where you can start typing to change it. nnoremap w :%s///g nnoremap :let v:hlsearch=!v:hlsearch nnoremap J :call tj#join_lines() " Shrug ¯\_(ツ)_/¯ inoremap ,shrug ¯\_(ツ)_/¯ " My own modeline nnoremap m :call execute(substitute(getline('.'), '.*vim', '', '')) nnoremap n :normal! " Basically commandline fixes for fat fingering cnoremap %:H %:h " But really I should use these instead cnoremap %H =expand('%:h:p') . std#path#separator() cnoremap %T =expand('%:t') cnoremap %P =expand('%:p') cnoremap E e