Skip to content

Commit

Permalink
Experimental: map S-Tab to delete one indent
Browse files Browse the repository at this point in the history
Seems friendly (similar to vscode and other editors), harmless (doesn't
seem to break anything as S-Tab normally acts same as Tab), and plays
nicely with visual mode S-Tab mapping to shift selection leftwards.

Idea from @samjwill, see tpope/vim-sensible#173

FIXME: make pumvisible() aware expr map trigger any existing S-Tab map
  • Loading branch information
mmrwoods committed Jun 21, 2023
1 parent 99c5f68 commit 73c3e19
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion plugin/friendly.vim
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ vnoremap < <gv
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv
" Allow Shift+Tab to delete one shiftwidth of indent (aka "outdent")
" Seems friendly (similar to vscode and some other editors), and harmless
" (Shift+Tab is not mapped by default in insert mode, does same as Tab)
inoremap <S-Tab> <C-d>
" Allow basic windows style editing shortcuts. Copied from mswin.vim but
" implements fewer shortcuts, in fewer modes, to avoid breaking things like
" CTRL-A/CTRL-X to add/subtract numbers and CTRL-V for visual block mode.
Expand Down Expand Up @@ -442,7 +447,8 @@ function! <SID>SimpleTab()
endif
endfunction
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : <SID>SimpleTab()
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" FIXME: remove duplication, trigger existing S-Tab map when pum not visible
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<C-d>"
" Experimental: map CR to accept completion, should be safe enough assuming
" friendly.vim is loaded before other plugins which may otherwise map CR.
" Some plugins might skip adding their own CR mapping if one exists, which
Expand Down

0 comments on commit 73c3e19

Please sign in to comment.