向 Vim 添加命令 [英] Adding a command to Vim

查看:28
本文介绍了向 Vim 添加命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我终于决定尝试 Vim,因为我越来越沮丧通过 GUI 编辑器.到目前为止,我很喜欢它,但我无法为我遇到的问题找到任何帮助...

I finally decided to try out Vim, as I am getting increasingly frustrated by GUI editors. So far, I'm loving it, but I can't find any help for a issue I'm having...

我正在尝试使用 cmap 在 Vim 中将命令 :Pyrun 映射到 :!python %.如果我键入 :cmap,映射显示正常.但是,在键入 :Pyrun 时,我收到此错误消息:

I am trying to map the command :Pyrun to :!python % in Vim using cmap. The mapping shows up fine if I type :cmap. However, on typing :Pyrun, I get this error message:

不是编辑器命令:Pyrun.

Not an editor command: Pyrun.

这是我在 .vimrc 中尝试的:

Here is what I'm trying in .vimrc:

:autocmd FileType python :cmap Pyrun<cr> !python %<cr>
:autocmd FileType python :cmap Intpyrun<cr> !python -i %<cr>

我该怎么做才能解决这个问题?

What can I do to solve this problem?

推荐答案

我会在你的 .vimrc 或你的 ftplugin/python_ft.vim 中尝试这样的事情

I would try something like this in your .vimrc or your ftplugin/python_ft.vim

command Pyrun execute "!python %"
command Intpyrun execute "!python -i %"

然后 :Pyrun:Intpyrun 应该可以工作

Then :Pyrun and :Intpyrun should work

然后您可以将功能键映射到每个

You could then map a function key to each

map <F5> :Pyrun<CR>
map <F6> :Intpyrun<CR>

这篇关于向 Vim 添加命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆