" File : keybindings.vim " Author : Jeff LANCE " Date : 15.04.2015 " Last Modified Date: 24.06.2020 " Last Modified By : Jeff LANCE """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " _ _________ ______ ___ _ _ ____ ___ _ _ ____ ____ " | |/ / ____\ \ / / __ )_ _| \ | | _ \_ _| \ | |/ ___/ ___| " | ' /| _| \ V /| _ \| || \| | | | | || \| | | _\___ \ " | . \| |___ | | | |_) | || |\ | |_| | || |\ | |_| |___) | " |_|\_\_____| |_| |____/___|_| \_|____/___|_| \_|\____|____/ " """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Custom {{{ " ----- " Disable highlights when you press : map :noh " Enable folding with the spacebar nnoremap za " Source current file map s :echom 'Source file' :so % " Two semicolons to escape imap ;; " Open a current file with sudo " map E :e suda://% " Save a current file with sudo " map W :w suda://% " Comment the target of a motion map / :Commentary " Indent line map >> map << " (Re|Un)do map uu " Save as map :saveas " ----- " }}} " Buffers {{{ " ----- command! -bang -nargs=? -complete=dir Files \ call fzf#vim#files( \ , \ fzf#vim#with_preview( \ {'options': ['--layout=reverse', '--info=inline']} \ ), \ 0 \ ) map :echom 'Close buffer' :call BufClose() map :e map :Startify map :bn map :bp " ----- " }}} " Windows {{{ " ----- map :call WinMove('h') map :call WinMove('j') map :call WinMove('k') map :call WinMove('l') " ----- " }}} " Tabs {{{ " ----- "map tn :tabnew :Startify "map tc :tabclose "map :tabnext "map :tabprev " ----- " }}} " COC {{{ " ----- " Use tab for trigger completion with characters ahead and navigate. " NOTE: Use command ':verbose imap ' to make sure tab is not mapped by " other plugin before putting this into your config. inoremap \ pumvisible() ? "\" : \ check_back_space() ? "\" : \ coc#refresh() inoremap pumvisible() ? "\" : "\" " Use to confirm completion, `u` means break undo chain at current " position. Coc only does snippet and additional edit on confirm. " could be remapped by other vim plugin, try `:verbose imap `. if exists('*complete_info') inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" else inoremap pumvisible() ? "\" : "\u\" endif " Use to trigger completion. if has('nvim') inoremap coc#refresh() else inoremap coc#refresh() endif " Use `[g` and `]g` to navigate diagnostics " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. nmap [g (coc-diagnostic-prev) nmap ]g (coc-diagnostic-next) " GoTo code navigation. nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) " Use K to show documentation in preview window. nnoremap K :call show_documentation() " Symbol renaming. nmap rn (coc-rename) " Formatting selected code. xmap f (coc-format-selected) nmap f (coc-format-selected) " ----- " }}} " Defx {{{ " ----- map :Defx function! s:defx_toggle_tree() abort " Open current file, or toggle directory expand/collapse if defx#is_directory() return defx#do_action('open_or_close_tree') endif return defx#do_action('drop') endfunction autocmd FileType defx call s:defx_my_settings() function! s:defx_my_settings() abort " Define mappings " nnoremap defx#do_action('drop') nnoremap \ defx#is_directory() ? \ defx#do_action('open_directory') : \ defx#do_action('multi', ['drop', 'quit']) nnoremap c \ defx#do_action('copy') nnoremap m \ defx#do_action('move') nnoremap p \ defx#do_action('paste') nnoremap l \ defx#do_action('open') nnoremap E \ defx#do_action('open', 'vsplit') nnoremap P \ defx#do_action('open', 'pedit') nnoremap o \ defx#do_action('open_or_close_tree') nnoremap K \ defx#do_action('new_directory') nnoremap N \ defx#do_action('new_file') nnoremap M \ defx#do_action('new_multiple_files') nnoremap C \ defx#do_action('toggle_columns', \ 'mark:indent:icon:filename:type:size:time') nnoremap S \ defx#do_action('toggle_sort', 'time') nnoremap d \ defx#do_action('remove') nnoremap r \ defx#do_action('rename') nnoremap ! \ defx#do_action('execute_command') nnoremap x \ defx#do_action('execute_system') nnoremap yy \ defx#do_action('yank_path') nnoremap . \ defx#do_action('toggle_ignored_files') nnoremap ; \ defx#do_action('repeat') nnoremap h \ defx#do_action('cd', ['..']) nnoremap ~ \ defx#do_action('cd') nnoremap q \ defx#do_action('quit') nnoremap \ defx#do_action('toggle_select') . 'j' nnoremap * \ defx#do_action('toggle_select_all') nnoremap j \ line('.') == line('$') ? 'gg' : 'j' nnoremap k \ line('.') == 1 ? 'G' : 'k' nnoremap \ defx#do_action('redraw') nnoremap \ defx#do_action('print') nnoremap cd \ defx#do_action('change_vim_cwd') endfunction " ----- " }}} " FZF {{{ " ----- map :Files " ----- " }}} " Header {{{ " ----- map :AddHeader " ----- " }}} " Plug {{{ " ----- map Pud :PlugUpdate map Pug :PlugUpgrade map Pui :PlugInstall " ----- " }}} "" REPL {{{ "" ----- " "nnoremap rp :REPLToggle "autocmd Filetype python nnoremap :REPLDebugStopAtCurrentLine "autocmd Filetype python nnoremap :REPLPDBN "autocmd Filetype python nnoremap :REPLPDBS " "" ----- "" }}} " Vimroom {{{ " ----- nnoremap z :Goyo " ----- " }}} " Vimux {{{ " ----- map vp :VimuxPromptCommand " map vr :VimuxRunCommand " map vo :VimuxOpenRunner " ----- " }}} " Functions {{{ " ----- " Renaming map r :call RenameFile() " Open file under cursor map o :call GotoFile("") map ' ciw''P map " c""P map [ c[]P map { c{}P " Rewrap paragraph using map {gq}:echo "Rewrapped paragraph" " Git map Gs :Git status map Ga :Git add map Gc :Git commit " ----- " }}} " vim:ft=vim