slap-命令行上的sublime

昨天我在网上突然看到一个slap的工具,用node写的命令行编辑器。功能类似sublime。

官方是这么介绍的:

Clipboard Image.png

slap is a Sublime-like terminal-based text editor that strives to make editing from the terminal easier. It has:

  • first-class mouse support (even over an SSH connection)
  • a Sublime-like file sidebar
  • double-click to select word, highlight other occurrences
  • configurable Sublime-like keybindings* (Ctrl+S save, Ctrl+Z undo, etc.)
  • copying/pasting with OS clipboard support
  • infinite undo/redo
  • syntax highlighting for 100+ languages
  • bracket matching
  • autoindentation
  • heavily customizeable via plugins
  • ... many other features that will make you leave nano, vim, and emacs behind

Installation

$ curl -sL https://raw.githubusercontent.com/slap-editor/slap/master/install.sh | sh

If you already have NodeJS installed:

$ sudo npm install -g slap@latest

Usage

$ slap fish.c
$ slap fish1.c fish2.c
$ slap redfish/ # open dir
$ slap # new file

Default keybindings

  • Quit: Ctrl+Q
  • Movement: mouse or arrow keys and PageUp/Down/Home/End
    • Shift or click+drag to select, Ctrl/Alt to move faster
  • Save: Ctrl+S
  • Undo: Ctrl+Z, redo: Ctrl+Y
  • List open tabs: Ctrl+L
  • Next/previous tab: Ctrl+Alt+PageUp/Down
  • Close tab: Ctrl+W
  • Find: Ctrl+F
  • Go to line: Ctrl+G
  • Go to matching bracket: Ctrl+]
  • Open: Ctrl+O (or click the filebrowser)
  • New file: Ctrl+N

Configuration

slap supports INI or JSON config files. You can put configuration wherever rc can find it. A mostly empty configuration file with some useful comments is created in ~/.slap/config if an existing file isn't found.

Pass configuration via command line:

$ slap --header.style.bg red file.c

Plugins

Slap is fully customizeable and supports plugins written in JS. You can place single JS files, or NodeJS packages, into~/.slap/plugins/.

To write your own plugin, a good starting point is slap-clipboard-plugin. Please note that plugin packages must have"keywords": ["slap-plugin"] in package.json.

OS support

OSX

iTerm2 supports the mouse and most keybindings out of the box. For optimal Terminal.app usage, see slap-Terminal.app-profile.

Linux

If you are using X.Org, ensure xclip is installed for OS clipboard support.

Windows

Most terminal emulators in Windows do not support mouse events, PuTTY being a notable exception. In Cygwin, slap crashes on startup due to joyent/node#6459.

我本来osx 上想装一个的,可是一直报错装不上。后来在连公司项目ssh时想,aliyun上能不能装一个。

就按照教程里的curl 方式装了一下 node 之前也没装!--。 

然后就开始使用了,唯一不爽的是我osx交换了command按键,到ssh里连上后按键又回去了。

第二个遇到的问题是中文乱码。

我就在issue里找了一下。

#182 还真有。

就按照说的去设置了一下:

Clipboard Image.png

logger下添加screenOpt 的 这样才有用。

希望大家玩的愉快!

标签:<a href="/?tag=slap">slap</a>,<a href="/?tag=cmd">cmd</a>,<a href="/?tag=命令行">命令行</a>,<a href="/?tag=编辑器">编辑器</a>