Skip to content

Tianer1123/python-run.vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

介绍

通过快捷键或命令直接运行当前python脚本。

截图

RunPython

ex命令下输入: :python_run或者按_ + r运行python脚本。

python_run 插件依赖

  • vim8.0或更新
  • +terminal

查看版本

终端查看vim版本:

vim --version

vim内查看vim版本:

:version

查看是否支持terminal

终端查看:

vim --version | grep terminal
  • +terminal : 支持
  • -terminal : 不支持

vim内查看:

:echo has("terminal")
  • 1 : 支持
  • 0 : 不支持

安装

Vundle ( 建议 )

把下面内容放到你的vimrc

Plugin 'Tianer1123/python-run.vim'

打开vim执行

:source %
:PluginInstall

Pathogen

cd ~/.vim/bundle
git clone https://github.com/Tianer1123/python-run.vim.git

无插件管理器

将插件下载下来拷贝到你的vim配置文件夹中

cd /tmp && git clone https://github.com/Tianer1123/python-run.vim.git
cp -r python-run.vim/* ~/.vim/

查看vim帮助:help add-global-plugin.

python_run 配置

win32:

win32下默认使用python命令,请设置好环境变量。

linux,MACOS:

python_run 需要在配置文件vimrc中配置python版本(python2python3):

let g:python_run_python_version = 3

或:

let g:python_run_python_version = 2

默认情况下g:python_run_python_version = 3

terminal的一些简单介绍

关于terminal的特性,可以查看terminal的相关文档:

:h terminal
  1. 如果terminal处于运行状态,可以使用<c-w> <c-w>或者<c-w> + h,j,k,l来切换window。
  2. 如果terminal处于运行状态,可以使用<c-w> <c-c>来终止terminal job,退出REPL并进入normal模式。
  3. 如果要退出terminal窗口,在进入normal模式后执行:q!或者:close!等。

映射

python_run 中设置的<localleader>_

set maplocalleader='_'

自定义maplocalleader

let g:python_run_python_localleader = '_'
快捷键 说明 功能
_r <localleader>r 运行python脚本

命令

python脚本进入normal模式时,执行ex命令:

:RunPython

运行python脚本。

如果安装了ipython,用如下命令打开:

:RunIpython

许可证

MIT许可证

About

🇨🇳 一个练手的vim脚本

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published