Skip to content

Commit 238b875

Browse files
committed
Experimental: map S-Tab to delete one indent
Seems friendly (similar to vsode 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
1 parent 99c5f68 commit 238b875

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

plugin/friendly.vim

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ vnoremap < <gv
269269
vnoremap <Tab> >gv
270270
vnoremap <S-Tab> <gv
271271
272+
" Allow Shift+Tab to delete one shiftwidth of indent (aka "outdent")
273+
" Seems friendly (similar to vscode and some other editors), and harmless
274+
" (Shift+Tab is not mapped by default in insert mode, does same as Tab)
275+
inoremap <S-Tab> <C-d>
276+
272277
" Allow basic windows style editing shortcuts. Copied from mswin.vim but
273278
" implements fewer shortcuts, in fewer modes, to avoid breaking things like
274279
" CTRL-A/CTRL-X to add/subtract numbers and CTRL-V for visual block mode.
@@ -442,7 +447,8 @@ function! <SID>SimpleTab()
442447
endif
443448
endfunction
444449
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : <SID>SimpleTab()
445-
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
450+
" FIXME: remove duplication, trigger existing S-Tab map when pum not visible
451+
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<C-d>"
446452
" Experimental: map CR to accept completion, should be safe enough assuming
447453
" friendly.vim is loaded before other plugins which may otherwise map CR.
448454
" Some plugins might skip adding their own CR mapping if one exists, which

0 commit comments

Comments
 (0)