bccalc.vim


Ⅰ. 插件描述

evaluate equations within vim

Ⅱ. 基本信息

创建日期:  2002-02-16
使用用户:  1
Github星:  2
插件作者:  scott urban

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin '/bccalc-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle '/bccalc-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug '/bccalc-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/vim-scripts/bccalc.vim

Ⅳ. 文档说明

This scirpt calculates equations using the program 'bc' (found on most linux systems, available for most systems).  Visually select the equation you want to calculate, then hit ;bc - if the selection ends with an '=' sign, the answer will be appended after the equal, otherwise, the answer is echoed as a message. Equations can span multiple lines, and the full bc syntax is probably supported.  Additionally, sin (), cos (), etc, are transformed into the names used by bc (s () c (), etc).

This script was first entered as a tip, but someone pointed out that functions are hard to use when posted as tips, so this makes it easier to download and use.

Here are some example lines:

2 * sqrt (2) =

3 * (2 - 1) + 4.0 ^ 6 =

4 / 3 =

3 +
   4 -
      2 * (1 / (3 + 2)) =

define rad (x) {
  return (x / 180) 4 atan (1)
}
cos (rad (45)) =

ibase = 2; obase = 2;
0100 * 0101 =

Select each of these in turn (continguous non-blank lines, and hit ;bc for each), and this is what you get:
2 * sqrt (2) = 2.82842712474619009760

3 * (2 - 1) + 4.0 ^ 6 = 4099.000000

4 / 3 = 1.33333333333333333333

3 +
   4 -
      2 * (1 / (3 + 2)) = 6.60000000000000000000

define rad (x) {
  return (x / 180) 4 atan (1)
}
cos (rad (45)) = .70710678118654752440

ibase = 2; obase = 2;
0100 * 0101 = 10100

Chaining is now allowed:

start with this

2 + 3 =
;bc
2 + 3 = 5
add some more stuff:
2 + 3 = 5 * 2 =
;bc
2  + 3 = 5 * 2 = 10

添加新评论