map <leader>t :tabnew<cr>
You can also map t to open a new tab using the selected text as a filename. You just need to define two mappings:
nmap <leader>t :tabnew<cr>
vmap <leader>t :call Foo()<cr>
nmap stands for normal (mode) map, vmap for visual. How to get the text under the cursor is a bit more complex and out of scope for this vim tip, but you might want to check http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_%28Part_1%29.
Remember to check ":help map" for a list of all mode mappings.
[…] grep to vim. We can improve it a little bit with very simple changes. Using this tip to have different key binding for different modes we can do something a bit smarter . Let’s create two functions, one for normal mode that […]
ReplyDelete