未加星标

By Jove! It's a lightweight alternative to Vim

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二03 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

Some people like Vim as a text editor, and other people like Emacs. Having such different opinions are the way of the UNIX world.

I'm an Emacs user through and through. Sure, I spent a few obligatory years in my early days of UNIX using Vim, but once I learned Emacs properly, there was no going back. The thing about Vi(m) is that it's on nearly every UNIX box because it's been around forever, and it's pretty small. It's the obvious choice for a default editor that people can use in a pinch.

Without taking into account deliberate optimizations and carefully selected configuration options, the "natural" difference in size between Vim and Emacs is roughly 1 to 7 (I maintain an Emacs module for the live linux distribution Slax , where Emacs is 37MB to Vim's 5MB. Similarly, on my NetBSD box, a minimal build of Emacs is 14MB and Vim is around 2MB).

To be fair, GNU Nano is also small and is a pretty fair and, lately, popular choice as the default text editor. The problem with both Nano and Vim, though, is that neither of them are Emacs. The problem with Emacs is that it's really, really big.

Delving into Emacs

Emacs started as a set of macros for an existing text editor called TECO. The idea was pretty straightforward:TECO occasionally had features that required six steps that were easier if scripted and turned into a single step. Eventually, people saw that the macros were so sensible that they gatheredup them up and bundled them together as a standalone, interactive editor.

To most people, "Emacs" suggests two different principles:

A text editor with a specific style of functionality (keyboard commands centered around ctrl and alt combinations)and a general overall "feel" and style. This is the "manual or automatic?" part of Emacs. A robust Lisp interpreter that is endlessly extensible and hackable. This isn't what most people think about when trying Emacs for the first time―it's the stuff under the hood.

Most of the weight of an Emacs binary is found in the place where these two sides of Emacs conjoin. Emacs itself (the text editing part) isn't very heavy. Add in all the cool tricks it can do (view PDF and docx files, load in additional menus, use a GUI front end, and so on) and the application becomes heftier. Add to that a complex config file, and things get even more convoluted.

Jonathan's own version of Emacs

Jonathan Payne wrote his own version of an Emacs editor and called it Jove. Today, it's something of a niche application that doesn't get talked about much, but it's a surprisingly small and effective Emacs clone. When you're in Jove, you hardly realize that you're not using Emacs. In fact, Jove is so much like GNU Emacsthat its inbuilt tutorial, teachjove, is the Emacs Tutorial with only slight modifications. This means you get the most commonly used benefits of GNU Emacs, but with a tiny footprint and a trivial list of dependencies: libtinfo ,for ncurses -style elements, and libc .

How small is it? The Jove executable is roughly 150K.

Jove ships with Slackware by default, so I don't even bother installing Vim. Because so many applications seem to want to default to Vim, I go so far as to alias Vi to Jove.

Fedora and Debian both provide Jove packages.

If you're on a distribution that doesn't provide a Jove package, you might be able to rebuild a package for your distribution from a source package. For example, RHEL and CentOS don't have Jove packages, but Fedora does. As long as you have the RPM development toolchain installed:

# yum grouplist -v # yum groupinstall fedora-packager

Download the source RPM for Jove (it should have src.rpm in its file name), and then rebuild the SRPM:

$ rpmbuild --rebuild jove-4.16.0.73-10.fc24.src.rpm

Find the rebuilt RPM in your user's ~/rpmbuild/RPMs/ directory in the appropriate architecture. Install it as usual. For example:

$ sudo dnf install ~/rpmbuild/RPMs/jove-4.16.0.73-10-el7.rpm

If all else fails, the source code for Jove is maintained at the University of Toronto .

Exploring Jove

The part of the GNU Emacs experience that Jove leaves out is Lisp. For hardcore users of Emacs, this makes Jove a noncontender as an Emacs, but as a replacement for Vim, the absence of Lisp simply means you get a lightweight nonextensible editor with the same look-and-feel as GNU Emacs. The best way to find the differences between Emacs and Jove is to use Jove. You'll run into the differences eventually, but there are a few tricks that can help you adapt.

Env settings

You can remove the Vim package if you really want to, but on some distributions doing so is more work than it's worth. For instance, on a RHEL server, both cvs and sudo "require" Vim. The executables don't actually require Vim, of course, but their RPM packages have been told that they do, so that's what yum or dnf will report.

It's easier and safer to just set a proper EDITOR environment variable. To do that use:

$ echo "EDITOR=/usr/bin/jove" >> ~/.bash_profile $ sudo !$ $ source ~/.bash_profile $ sudo !$

Most applications respect the EDITOR environment variable (even visudo , which, given the name, you might not expect). I've seen a few oddities that ignore it and stubbornly load Vim anyway, but in my experience those are rare.

If you absolutely must, you can symlink Jove to Vi, as long as you keep the actual Vi executable around for emergencies. Because Vi is installed to /bin , it's the one text editor you'll have in the event of a system rescue when /bin is the only mounted partition (unless you manually install something else to /bin ). A safe option is:

$ sudo mv /bin/vi /bin/vi.bin $ sudo ln /usr/bin/jove -s /bin/vi

You should only do this if you know what you're doing and understand how it will affect a rescue environment.

teachjove

If you're not a Emacs or Jove user already, you should first launch teachjove for a step-by-step introduction. Be careful, if you're currently a happy Vim user, this may change your world view. If you're a Nano user, this gives you a glimpse at what you're missing.


By Jove! It's a lightweight alternative to Vim
joverc

Jove ships with several .jove.rc.* files with all the usual defaults an Emacs user might expect.

$ cat /path/to/jove/jove.rc.xterm > ~/.joverc

This serves as both a safe starting place for getting used to Jove as well as an example of the customizations possible. The most common change to make, surely, is the behavior of the Forward-Delete key, which for historical reasons is set to act as a backspace:

# DEL key bind-to-key delete-next-character ^[[3~ # Backspace key bind-to-key delete-previous-character ^? apropos As with GNU Emacs, the command M-x apropos foo (or M-x apr foo for short) performs a search within a

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

主题: LispDebianLinuxSlackEDI
分页:12
转载请注明
本文标题:By Jove! It's a lightweight alternative to Vim
本站链接:http://www.codesec.net/view/522204.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(42)