Thursday, April 23, 2015

Autocmd to have a mapping only for a specific file

Hi,

I try to have an autocommand that would provide a mapping to the <enter> and <c-enter> keys only on a certain file name. Like myfile.txt for example.

I have tried a test like this here, and it works for the <c-Enter> mapping but not for the <Enter> one:

autocmd! BufNewFile,BufRead,BufEnter myfile.txt nmap <buffer> <Enter> :echo 'Hi!'<cr>
autocmd! BufNewFile,BufRead,BufEnter myfile.txt nmap <buffer> <c-Enter> :echo 'Test!'<cr>

And when I do :map <enter> vim says that there are "No mapping found"

Any ideas why? And please tell me if I chose the right list of events.

Thank you very much,

Alexandre

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: