您的要求不是很多,但我们还是来吧...
Drop Janus as soon as you can. This piece of shit gives you a false sense of comfort while actively preventing you from learning how to use Vim and making it a lot harder than necessary to customize it to your liking.
Vim's tabs are not like tabs in other editors: they are not and can't be 1-to-1 proxies for files. In Vim, a file is loaded in a "buffer" and that buffer may or may not be displayed in zero or more "windows", in zero or more "tabs". This particularity will probably bite you one of these days so you'd better get used to deal with buffers.
In Vim, creating a new file works the same as in any editor: you edit a new empty file and, when you are done, you write it to disk.
:e[dit] file.html
(editing)
:w[rite]
Use :sp[lit] file.js
to edit file.js
in a new horizontally window.
Use :vs[plit] file.html
to edit file.html
in a new vertical window.
Use :tabe[dit] file.css
to edit file.css
in a new tab.
If you want to postpone the decision of the filename, :enew
, :new
, :vnew
and :tabnew
create empty buffers in place, in an horizontal window, in a vertical one and a tab.
You don't really need to create those files from outside of Vim.
From the Finder, the simplest way to edit a file in MacVim is to right-click on it and choose "Edit in MacVim". Same for three files.
There is a drop menu, somewhere in MacVim's Preferences window, that lets you define the default behavior when MacVim is launched by other programs. Try it.
Since you seem to have installed the mvim
script, editing a file in the MacVim GUI is done with $ mvim filename
and editing the same file directly in your shell is done with $ mvim -v filename
.
You can also open multiples files (even if they don't exist) in their own tabs from your shell:
$ mvim -p file1 file2 file3
Your command, :!mvim filename
, does exactly what it's supposed to do: it launches a new MacVim instance.
Vim already comes with a file explorer that does a lot more than NERDTree called Netrw
. See :help netrw
.
Did I tell you that you shouldn't use tabs if you don't have a solid understanding of what they are and what they do?
:tabe something.html
。这会在当前窗口中创建一个新标签,并将文件 something.html
放入其中,如果不存在,则会创建一个新文件。(实际上直到保存该文件之前都不会创建新文件)。:help tab-page-commands
可能值得你的时间。Command + T
在MacVim中创建一个新的标签页。
:b <Tab>
命令可以方便地进行切换。我从事前端开发工作,我的设置很简单:HTML代码在一个竖直窗口中占据了一半的可用空间,另一半则是CSS或JS,具体取决于我正在处理的功能。我很少需要同时查看CSS和JS,但HTML是必须的,因为这两个文件都涉及HTML结构。所以,我认为两个竖直窗口是最好的设置。当然,这里指的是分割窗口,而不是GUI窗口。 - romainl~/.vimrc
中加入filetype plugin indent on
和syntax on
就可以获得语法高亮、自动完成和正确的缩进规则。如果你想要一个代码检查器,有许多插件可用。再次强调,不需要一个可怕的发行版! - romainl