Quantcast
Channel: BufRead,BufNew keymaps modify current buffer instead of opened buffer in Neovim and Vim - Stack Overflow
Viewing all articles
Browse latest Browse all 2

BufRead,BufNew keymaps modify current buffer instead of opened buffer in Neovim and Vim

$
0
0

I can't scratch my head around why my keymaps in C++ file buffer are getting overwritten by rules for in file. I though BufRead executes after opening new file, right?

I have the following vimrc configuration:

autocmd FileType cpp    \  nnoremap <buffer> <f5> :up<cr>:!g++ -Wall -Wextra -Wshadow -Wno-sign-conversion -O2 -o a.out % && ./a.out < in<cr>    \| nnoremap <buffer> <f6> :split in<cr>autocmd BufRead,BufNew in    \  nnoremap <buffer> <f5> :up<cr>:!./a.out < in<cr>    \| nnoremap <buffer> <f6> :wq<cr>    \| echom "in file loaded " . winbufnr(0)

Output in vim after F6 (:mess):

in file loaded 1in file loaded 2

Output in Nvim after F6:

in file loaded 1

There is no output before pressing F6.

When I open file in from test.cpp (either through F6 or direct :sp), C++ keymaps are no longer there, from test.cpp:

:nnoremap <buffer>n  <F6>        *@:wq<CR>                                               n  <F5>        *@:up<CR>:!./a.out < in<CR>

My other F5 keymaps for other files are working just fine. Any help is appreciated


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>