My end goal is trying to make directory navigation in Vim easier, preferably without a plugin.
What I have so for in my .vimrc
:
nmap <m-up> :cd ..<enter>:pwd<enter>
nmap <m-left> :cd -<enter>:pwd<enter>
nmap <m-down> :cd <tab>
The first two commands work great. I can easily go up/back a directory. The intention of the third command is to quickly get to a set of options that I can tab/arrow-key through to the desired subdirectory. However, the result is:
:cd ^I
i.e. it's putting in a tab/ctrl-I char instead of simulating the tab key press, which is the result I want. I have other commands that use <esc>
,backspace
etc and they all work as desired, but <tab>
is different. Any suggestions (besides just hitting tab after my macro)?
You need to set the wildcharm
option for that:
set wildcharm=<C-z>
nnoremap <m-down> :cd <C-z>
See :help wildcharm
.
I think it can't "Tab" as you expect it to, because it is interpreting it as part of the vim command, rather than an input for the (bash?) shell. My guess would be to map it to something along the lines of this, if you want to see what is in the working directory:
nnoremap <m-down> :!pwd
The no
in nnoremap
is to prevent any mapping from happening in the reverse direction, kind of a habit that you might want to get into. This will display what is currently in the directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With