vim的使用

:Ve 垂直打开目录结构

:S 水平打开目录结构

原文: https://stackoverflow.com/questions/14385379/explore-filesystem-directories-in-vim

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.

------------------------------------------------------------------

1.How do I switch between panes in split mode in Vim?

I've done the :split command and now I want to switch between panes.(:S ,   :Ver命令都可以分屏)

In command mode, hit Ctrl-W and then a direction, or just Ctrl-W again to switch between panes.

Ctrl-W, s will create a horizontal split.
Ctrl-W, v will create a vertical split.
Ctrl-W, direction will allow you to move among the panes.
:ls will show your open buffers.
:b <number> will open the specified buffer in the current pane.

you can use <ctrl> + w + w To switch the panes in order.
A suggest way is to put this codes in your vimrc file
""""""""""""""""""""""""""""""""""""""""""
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l

That means you could use <ctrl>+j/k/h/l to switch the right direction just like you use the j/k/h/l to move the cursor

原文地址:https://www.cnblogs.com/oxspirt/p/7158677.html