Skip to main content

Cano

What is Cano?

Cano is a VIM like text editor written in C using the ncurses library. Cano was started as a hobby project by CobbCoding. You can find the repository here.

How to get started with Cano

Prerequisites

Cano assumes the following:

Installation & Build From Source

  1. Clone the Cano repository
git clone https://github.com/CobbCoding1/Cano.git
  1. Navigate to the Cano directory
cd path/to/Cano
  1. Make the generator script executable
chmod +x autogen.sh
  1. Run the generator script
./autogen.sh

The build files will be stored at path/to/cano/build.

  1. Compile cano
make -C build
  1. Run cano
./build/cano

OS Specific Installation

Arch Linux

Arch users can use their preferred AUR helper to install Cano by using this AUR package

For instance, if using yay, run the following command:

yay -S cano-git

Debian/Ubuntu

Debian and Ubuntu users can build Cano from source and install it directly to usr/local/bin

Note This process assumes that you have a C compiler(preferably GCC), Autotools, pkg-config and the ncurses library installed. For more information on how to install these dependencies, see the Prerequisites section.

Here are the steps to install Cano on Debian/Ubuntu:

  1. Install dependencies
sudo apt install gcc autoconf automake libtool pkg-config make libncurses-dev
  1. Clone the Cano repository
git clone https://github.com/CobbCoding1/Cano && cd Cano
  1. Run the autogen.sh script
chmod +x autogen.sh && ./autogen.sh
  1. Change to the build directory and build Cano using Make
cd build
make
  1. Install Cano
sudo make install

Nix/NixOS

Due to Cano's build system undergoing several changes recently, Nix installation is not supported at this time. Please check back later as Cano is still under development.

Using Cano

Modes

There are 6 modes in Cano:

  • Global Mode
  • Normal Mode
  • Insert Mode
  • Visual Mode
  • Search Mode
  • Command Mode

Global Mode is the default mode when Cano is opened.

Normal mode is used for motions and deletions.

Insert mode is used for inserting text.

Visual mode is used for selecting text and performing actions on the selected text.

Search mode is used for searching for text in the current buffer.

Command mode allows the user to run commands.

Motions(Keybinds)

There are several motions that can be used within Cano. From moving the postion of the cursor to performing actions on lines!

Here are some of the most common and useful motions:

  • Esc - Enters Normal Mode while in Global mode
  • Ctrl + Q- Quits out of Cano regarless of mode
  • / - Enters Search Mode
  • v - Enters Visual Mode
  • i - Enters Insert Mode
  • h - Moves the cursor left
  • j - Moves the cursor down
  • k - Moves the cursor up
  • l - Moves the cursor right
  • Ctrl + S - Saves the current file and exits Cano

For the full list of usable Cano motions while in Global and Normal mode, see the table below.

ModeKeybindAction
GlobalEscEnter Normal Mode
GlobalCtrl + QQuit (regardless of mode)
GlobalEscEnter Normal Mode
NormalhMove cursor left
NormaljMove cursor down
NormalkMove cursor up
NormallMove cursor right
NormalxDelete character
NormalgGo to first line
NormalGGo to last line
Normal0Go to beginning of line
Normal$Go to end of line
NormalwGo to next word
NormalbGo to last word
NormaleGo to end of next word
NormaloCreate line below current
NormalOCreate line above current
NormalCtrl + oCreate line below current without changing mode
Normal%Go to corresponding brace
NormaliEnter insert mode
NormalIGo to beginning of line
NormalaInsert mode on next char
NormalAInsert mode at end of line
NormalvEnter visual mode
NormalVEnter visual mode by line
NormaluUndo
NormalURedo
Normal/Enter Search mode
NormalnJump to next search
NormalCtrl + SSave and exit
NormalrReplace current char with next char inputted
Normal(n) + motionRepeat next motion n times
Normal(d) + motionDelete characters of next motion n times
NormalCtrl + nOpen file explorer

Visual Mode

Visual mode works the same as Normal mode, except it works on the entire selection, instead of character by character.

ModeKeybindAction
Visual>Indent current selection
Visual<Unindent current selection

Search Mode

Search takes in a string and then finds each occurence of the string in the file. Note: If prepended with s/ then this action will the substring(first) string with the second string. An example of this would be:

s/hello/bye/

This will replace all instances of hello with bye in the file.

Command Mode

ModeCommandAction
Commandset-outputchange output file
Commandecho (v)echo value (v) where v is either an ident or a literal
CommandweWrite and exit
CommandeWrite without exiting
Commandset-var (var) (value)Change a config variable
Commandset-map (a) "(b)"Map key a to any combination of keys b
Commandlet (n) (v)Create variable (n) with value (v)
Command!(command)Execute a shell command

Special Keys

There are several speacial keys that can be remapped.

Key
<space>
<esc>
<backspace>
<enter>
<ctrl-t>

Configuring Cano

Certain aspects of Cano can be configured via main config file which is config.cano By default, this file is located at ~/.config/cano/config.cano; however this can be manually set at runtime by running the following command:

./cano --config <config/file/path/name>

Config File Breakdown

The format of the config file is the same as how you would write a command in Command mode. Note: This is VERY important to remember. Here is an example of how this looks:

set-var syntax 1
set-var indent 2

Config Variables

relative #toggles relative line numbers
auto-indent #toggles auto indentation
syntax #toggles syntax highlighting
indent #sets the indent width
undo-size Sets the size of the `undo` history

There is a second config file that is exclusively used for custom syntax highlighting! This file is stored in the same default location as the main config file but it uses a different naming convention. An example of this is:

~/.config/cano/c.cyntax

Note The word Syntax is spelled with a c instead of and s because...c is for Cano duh!

The c. in the example above represents the language that the syntax file is for. In this case it is the C programming language. If you want to create custom syntax highlighting for the Go programming language you can create a file called go.cyntaxinstead.

Here is an example of the contents of the *.cyntax file:

k,170,68,68,
auto,struct,break,else,switch,case,
enum,register,typedef,extern,return,
union,continue,for,signed,void,do,
if,static,while,default,goto,sizeof,
volatile,const,unsigned.
t,255,165,0,
double,size_t,int,
long,char,float,short.
w,128,160,255.

Let's break down what is happening here. The single characters, in this case k,t,and w, represent the type of keyword it is.

  • k represents a keyword.
  • t represents a type.
  • w represents a word.

The types is then followed by a comma and then the RGB values for the color. No spaces should be used. Starting on the next line, after the RGB values, list the keywords,types,or words that should use the color. If the list is getting a bit long you can continue the list on the next line by ending the current line with a ,. After the list of the particular keyword, type, or word is completed end the line with a . This indicates to Cano that the list is complete. The default value for the "words" is meant to be a bit darker than the other keywords and types. This is to increase readability.

Canoon(Beta)

Canoon is the official Cano installer and manager, currently in beta. To learn about Canoon you can head over to the Canoon GitHub Repository or you can go to the Canoon section of the docs