The line necessary to map the leader is this:
let mapleader = "\\"
In this case, the leader is set to '\' (the other backslash is to escape that one so it doesn't escape the quote). This is the default, but you may have to explicitly use this. That's what I had to do. Even if you don't, it's probably good to put that in your vimrc file so you know you can always count on it. Also note that the leader doesn't have to be '\'. In fact, many people use '_'.
Here are some useful leader commands. As you can see, they are things you might see yourself doing frequently, and much easier, with the help of the leader. You can copy and paste this directly into your vimrc or into the command mode in Vim. For those of you that don't know, the quotes represent comments.
" Tab commands using the leader
map <leader>tn :tabnew<cr>
map <leader>tc :tabclose<cr>
map <leader>tx :tabnext<cr>
" NERDTree shortcut
map <leader>nt :NERDTree<cr>
" Shortcut for opening vimrc
map <leader>rc :sp ~/.vimrc<cr>
NERDTree is a plugin that closely resembles the tree-like file browser in things like TextMate or Aptana Studio. I'll talk more about this one later. Also, some of you may be unfamiliar with tabs. But don't fret! I'll also talk about that in another post.
Please, post any requests for tutorials, tips, tricks, or anything you can think of. I'd be more than happy to talk about them!
No comments:
Post a Comment