Is there any efficient ways to locate, open files in Vim? [duplicate] - vim

This question already has answers here:
Shortcut to open file in Vim
(19 answers)
Closed 9 years ago.
I use Nerdtree, it is convenient. But when there is too many files in directories, it is little inconvenient to locate files and open it.
Is there some efficient way to locate, open files in Vim?

This other answer of mine covers a few of the methods available to you without installing anything. Vim's built-in ** and tab-completion are your best friends:
:e **/foo*/bar<tab>
The above mentioned CtrlP is a great tool that does a lot more than file navigation. You should try it, as well as the other plugins in my answer.
Also, NERDTree is close to useless because you already have a file explorer in Vim: :help netrw.

Related

Is there a way to quit Vim so that it will load the same session next time? [duplicate]

This question already has answers here:
How to save and restore multiple different sessions in Vim?
(14 answers)
Closed 9 years ago.
Sometimes I have Vim running with a good number of tabs, buffers, etc, but I need to quit to reboot, install a new Vim version, etc.
But when I start Vim back up I want the same tabs, split windows, with the same files open in them.
Is there any way to do this? Does Vim have a concept of "sessions"?
(I'm not worried about tabs or buffers that contained contents not loaded from files.)
Yeah of course VIM knows session managment :)
From the vim doc :
A Vim session contains all the information about what you are
editing. This includes things such as the file list, window layout,
global variables, options and other information. (Exactly what is
remembered is controlled by the 'sessionoptions' option, described
below.) The following command creates a session file:
:mksession vimbook.vim
Later if you want to restore this session, you can use this command:
:source vimbook.vim
Check out this tuto about this functionnality : http://usevim.com/2013/07/05/sessions/
Make a session in Vim:
:mksession session.vim
In terminal, restore session:
$ vim -S session.vim
Or when already in Vim, restore session:
:source session.vim

GVIM : Possible to begin editing the file without having to press "i"? [duplicate]

This question already has answers here:
Is there a way to change vim's default mode
(5 answers)
Closed 9 years ago.
I am trying to move from GEDIT to GVIM but I noticed that when I open a file I am not free to edit it.
unless I press i to go in (INSERT) mode.
Is there a way to bypass this? So the file is instantly editable?
You can do this by editing your .vimrc file. It looks like set im! is the command you're looking for to set input mode as the default, but you'll also need to explicitly map escape to change to command mode.
A better question is why you would want to do this, though. Unless you're opening a brand new file, once you know vim, you'll probably spend very little time in insert mode, as you should be using more advanced command-mode commands (append, correct, etc) to edit and update your code at the appropriate places. If you're just going to use vim the same way you use gedit, don't bother - gedit is better than vim at being gedit.
EDIT: After reading the comments on your question, it sounds like you really, really shouldn't be using vim. It's not something you want to stumble into by default, certainly not if what you want is a basic editor with customizable display.

Changing open command for NERDTree [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Is there any way to reduce the command in VIM?
In vim to open your NERDTree menu you type :NERDTree, but that actually really annoys me, because it's long and mixed case. Since you close it with q, I want to open it with a short key (maybe :n, you can also provide suggestions for that if you feel like it). How can I change that?
I am sorry if this is simple, but I am a newb, and I don't know form where to start aproaching such a problem -from the plugin files, or is there a special remapping technique in your .vimrc.
You can use
map <F2> :NERDTreeToggle<CR>
to map NERDTree to any key you like (F2 in this example)
it's also possible to map it to :n
map :n :NERDTreeToggle<CR>
but that's not very common, I like using one of the F-Keys because that's faster.

Explore filesystem/directories in vim?

What is the best way/plugin to explore filesystem and to open files and directories?
The best way to explore filesystem/directories in Vim is the one that best suits your needs. As it is phrased, this question can't get an answer because there's no "way" universally agreed upon.
On the other hand, if you want to have an overview of the many ways to explore the filesystem in Vim then, yes, that is a question that can be answered. In a non-exhaustive way, though.
NERDTree and netrw are already covered. These plugins show you a tree-like list of files and directories that you can act on. Before trying NERDTree, I'd suggest you try your hands on netrw as it comes with Vim by default and offers a much wider range of features than NERDTree. You should look around on http://www.vim.org because there are a bunch of similar plugins.
On the opposite side of the spectrum, you have Vim's own file handling capabilities. Here is a sample of commands you can use from Vim to open files:
:e filename edits filename
:sp filename edits filename in an horizontal split
:vs filename edits filename in a vertical split
:tabe filename edits filename in a new tab
You have tab-completion, just like in the shell:
:e <tab> goes through all the directories/files in the working directory
You can use wildcards, of course:
:e **/*.js<tab> shows all the js files in the working directory and its subdirectories
Assuming you have set wildmenu in your ~/.vimrc, you can make tab-completion even better with an horizontal menu which can be customized further…
You can also use "args"… but that will be for another time.
Somewhere between Vim's default commands and netrw/NERDTree you can find a bunch of "fuzzy" and less fuzzy file openers more or less modeled after a feature introduced in TextMate a while ago: FuzzyFinder, LustyExplorer, Command-T, CtrlP and many other variations on the same theme. The core concept is to provide you with a list of choice that you narrow down by typing more characters in a prompt until the file ou want to edit is selected.
If you decide you want to go down the plugin road, I'd suggest you visit http://www.vim.org, compare what's there, try a few plugins and decide for yourself.
Anyway, you should get used to the basics before looking for a plugin.
Try NERD Tree, besides the tree tab it also enhances the classical directory listing as suggested by #ATOzToa.
On Windows, I find :!start explorer %:p:h to be the way to go, or :!start explorer . if I'm in the directory I want opened.
On MacVim you could probably do something similar with :!open . to open a Finder window on the current directory but I don't have a Mac handy to try it out.
Not sure what you'd use in GNU/Linux; it probably depends on your desktop manager.

Does "M-x term" of emacs exist on vim? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How can I open a Shell inside a Vim Window?
In emacs there is an amazing functionality that allows user to split the window into two ones and run shell commands on one window. Does it exist on vim?
Thanks
There are several, but Conque appears to be the most full-featured one.

Resources