Reputation: 847
I’m looking for a way to add a custom command or alias to my vimrc to quickly change to different directories within Vim. I had something set up once, but lost that config. This is for a Linux setup.
Basically, I want to set an alias (all-lowercase, if possible; Vim seems to want custom commands to start with an uppercase letter) such as:
:cdscripts
and have the result be the same as typing:
:cd /home/username/.../Scripts
I have used NERDTree, but am looking for something a little bit faster. I have also tried these:
CommandAlias : Make aliases to vim command
but can’t quite get the results I’m looking for. Is this possible?
Upvotes: 2
Views: 1977
Reputation: 1478
I wrote an alias manager doing these thing easily. - aliasme
you can add, remove or jump to declare path you want.
Three step to install
mkdir ~/.aliasme
curl https://raw.githubusercontent.com/Jintin/aliasme/master/aliasme.sh > ~/.aliasme/aliasme.sh
echo "source ~/.aliasme/aliasme.sh" >> [~/.bash_profile (or any login script: bash_rc)]
After install, you can use all these function
See https://github.com/Jintin/aliasme for more information
Upvotes: -1
Reputation: 172540
A custom command is very easy:
:command Cdscripts cd /home/username/.../Scripts
To avoid clashes with built-in commands, these must start with an uppercase letter. You can use the plugin linked in your question or cmdalias.vim - Create aliases for Vim commands to create a lowercase alias:
:Alias cdscripts Cdscripts
Upvotes: 4