Vim - how to browse using vim, leave and stay in browsed location - vim

I've spent some time of searching internet and vim man with no luck.
After vim . I'd like to browse in vim and be able to leave and stay in given location in terminal. Is there any possibility to achieve that?

I think this link is your answer If you want to change shell directory from vim.

Related

Open Specific Drive Using Netrw Vim

I am using Vim80 on Windows 10. Using Netrw command , by default it will open up my %HOME% path. I want to open specific disk drive on my computer like F: using netrw. I have searched through similar questions on Stack Overflow and found answers like using :Ex F: or :cd F:\ but it does not change the default directory. What is the netrw vim command that will enable me to change the drive I am working on?
You are searching for the wrong thing, Netrw has no default directory, it just opens your active directory.
So if you open a cmd navigate fo F: and then run vim, you will have what you want.
But i know that is not the workflow in windows. so you can change the "starting directory" properity on the shortcut to your vim.
right click on vim Icon -> property/shortcut/Start in
as Doktor OSwaldo stated Netrw doesn't have a default directory. However an alternative approach i've used sometimes is to clone my Vim shortcut by going to the file location:
Then cloning the shortcut under a new name:
Then i simply enter the directory (or drive) i want vim to open with netrw by default, like so:
Then i can find vim in the windows menu easily:
Which allows me to start up my vim instance like this:
I tend to do this per project which gives me nice project oriented searching available from the windows menu. Anyway, i hope this helps although i understand it was slightly different to what you wanted ideally. If i were you i would create a shortcut per drive so you could search vim and see results like:
vim
vim-f-drive
vim-c-drive
vim-d-drive

Editing _vimrc in Windows

I am having some trouble with VIM on windows, and I was wondering if anyone could be of assistance. As of right now, I am trying to make it so that when VIM starts, it changes it's working directory to one besides the default (C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Vim 7.3). The way I am going about this is adding in cd $HOME\Desktop\VimFiles, where $HOME is C:\Users\Alphabet (Alphabet is the name of my account).
The issue I am running into right now is that after opening up _vimrc and adding in the line stated above, I cannot save the file, even when forcing it (with w!). I was wondering why this is and how I can go about fixing this. As an added note, I am running this in GVIM.
Note: I have attempted to do the same thing in VIM, and am able to edit the _vimrc file fine, but when I go to it's location and open it with GVIM or Notepad++, the "cd" line doesn't show up. Is there a reason for this?
Any help is appreciated. Thank you!
It looks like you are trying to write a file in a protected directory without the proper privileges.
In Vim, :echo $HOME tells you where you are supposed to put your _vimrc. In your case, your _vimrc should be C:\Users\Alphabet\_vimrc and you should put your plugins and whatnot in C:\Users\Alphabet\vimfile\.
Never touch system files!

vim plugin for directory list/file open

I'm looking for a vim plugin similar to http://www.vim.org/scripts/script.php?script_id=1325 with a directory list in which you can select a file to open. Does this exist somewhere? Wasn't able to find it myself.
NERDTree is the second best ranked plugin on vim.org and it perfectly fits your description.
There are many other variations of the same principle:
FuzzyFinder
LustyExplorer (the one I used before)
Command-T (famous among TextMate switchers, I never liked it, though)
CtrlP (the one I use now)
…
And I second :Explore.
Have you tried the :Explore command that comes with the standard vim distribution since (roughly) version 6?
See http://vim.wikia.com/wiki/File_explorer for basic help on that command.
See http://vimdoc.sourceforge.net/htmldoc/pi_netrw.html#netrw-quickhelp for detailed help on what the Explorer can do.
If you want to open an explorer without replacing the current buffer, you can use the :Sexplore command. A puerile mnemonic for that is to execute :Sex.

How can I have two panels in terminal that interact with each other?

I'm trying to switch to Vim and I'm liking it a lot, but one big issue I'm having is switching files I have to constantly :wq, cd ..., ls ..., vi ..., etc. I'd like to have two panels (vertical?). One is for coding and the other is for cd-ing/ls-ing/vi-ing. Sort of like having a file browser as in most code editors. Any ideas?
You could use NERDTree for directories navigation and CommandT for fast file searching.
I second the NERDTree plugin from #lucapette.
And also recommend Bufferlist, to quickly switch between already opened files.
Another quick solution to explore a directory would be with :E
:E ~/workspace/
Would list the files in the workspace dir in your home folder for you to open.
You can :vsp into directory (as opposed to file).
I ended up using the CtrlP plugin and ditching the idea of having a file pane. I always knew what the file name was kinda, so this works better and takes up 0 screen real estate.
https://github.com/kien/ctrlp.vim

Vim Editor open always users home directory

I installed Nerd_tree plugin for vim on ubuntu 10.04. It is great plugin. But I met the following problems:
after open nerd_tree to browse the files in /etc/apache2/sites-available/, now I close it, and go on with my work. Later I want open nerd_tree again to edit another file in /etc/apache, but nerd_tree shows me always the user home directory /home/toledot, So I have to up dir->up-dir->up-dir again. Is there a way let nerd_tree to remember the path, which I have used at the last minute?
I opened nerd_tree and select one file to edit. After my update on this file, and want to select another file to make some change. But I can not go back to the nerd_tree. I tried to make double click and tab and so on. It doesn't work. What is the hotkey to switch nerd_tree and the opened files in vim?
I am absolute new with vim and plugins, so please help me and explain the solution in details. I am very thankful for any suggestion or infos.
A couple of points that may be helpful.
If you set autochdir the current working directory will be automatically be set to that of the current file. You can do this either interactively or in your .vimrc file.
The official way to open the NERDTree window seems to be with the command :NERDTree. You can map this to any convenient key sequence.
You should be able to view the helpfile with the command :help NERDTree. If you have trouble getting the help, change to the directory containing file NERD_tree.txt (in vim) and execute :helptags .
You can also add bookmarks for file/directories that you often use. See
:help NERDTreeBookmarkCommands.
What you need is a handy map to :NERDTreeToggle. Put this in your .vimrc
nmap <silent> <F4> :NERDTreeToggle<CR>
And just hit <F4> to open/close NERDTree, just like that, just as you last toggle-closed it.
You can also open a specific directory using :NERDTree /my/dir
I advise you to set autochdir so that whenever you open a file, working directory (you can find out this with :pwd) will be changed accordingly

Resources