NERDTree go to a directory - vim

I'm familiar with the C command to cd into a visible directory. What if I just want to go into a random directory and set that as the cd, something like:
C ~/.ssh
How would I do that in NERDTree?

Related

VIM is not working as expected with relative path address of a file

Let's say I am in my directory ~/bin and I want to open a file which is in ~/mySetting/commands.txt.
So, from the terminal when I enter vim ../mySetting/commands.txt, vim opens it as a new directory. But when I enter the full path like vim ~/mySetting/commands.txt, It opens it as expected.
Does VIM not work with relative path??
Or
It's possible if ~/bin is a symlink to somewhere deeper in the hierarchy. For example, if ~/bin is a symlink to ~/.local/share/bin then ../mySetting/commands.txt would be ~/.local/share/mySetting/commands.txt.
To test: ls -l ~/bin and cd ~/bin && pwd -P && ls -l ../mySetting/commands.txt

NERDTree command automatically change directory and root directory

Is it possible that whenever I select a directory and enter that directory from the NERDTree it should become the root directory? That is, every time I select a new directory the following two commands will be triggered: cd and :NERDTreeCWD?
Thanks!
set in your vimrc: let g:NERDTreeChDirMode = 2
The NERDTree provides two mappings you could use manually to get this effect: Typing cd on a node changes the directory to it, and typing C on a node, "enters" it via the NERDTree.
Personally, I often combine them -- just type Ccd -- the C will enter the directory and leave the cursor on it, and a cd will change the working directory to it.
Now, if you do want to create just one mapping to use directly, you could use the NERDTree's extension mechanism. Read up on :help NERDTreeAPI for the details, but the short version is: put a file in ~/.vim/nerdtree_plugin/cd_mapping.vim with the following contents:
call NERDTreeAddKeyMap({
\ 'key': '_C',
\ 'callback': 'NERDTreeEnterDirectoryAndCD',
\ 'quickhelpText': 'Enter directory and cd into it' })
function! NERDTreeEnterDirectoryAndCD()
let node = g:NERDTreeDirNode.GetSelected()
exec 'cd ' . node.path.str({'format': 'Cd'})
NERDTreeCWD
endfunction
This should do the trick with the keybinding _C. Change the key property to whatever you'd like the key to be.
cd CD ( cd -> changes pwd/cwd and CD -> sets tree root to pwd/cwd)

How to go to another directory sharing same parent directory?

I am beginner in linux and wondering about a shorter way to go a directory having same parent directory. Here I elaborate that.
dir1
- dir11
- dir12
- dir13
- dir14
Directory dir1 has sub-directories dir11,...,dir14. I am at directory dir13 and want to go to dir12. What is direct way to do this?
I can do
cd..
cd dir12/
But I am wondering whether I can do this in single step. Any ideas?
cd doesn't only take one directory to change to. You can provide a complete path to which you want to go.
You can simply type cd ../dir12
You can also go all nuts with cd ../dir12/../dir13/../dir14/..
Try also the following: type cd ..<press Tag twice>. This will list you all directories in the path you have given.
There are wildcards that cd can use. For example ~ is your home directory. cd ~ or just cd will change into your $HOME.
See man cd (in a terminal) for more.

Why does "cd -" behave as it does?

What does cd - exactly do ? ( the change directory command, plus a dash )
I noticed that if I run it in my /home/user folder repeatedly it outputs either /home/user or /home, this changes if I run it from a different folder.
cd -
pop the last directory you were from the stack of directory. It's like hitting "back" on the browser.
Exemple :
you are in /user/alex
you can test that with :
pwd
that give you
/user/alex
then if you do
%cd project1/subfolder
%pwd
/user/alex/project1/subfolder
%cd subsubfolder
%pwd
/user/alex/project1/subfolder/subsubfolder
%cd -
pwd
/user/alex/project1/subfolder
cd -
pwd
/user/alex
NB : it's not going back a level upper in the folder hierarchy. it's going to the previous current folder. ( a level upper is cd .. ).
The syntax
cd -
allows you to switch back to the "last directory you were in when you changed to the current directory". Running the command twice allows you to switch back to the current directory (since the current directory would then become the "last directory you were in when you changed to the current directory").
This is very useful if you are in a very long directory which you don't want to type out over and over, and you go to another lengthy named directory. Instead of retyping it, you can just do a 'cd -', which is similar to how some people use the alt-tab (or command-tab) to switch between applications. This key combo shortcut lets you essentially toggle between the last two applications.
cd stands for Change Directory
It is used to navigate arond your folders
So if you're in /home/user and have a folder in that directory called 'top-secret', you would access it by typing:
cd /top-secret

Add tomorrow-theme to janus (macvim)

How do I add the tomorrow theme to Janus in MacVim?
https://github.com/chriskempson/tomorrow-theme
What are the steps?
You can copy the theme's vim folder into the ~/.janus folder, as explained in the Customization wiki page of Janus. It would be a good idea to give the vim folder a more descriptive name e.g. tomorrow-theme.
For example, assuming you've got your local copy (clone) of tomorrow-theme at <path_to_tomorrow_theme>, you could do
$ cd ~/.janus
$ mkdir tomorrow-theme
$ cp -R <path_to_tomorrow_theme>/vim/ tomorrow-theme
Note the slash / at the end of the path to the vim folder.
Start by reading the documentation. After that, copy the files from github/vim into ~/.vim directory.
I guess there's multiple ways of doing this.
I cd'ed into:
.vim/janus/vim/colors
I created tomorrow-theme folder and cd'ed into that:
.vim/janus/vim/colors/tomorrow-theme
In the tomorrow-theme folder I create colors directory
.vim/janus/vim/colors/tomorrow-theme/colors
And that's where I paste the downloaded .vim themes
Tomorrow-Night-Blue.vim Tomorrow-Night-Bright.vim Tomorrow-Night-Eighties.vim Tomorrow-Night.vim Tomorrow.vim

Resources