Navigation tab navigation not working

NOTE . I am using Terminator instead of terminal. But since all the other mappings work fine why they don't work.

I tried to use these mappings in my vimrc file to be able to use Tab Navigation. But it doesn't work at all.

nnoremap <C-S-tab> :tabprevious<CR>
"nnoremap <C-tab>   :tabnext<CR>
nnoremap <C-tab> :tabn<CR>     "I also tried this
nnoremap <C-t>     :tabnew<CR>
inoremap <C-S-tab> <Esc>:tabprevious<CR>i
inoremap <C-tab>   <Esc>:tabnext<CR>i
inoremap <C-t>     <Esc>:tabnew<CR>
inoremap <C-S-w>   <Esc>:tabclose<CR>

      

"Also go to the nth tab Use <A-Fn>

nnoremap <A-F1> 1gt
nnoremap <A-F2> 2gt
nnoremap <A-F3> 3gt
nnoremap <A-F4> 4gt
nnoremap <A-F5> 5gt
nnoremap <A-F6> 6gt
nnoremap <A-F7> 7gt
nnoremap <A-F8> 8gt
nnoremap <A-F9> 9gt
nnoremap <A-F10> 10gt 

      

NOTE . I have ctags and cscope installed . Therefore, I think that there may be some difficulty, since it ctrl-t

is a transition from a certain tag. And only this display works for a new tab.

Also I checked it ctrl-PageDown

works perfectly for the same purpose.

Second question:

How does this key notation work in vimrc. It's something like this:

  • All modifier keys must be used in Caps as

    • C for Ctrl.
    • A for Alt.
    • S for Shift.
  • And other keys are all in small.

But what about keys like:

  • home
  • the end
  • Backspace
  • Escape
  • PageUp
  • PageDown
  • Tab
  • Function keys, etc.

How do I use them?

Here I read that they should be used when mapping, but even they used tab instead of Tab in mappings.

+3


source to share


2 answers


Prepare to be disappointed.

Terminal Key Codes

Vim accepts terminal keycodes, so not all key combinations are possible. The best way to find out which keys are recognized is to open insert mode and press ctrl+ vfollowed by a key combination. This will show you the raw codes. Do this for a different keyboard shortcut. If the source codes are the same, then Vim cannot distinguish between them. for example ctrl+ v ctrl+ shift+ tab.

Your comparisons

You should probably avoid insert mode mappings to switch tabs. It's just not the Vim Way, as insert mode should only be used on short bursts.

Your mappings :tabprev

and :tabnext

can be simplified in mappings gT

and gT

. Personally, I don't mind the default mappings gT

or gT

.

<key>

designation



As far as I know, it doesn't matter. All my collations are lowercase. <>

See the section for a list of notations :h key-notation

.

You are using it correctly <c-..>

for control, <a-...>

for alt and <s-...>

for changing. An approximate combination will be <c-s-space>

. Note: most <c-s-...>

mappings will fail.

Using tabs

Vim's tabs are not like most text editors. They are more like viewports in a group of windows / sections. Also, Vim has a buffer orientation and not a tab like most editors. For example, using features like Vim quickfix is ​​often easier without tabs (see :h 'switchbuf

if you should use tabs). Vim tabs often get in the way of using splits as more convenient windows and buffered navigation commands are available. I personally have a lot of files open (sometimes 100+) without using tabs and using 1-2 sections on average without any problem.

The bottom line: Learn to use buffers effectively .

Conclusion

I would advise you to quickly break up your workflow in a tab and learn to love buffers. You don't really need your juxtapositions, and you won't be working against Wim's nature.

+3


source


Read :help key-notation

for an explanation ... Vim Key Symbols.


It's generally a good idea to play it safely, so I recommend following these conventions when matching combos:

  • always capitalize the modifier key, C

    for Control

    , S

    for Shift

    , A

    for Alt

    , D

    for Command

    (MacVim GUI only), M

    for Meta

    ,

  • always use a lowercase letter for alphabetic keys abc…xyz

    ,

  • always uppercase the first letter of the "special" keys Tab

    , Space

    , Up

    etc.

Examples:

<S-Up>
<C-r>
<A-LeftMouse>

      

However, the following notation works as well as any other notation, try to be consistent:

<s-UP>

      


Using multiple modifiers in the same mapping doesn't work reliably, so you'll be better off in the long run if you avoid them entirely.



nnoremap <C-S-j> :echo "csj"<CR>
nnoremap <C-j>   :echo "cj"<CR>

      

now press <C-j>

and <C-S-j>

in normal mode.


<C-S-w>

indistinguishable from <C-w>

.


:verbose map <C-t>

      

shows you what is being mapped to <C-t>

and where the mapping happened. You can use it to debug your mappings.


And I agree with Peter, you are using both tab pages and inserting the mode incorrectly.

+1


source







All Articles