如何在 Cygwin 中使用我的 .vimrc 文件?
我刚刚在我的工作机器上安装了 Cygwin,并且想使用我在家里的 Linux 机器上使用的 .vimrc 文件。
- 这可能吗,还是需要有特定于 Cygwin 的设置?
- 我应该把 .vimrc 文件放在哪里?
我有点不确定在 Cygwin 下的 bash 提示符下我会被放入哪个目录,但我想我应该在那里创建一个名为 .vim 的子目录,对吧?
I just installed Cygwin on my work machine and would like to use the .vimrc file I use on my Linux box at home.
- Is that possible, or does it need to have Cygwin-specific settings?
- Where would I put the .vimrc file?
I'm a little unsure of what directory I'm being dropped into at the bash prompt under Cygwin, but I think I'd create a subdirectory called .vim there, right?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
我以
vi -V
启动 vi 并得到以下信息:意识到 vi 正在寻找
.virc
而不是.vimrc
,就像所有其他 *nix 系统一样我曾经使用过,我只是运行这个来解决问题:...或者如果 如果你配置了符号链接:
我很确定这是一个问题,因为Cygwin安装了vi,而不是vi改进;但是,如果您启动不带参数的 vi,加载屏幕仍然显示 vi 已改进。无论如何,我通过
setup.exe
安装了vim
并运行vim
(不是vi
)确实尝试加载 < code>~/.vimrc 正如预期的那样。您只需将alias vi=vim
添加到 ~/.profile 即可默认使用改进的版本。I launched vi as
vi -V
and got this:Realizing vi was looking for
.virc
and not.vimrc
like all the other *nix systems I've ever used, I just ran this to fix the problem:... or if if you've configured symlinks:
I'm pretty sure this was a problem, because Cygwin installs vi, and not vi improved; however, the loading screen if you launch vi with no parameters still says vi improved. Regardless, I installed
vim
viasetup.exe
and runningvim
(notvi
) does indeed try to load~/.vimrc
as expected. You can simply add analias vi=vim
to your ~/.profile to use the improved version by default.Cygwin(自版本 1.7.25 起)默认安装
vi
(不是vim
!)。如果您还安装了 vim,您将有两个命令:/usr/bin/vi 和 /usr/bin/vim。与其他 *nix(例如 debian)不同,这两个命令在启动 vi/vim 时的行为略有不同。
这两个命令都会加载 Vi 增强版,但它们在初始化编辑器时查找的文件有所不同:
/usr/bin/vi
首先查找/etc/virc
,然后查找$HOME/.virc
/usr/bin/vim
首先查找/etc/vimrc
,然后查找$HOME/.vimrc
。如果找到,这两个文件(在
/etc
和$HOME
中)都将被获取!您可以自己输入
vi -V
和vim -V
进行检查。如果调用
vim
,则使用.vimrc
;如果调用vi
,则使用.virc
。或者简单地使用alias vi=vim
来使用.vimrc
Cygwin (as of version 1.7.25) installs
vi
(notvim
!) by default. If you also installvim
you will have two commands:/usr/bin/vi
and/usr/bin/vim
.Unlike in other *nix (e.g. debian) both commands slightly differ in their behaviour on starting vi/vim.
Both commands will load Vi Enhanced but they differ in the files they look for to initialize the editor:
/usr/bin/vi
looks first for/etc/virc
and then for$HOME/.virc
/usr/bin/vim
looks first for/etc/vimrc
and then for$HOME/.vimrc
.Both files (in
/etc
and in$HOME
) will be sourced if found!You can check it yourself entering
vi -V
andvim -V
.Use
.vimrc
if you callvim
and.virc
if you callvi
. Or simplyalias vi=vim
for using.vimrc
1)是的,这是可能的。它不需要任何 cygwin 特定的设置,尽管您可以添加一些 Windows 特定的设置。只需确保正确安装 vi(vim gvim 等效项)即可。
2) 与 *nix 相同的位置 -- 用户主目录
1) Yes it is possible. It doesnt need any cygwin specific settings, though you can add some windows specific ones. Just make sure to install vi (vim gvim equivalent) properly.
2) the same place as on *nix -- user home directory
请注意一件事:有一个 Cygwin 端口的 vim 和一个本机 win32 端口的 vim。当与 cygwin 或 native-win32 应用程序对话时,两者都有各自的优点和缺陷。
vim.wikia 上的一个类别专门用于 cygwin 相关提示。
Beware one thing: there is a Cygwin port of vim, and a native win32 port of vim. Both have their advantages and their flaws when dialogue with cygwin or native-win32 applications is concerned.
A category on vim.wikia is dedicated to cygwin related tips.
Cygwin 文件系统的某些部分使用您的“主机”文件系统作为自己的文件系统。在 cygwin 中,有一个用户主目录(实际上位于您的“Documents and Settings/Username”文件夹下),因此您应该将其放置在那里。
只要将你的 .vimrc 放在你知道如何通过 cygwin 访问的地方,然后执行一个
它就会工作——至少在几个月前我的 Cygwin 安装上使用默认的
vim
。Some parts of file system of Cygwin use your "host" file system as its own. Within cygwin, there is a user home directory (which actually resides under your "Documents and Settings/Username" folder), so you should place it there.
Just place your .vimrc somewhere you know how to access via cygwin and do a
It will work--at least worked with default
vim
on my Cygwin installation several months ago.我不明白为什么你的 Linux ~/.vimrc
不应该在您的 cygwin 安装中工作。
要转到 cygwin 中的主目录,
cd ~
或
cd $HOME
在 Windows 中,您可以使用 WinSCP 连接到 Linux 机器,在 WinSCP 默认编辑器中打开 Linux .vimrc,复制内容。然后切换到Cgywin终端并输入
getclip> ~/.vimrc
启动 vi/vim 查看您的新设置是否已生效:
vi
I don't see any reason why your Linux ~/.vimrc
should not work in your cygwin install.
To go to your home directory in cygwin,
cd ~
or
cd $HOME
In Windows, you can use WinSCP to connect to your Linux box, open your Linux .vimrc in the WinSCP default editor, copy the contents. Then switch to the Cgywin terminal and type
getclip > ~/.vimrc
Start vi/vim to see if your new settings have taken effect:
vi
我必须在
/home/Leo/.virc
或更一般的目录中将我的
。.vimrc
文件重命名/符号链接为.virc
>$HOME/.vircI had to rename / symlink my
.vimrc
file to.virc
in a directory like/home/Leo/.virc
or more generally$HOME/.virc
.我刚刚创建了自己的并开箱即用:
1) vim ~/.vimrc
一旦进入 .vimrc (空白文件),我喜欢从以下位置复制示例:
然后检查任何文件应该有很多颜色和东西
I just created my own and worked out of box:
1) vim ~/.vimrc
Once inside the .vimrc (blank file) I like to copy the example from:
Then check any file should have lots of color and stuff
只需导航到您的主目录即可
c:/Users/用户名/
使用创建文件
vi.vimrc
在这里设置您的偏好,它们肯定会反映
喜欢
保存并尝试。
simply navigate to your home directory which is
c:/Users/user_name/
create the file using
vi .vimrc
set your preferences here, and they would surely reflect
like
save and try.
我在使用 Cygwin vi tabstop 时遇到了问题。它总是默认为 8。启动时出现错误“无法获取 defaults.vim” 尝试遵循各种解决方案,但下面的解决方案对我有用。
在当前用户主目录($HOME)下创建.vim目录。
在.vim目录下创建.virc文件。
将以下行添加到 .virc
set tabstop=4
Cygwin 版本详细信息
CYGWIN_NT-10.0-22000 3.3.5-341.x86_64 x86_64 CYGWIN
I had issue with Cygwin vi tabstop. It was always defaulting to 8. While launching it was giving error "Failed to source defaults.vim" Tried to follow various solutions but below worked for me.
Create .vim directory under current user home ($HOME) directory.
Create .virc file under .vim directory.
Add below line to .virc
set tabstop=4
Cygwin version details
CYGWIN_NT-10.0-22000 3.3.5-341.x86_64 x86_64 Cygwin