I want to be able to highlight lines I want to indent/reverse-indent and indent with tab and shift-tab respectively.
" for command mode reverse tab
nmap <S-Tab> <<
" for insert mode reverse tab
imap <S-Tab> <Esc><<i
" for command mode multiple line reverse tab(doesn't work)
nmap <Tab> i<
" for insert mode multiple line reverse tab(doesn't work)
imap <Tab> <
" for command mode tab
nmap <Tab> >>
" for command mode multiple line tab(doesn't work)
nmap <Tab> i>
" for insert mode multiple line tab(doesn't work)
imap <Tab> >
This is the last thing I need before I'm willing to use vim as my primary editor.
If you prefer using [spacebar] to indent your code rather than using [tab], you can select multiple lines by holding the [alt] key and clicking on the beginning of each line you want to indent. Then, you can press [spacebar] and all the selected lines will be affected. omg it moves!
In normal mode, press Tab or Shift-Tab to adjust the indent on the current line and position the cursor on the first nonblank character; in insert mode, press Shift-Tab to unindent; in visual mode, press Tab or Shift-Tab to adjust the indent on selected lines.
To indent the current line, or a visual block: ctrl-t, ctrl-d - indent current line forward, backwards (insert mode) visual > or < - indent block by sw (repeat with . )
In visual mode,
To select and highlight your text, you need to start using visual mode, (I usually do this by hitting v, or if coming from insert mode: Escv) and select your text using the standard motions (such as h, j, k and l) .
If you do not want to use the default shortcuts < and >, create mappings for use in visual mode. You need :vmap
:
:vmap <Tab> >
:vmap <S-Tab> <
which would mean pressing
But why do you need to create a mapping for this?
Sometimes it's better just to learn the Vim (or even Vi) keys (and < and > are easy anyway), and then you can use any installation, not just the one with your .vimrc
.
For instance, you've put:
imap <Tab> <
This is a bad idea. This will make it harder for you to insert a tab-character into your text (even ctrl+i won't work as I'd expect), and every time you type tab you'll insert a <
.
Happy editing!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With