Linux あれこれ

Linux 関連(一部 Windows11 )の備忘録です。

「Xubuntu 22.04.1 LTS」にて「nano」をカスタマイズ〈H162-3〉

登録日: 2023-01-05 更新日: 2023-01-08

前回、「Boxes」のゲストOS の「EndeavourOS (i3-wm)」(Arch 系)にて、一般的なキー定義に「nano」をカスタマイズしたら、使い勝手が良くなりました。

今回は、他のディストリビューションでもできるか、ホストOS の「Xubuntu 22.04.1 」(Ubuntu 系)で試しました。

その備忘録です。

-

-

使用したPC は「ASUS Chromebox CN60 」で、プロセッサは第4世代の「Intel Celeron 2955U 」です。

UEFI 立ち上げ」のPC です。

-

(注)リンクを戻るときはブラウザの左上の「←」をクリック

-

-


目次

-

前回の作業:

「EndeavourOS」(i3-wm) にて「nano」をカスタマイズ〈H162-2〉

-

参考: 「nano」の情報:

  1. 「nano」を起動する時のオプション:

  2. 「nano」の「ヘルプ」表示:

  3. 「nano」のデフォルトのショートカットキー:

  4. 「一般的なキー」にカスタマイズしたときのショートカットキー:

  5. 「nano」のデフォルトの設定ファイル(日本語のコメント行付き):

  6. 「nano」を使うときの留意点:

-

今回の作業:

  1. GitHub の「nano」の追加のハイライト定義ファイルをインストール:

  2. 追加のハイライト定義を使って、「nano」を「一般的な」キー定義にカスタマイズする場合:

  3. カスタマイズした「nano」で動作確認:

  4. 「nano」を「デフォルトの設定」に戻したい場合:

  5. 追加のハイライト定義を使わずに、「一般的な」キー定義にカスタマイズする場合:

  6. 個人的な色使いの「markdown」の定義ファイルと、「カスタマイズ」:

-

「まとめ へ」

「目次詳細 へ」

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - -

Xubuntu 22.04.1 LTS で、「Boxes」を使う:

-

ボックスの「EndeavourOS」(i3-wm) にて「nano」を使用:

-

(1). 起動した「nano」の画面:

→ハイライト表示の定義ファイルをすべて読み込んでいるので、 設定ファイルが色分けされて見やすいです。

-

カスタマイズしたので、ガイド行の表示が、一般的なキーに変わっていることに注目:

Ctrl + O オー で開いて、Ctrl + W で保存し、Ctrl + Q で終了。「ヘルプ表示」はCtrl + H です。

-

(2). 「i3-wm」はタイリングで「端末」画面を並べて使えるので、効率が上がります:

アプリ内で「コマンドを実行」できますが、「端末」画面をタイリングで並べた方が便利です。結果をマウスで範囲指定して、中央ボタンで貼付けできます。(カットバッファでなく、クリップボードが使われます)

-

ホストOS の「Xubuntu 22.04.1 」にて「nano」を使用:

-

ウィンドウのタイトルバーをつかんで、4隅にぶつけると、同じようにタイリングができます:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - --

ホストOS : Xubuntu 22.04.1 LTS

-

現在のバージョンを表示:

2023-01-08 現在

カーネル:

$ uname -r
5.15.0-57-generic

-

リリース:

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"

→ひとつ前のリリースを使う、安定志向のポイントリリース版(延命版)です。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ---

テキストエディタ「nano」について:

-

公式サイト:

The GNU nano homepage

-

「端末」画面で実行される CUI のエディタ(vim 等)に慣れていなくても、使えるのが利点です:

起動するだけで、すぐに文字入力が可能になり、矢印キーでカーソルの移動ができます。 画面の下にあるガイド行で、主要な(統一感がなく、クセが強めの)キー割当てが表示されます。 たぶん、覚えられないから逆に、ガイド行が生まれたのだろうと思います。

-

オンラインマニュアル:

Online Manual

-

現在のバージョン:
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"

-

$ nano --version
 GNU nano バージョン 6.2
 (C) 1999-2011, 2013-2022 Free Software Foundation, Inc.
 (C) 2014-2022 nano への貢献者たち
 コンパイルオプション: --disable-libmagic --enable-utf8

→最新は「7.1」なので、少し遅れぎみ。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----

1. 現在の状態を確認:

-

1). インストールされているかの確認:

$ apt list nano* --installed
:
nano/jammy,now 6.2-1 amd64 [インストール済み、自動]

→「nano」のみインストールされています。依存で入ったみたい。

-

2). カスタマイズ前の「nano」を起動:

$ nano

-

→クセが強めの「ガイド行」に注目。

-

3). 大元の設定ファイル:

$ ls /etc/nano*
:
/etc/nanorc

→設定を修正するときは、こちらのファイルはさわらずに、下記のファイルを作成して修正します。

-

4). 個人的な設定ファイル:

$ ls ~/.nanorc
:
ls: /home/ubn/.nanorc: そのようなファイルやディレクトリはありません

→ホームに設定ファイルはありませんでした。
つまり、「nano」はデフォルトの設定で動いているということ。

-

5). 「nano」の基本の構文(強調表示)ファイル:

プログラム言語別のハイライト表示の定義:

「nano」のインストールで一緒に入ります。

-

$ ls /usr/share/nano/*.nanorc
:
/usr/share/nano/asm.nanorc
/usr/share/nano/autoconf.nanorc
/usr/share/nano/awk.nanorc
/usr/share/nano/c.nanorc
/usr/share/nano/changelog.nanorc
/usr/share/nano/cmake.nanorc
/usr/share/nano/css.nanorc
/usr/share/nano/debian.nanorc (-> debian/debian.nanorc)
/usr/share/nano/default.nanorc
/usr/share/nano/elisp.nanorc
/usr/share/nano/email.nanorc
/usr/share/nano/go.nanorc
/usr/share/nano/groff.nanorc
/usr/share/nano/guile.nanorc
/usr/share/nano/haskell.nanorc ( -> extra/haskell.nanorc)
/usr/share/nano/html.nanorc
/usr/share/nano/java.nanorc
/usr/share/nano/javascript.nanorc
/usr/share/nano/json.nanorc
/usr/share/nano/lua.nanorc
/usr/share/nano/makefile.nanorc
/usr/share/nano/man.nanorc
/usr/share/nano/markdown.nanorc
/usr/share/nano/nanohelp.nanorc
/usr/share/nano/nanorc.nanorc
/usr/share/nano/nftables.nanorc
/usr/share/nano/objc.nanorc
/usr/share/nano/ocaml.nanorc
/usr/share/nano/patch.nanorc
/usr/share/nano/perl.nanorc
/usr/share/nano/php.nanorc
/usr/share/nano/po.nanorc
/usr/share/nano/python.nanorc
/usr/share/nano/ruby.nanorc
/usr/share/nano/rust.nanorc
/usr/share/nano/sh.nanorc
/usr/share/nano/sql.nanorc
/usr/share/nano/tcl.nanorc
/usr/share/nano/tex.nanorc
/usr/share/nano/texinfo.nanorc
/usr/share/nano/xml.nanorc
/usr/share/nano/yaml.nanorc

-

$ ls /usr/share/nano/debian/
:
debian.nanorc

→リンクされてます。

-

$ ls /usr/share/nano/extra/
:
ada.nanorc      haskell.nanorc  spec.nanorc
fortran.nanorc  povray.nanorc

→リンクされてます。

-

6). 「nano」のオプションの構文(強調表示)ファイル:

ハイライト表示の定義ファイル:

-

$ ls /usr/share/nano-syntax-highlighting/*.nanorc
:
ls: '/usr/share/nano-syntax-highlighting/*.nanorc' にアクセスできません: 
そのようなファイルやディレクトリはありません

-

7). 「nano-syntax-highlighting」がインストールできるか確認:

$ apt search syntax | grep nano
:
nano/jammy,now 6.2-1 amd64 [インストール済み、自動]

→「nano」のオプションの定義ファイルはリポジトリに登録されていないみたい。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - -----

2. 「nano」の既存の設定ファイルをバックアップ:

-

$ cp ~/.nanorc ~/.nanorc-ORG
:
cp: '/home/ubn/.nanorc' を stat できません: 
そのようなファイルやディレクトリはありません

→すでにカスタマイズしている場合があるので、それに備えて退避。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- -

3. 参考: 「nano-syntax-highlighting」構文(強調表示)ファイルのインストール

-

追加の定義ファイルなので、無くても色分けされないだけです。適用は好みです。

-

「nano」のインストールで「基本の定義ファイル」はインストールされますが、

追加の、「nano-syntax-highlighting」定義ファイルはインストールされません。

-

1). 参考: Arch 系の場合:

-

リポジトリからインストール:
$ sudo pacman -S nano-syntax-highlighting

→インストール先のフォルダを確認。

設定に記述されているフォルダ名が違う場合は、修正が必要です。たぶん、「~/.nano/*.nanorc」?

-

2). Ubuntu 系の場合:

-

GitHub からダウンロードしてインストール:

参考:

GitHub: scopatz/nanorc

-

(1). 「wget」をインストール:
$ sudo apt install wget
:
wget はすでに最新バージョン (1.21.2-2ubuntu1) です。

-

(2). インストール用のスクリプトをダウンロードすると、自動でインストールが実行:
$ wget https://raw.githubusercontent.com/scopatz/nanorc/master/install.sh -O- | sh
:
--2023-01-04 20:54:27--  https://raw.githubusercontent.com/scopatz/nanorc/master/install.sh

→「install.sh」が実行され、GitHub にある、すべての「.nanorc」ファイルが「~/.nano」に自動的に解凍されました。

-

(3). インストール完了:
$  ls ~/.nano/
:
AUTHORS.rst          haskell.nanorc     pov.nanorc
Dockerfile.nanorc    hcl.nanorc         powershell.nanorc
Rnw.nanorc           html.j2.nanorc     privoxy.nanorc
apacheconf.nanorc    html.nanorc        prolog.nanorc
arduino.nanorc       i3.nanorc          properties.nanorc
asciidoc.nanorc      ical.nanorc        pug.nanorc
asm.nanorc           ini.nanorc         puppet.nanorc
awk.nanorc           inputrc.nanorc     python.nanorc
batch.nanorc         install.sh         reST.nanorc
c.nanorc             jade.nanorc        readme.md
clojure.nanorc       java.nanorc        rego.nanorc
cmake.nanorc         javascript.nanorc  rever.xsh
coffeescript.nanorc  js.nanorc          rpmspec.nanorc
colortest.nanorc     json.nanorc        ruby.nanorc
conf.nanorc          keymap.nanorc      rust.nanorc
conky.nanorc         kickstart.nanorc   scala.nanorc
creole.nanorc        kotlin.nanorc      sed.nanorc
csh.nanorc           ledger.nanorc      sh.nanorc
csharp.nanorc        license            shellcheck.sh
css.nanorc           lisp.nanorc        sieve.nanorc
csv.nanorc           lua.nanorc         sls.nanorc
cython.nanorc        m3u.nanorc         sparql.nanorc
dot.nanorc           makefile.nanorc    sql.nanorc
dotenv.nanorc        man.nanorc         svn.nanorc
elixir.nanorc        markdown.nanorc    swift.nanorc
email.nanorc         moonscript.nanorc  systemd.nanorc
erb.nanorc           mpdconf.nanorc     tcl.nanorc
etc-hosts.nanorc     mutt.nanorc        tex.nanorc
fish.nanorc          nanorc             toml.nanorc
fortran.nanorc       nanorc.nanorc      ts.nanorc
fsharp.nanorc        nginx.nanorc       twig.nanorc
gemini.nanorc        nmap.nanorc        vala.nanorc
genie.nanorc         ocaml.nanorc       verilog.nanorc
gentoo.nanorc        octave.nanorc      vi.nanorc
git.nanorc           patch.nanorc       x11basic.nanorc
gitcommit.nanorc     peg.nanorc         xml.nanorc
glsl.nanorc          perl.nanorc        xresources.nanorc
go.nanorc            perl6.nanorc       yaml.nanorc
gophermap.nanorc     php.nanorc         yum.nanorc
gradle.nanorc        pkg-config.nanorc  zig.nanorc
groff.nanorc         pkgbuild.nanorc    zsh.nanorc
haml.nanorc          po.nanorc          zshrc.nanorc

→多くの定義ファイルが追加されました。

-

(4). 合わせて、ホームに設定ファイルの「~/.nanorc」が作成されました:

-

(5). 自動で作られた、設定ファイルを確認:
$  ls ~/.nanorc
:
/home/ubn/.nanorc

-

確認:

$  cat ~/.nanorc
include "~/.nano/apacheconf.nanorc"
include "~/.nano/arduino.nanorc"
include "~/.nano/asciidoc.nanorc"
include "~/.nano/asm.nanorc"
include "~/.nano/awk.nanorc"
include "~/.nano/c.nanorc"
include "~/.nano/clojure.nanorc"
include "~/.nano/cmake.nanorc"
include "~/.nano/coffeescript.nanorc"
include "~/.nano/colortest.nanorc"
include "~/.nano/conf.nanorc"
include "~/.nano/csharp.nanorc"
include "~/.nano/css.nanorc"
include "~/.nano/cython.nanorc"
include "~/.nano/dot.nanorc"
include "~/.nano/dotenv.nanorc"
include "~/.nano/email.nanorc"
include "~/.nano/Dockerfile.nanorc"
include "~/.nano/etc-hosts.nanorc"
include "~/.nano/fish.nanorc"
include "~/.nano/fortran.nanorc"
include "~/.nano/gentoo.nanorc"
include "~/.nano/git.nanorc"
include "~/.nano/gitcommit.nanorc"
include "~/.nano/glsl.nanorc"
include "~/.nano/go.nanorc"
include "~/.nano/gradle.nanorc"
include "~/.nano/groff.nanorc"
include "~/.nano/haml.nanorc"
include "~/.nano/haskell.nanorc"
include "~/.nano/html.nanorc"
include "~/.nano/html.j2.nanorc"
include "~/.nano/ical.nanorc"
include "~/.nano/ini.nanorc"
include "~/.nano/inputrc.nanorc"
include "~/.nano/jade.nanorc"
include "~/.nano/java.nanorc"
include "~/.nano/javascript.nanorc"
include "~/.nano/js.nanorc"
include "~/.nano/json.nanorc"
include "~/.nano/keymap.nanorc"
include "~/.nano/kickstart.nanorc"
include "~/.nano/kotlin.nanorc"
include "~/.nano/ledger.nanorc"
include "~/.nano/lisp.nanorc"
include "~/.nano/lua.nanorc"
include "~/.nano/makefile.nanorc"
include "~/.nano/man.nanorc"
include "~/.nano/markdown.nanorc"
include "~/.nano/mpdconf.nanorc"
include "~/.nano/mutt.nanorc"
include "~/.nano/nanorc.nanorc"
include "~/.nano/nginx.nanorc"
include "~/.nano/nmap.nanorc"
include "~/.nano/ocaml.nanorc"
include "~/.nano/patch.nanorc"
include "~/.nano/peg.nanorc"
include "~/.nano/perl.nanorc"
include "~/.nano/perl6.nanorc"
include "~/.nano/php.nanorc"
include "~/.nano/pkg-config.nanorc"
include "~/.nano/pkgbuild.nanorc"
include "~/.nano/po.nanorc"
include "~/.nano/pov.nanorc"
include "~/.nano/privoxy.nanorc"
include "~/.nano/puppet.nanorc"
include "~/.nano/pug.nanorc"
include "~/.nano/python.nanorc"
include "~/.nano/reST.nanorc"
include "~/.nano/rpmspec.nanorc"
include "~/.nano/ruby.nanorc"
include "~/.nano/rust.nanorc"
include "~/.nano/scala.nanorc"
include "~/.nano/sed.nanorc"
include "~/.nano/sh.nanorc"
include "~/.nano/sls.nanorc"
include "~/.nano/sql.nanorc"
include "~/.nano/svn.nanorc"
include "~/.nano/swift.nanorc"
include "~/.nano/systemd.nanorc"
include "~/.nano/tcl.nanorc"
include "~/.nano/tex.nanorc"
include "~/.nano/vala.nanorc"
include "~/.nano/verilog.nanorc"
include "~/.nano/vi.nanorc"
include "~/.nano/xml.nanorc"
include "~/.nano/xresources.nanorc"
include "~/.nano/yaml.nanorc"
include "~/.nano/yum.nanorc"
include "~/.nano/zsh.nanorc"

→ダウンロードした定義ファイルが設定ファイルに指定されています。 ただし、(完全ではなかったのか)いくつかは除外されています。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- --

4. 一般的なキー定義にカスタマイズした設定ファイル「~/.nanorc」を作成:

-


1). インストールで自動で作られた「設定ファイル」をバックアップ:

-

$ mv ~/.nanorc ~/.nanorc-Github

-


2). 設定ファイル「~/.nanorc」を作成:

使うエディタはどれでもよいです。

$ mousepad ~/.nanorc

↓ 下記をすべて貼付け:

## include ~/.nano/*.nanorc
### GitHub の最新の定義を読込:
include "~/.nano/apacheconf.nanorc"
include "~/.nano/arduino.nanorc"
include "~/.nano/asciidoc.nanorc"
include "~/.nano/asm.nanorc"
include "~/.nano/awk.nanorc"
include "~/.nano/c.nanorc"
include "~/.nano/clojure.nanorc"
include "~/.nano/cmake.nanorc"
include "~/.nano/coffeescript.nanorc"
include "~/.nano/colortest.nanorc"
include "~/.nano/conf.nanorc"
include "~/.nano/csharp.nanorc"
include "~/.nano/css.nanorc"
include "~/.nano/cython.nanorc"
include "~/.nano/dot.nanorc"
include "~/.nano/dotenv.nanorc"
include "~/.nano/email.nanorc"
include "~/.nano/Dockerfile.nanorc"
include "~/.nano/etc-hosts.nanorc"
include "~/.nano/fish.nanorc"
include "~/.nano/fortran.nanorc"
include "~/.nano/gentoo.nanorc"
include "~/.nano/git.nanorc"
include "~/.nano/gitcommit.nanorc"
include "~/.nano/glsl.nanorc"
include "~/.nano/go.nanorc"
include "~/.nano/gradle.nanorc"
include "~/.nano/groff.nanorc"
include "~/.nano/haml.nanorc"
include "~/.nano/haskell.nanorc"
include "~/.nano/html.nanorc"
include "~/.nano/html.j2.nanorc"
include "~/.nano/ical.nanorc"
include "~/.nano/ini.nanorc"
include "~/.nano/inputrc.nanorc"
include "~/.nano/jade.nanorc"
include "~/.nano/java.nanorc"
include "~/.nano/javascript.nanorc"
include "~/.nano/js.nanorc"
include "~/.nano/json.nanorc"
include "~/.nano/keymap.nanorc"
include "~/.nano/kickstart.nanorc"
include "~/.nano/kotlin.nanorc"
include "~/.nano/ledger.nanorc"
include "~/.nano/lisp.nanorc"
include "~/.nano/lua.nanorc"
include "~/.nano/makefile.nanorc"
include "~/.nano/man.nanorc"
include "~/.nano/markdown.nanorc"
include "~/.nano/mpdconf.nanorc"
include "~/.nano/mutt.nanorc"
include "~/.nano/nanorc.nanorc"
include "~/.nano/nginx.nanorc"
include "~/.nano/nmap.nanorc"
include "~/.nano/ocaml.nanorc"
include "~/.nano/patch.nanorc"
include "~/.nano/peg.nanorc"
include "~/.nano/perl.nanorc"
include "~/.nano/perl6.nanorc"
include "~/.nano/php.nanorc"
include "~/.nano/pkg-config.nanorc"
include "~/.nano/pkgbuild.nanorc"
include "~/.nano/po.nanorc"
include "~/.nano/pov.nanorc"
include "~/.nano/privoxy.nanorc"
include "~/.nano/puppet.nanorc"
include "~/.nano/pug.nanorc"
include "~/.nano/python.nanorc"
include "~/.nano/reST.nanorc"
include "~/.nano/rpmspec.nanorc"
include "~/.nano/ruby.nanorc"
include "~/.nano/rust.nanorc"
include "~/.nano/scala.nanorc"
include "~/.nano/sed.nanorc"
include "~/.nano/sh.nanorc"
include "~/.nano/sls.nanorc"
include "~/.nano/sql.nanorc"
include "~/.nano/svn.nanorc"
include "~/.nano/swift.nanorc"
include "~/.nano/systemd.nanorc"
include "~/.nano/tcl.nanorc"
include "~/.nano/tex.nanorc"
include "~/.nano/vala.nanorc"
include "~/.nano/verilog.nanorc"
include "~/.nano/vi.nanorc"
include "~/.nano/xml.nanorc"
include "~/.nano/xresources.nanorc"
include "~/.nano/yaml.nanorc"
include "~/.nano/yum.nanorc"
include "~/.nano/zsh.nanorc"

## Display line numbers to the left (and any anchors in the margin).
### 左側に行番号を表示 (および余白にアンカーを表示): 未使用
#set linenumbers

## If you would like nano to have keybindings that are more "usual":
### 「一般的な」キーバインドに変更:
bind ^X cut main
bind ^C copy main
bind ^V paste all
bind ^Q exit all
bind ^S savefile main
bind ^W writeout main
bind ^O insert main
set multibuffer
bind ^H help all
bind ^H exit help
bind ^F whereis all
bind ^G findnext all
bind ^B wherewas all
bind ^D findprevious all
bind ^R replace main
bind ^Z undo main
bind ^Y redo main
unbind ^K main
unbind ^U all
unbind ^N main
unbind ^Y all
unbind M-J main
unbind M-T main
bind ^A mark main
bind ^P location main
bind ^T gotoline main
bind ^T gotodir browser
bind ^T cutrestoffile execute
bind ^L linter execute
bind ^E execute main

-


3). nano を起動して確認:

行番号を表示すると、マウスで範囲選択時に含まれて使いづらくなるので、設定では無効にしました:

コマンド起動時に指定する方がやりやすいです。

もし、マウスを使わないならコメントを解除しても良いです。

-

行番号を表示しないとき:
$ nano

-

行番号を表示したいとき:
$ nano -l

→「-l」小文字のエル を付けて起動

-

画面下のガイド行も、ヘルプ時の内容も、設定したキーに合わせて変更されました:
^H ヘルプ      ^W 書き込み    ^F 検索        ^X 切り取り    ^E コマンドを実^P 位置        ^Z Undo        ^A マークを設置
^Q 終了        ^O 読み込み    ^R 置換        ^V 貼り付け    ^J 均等割付    ^T 行を指定    M-E Redo       ^C コピー

→操作がわからないときは Ctrl+ H でヘルプ表示。Ctrl+ H でヘルプが閉じます。

-

^H」は、「Ctrl + H」を押します。

M-E」は、「Alt + E」を押します。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ---

5. 一般的なキーにカスタマイズした「nano」を使って確認:

-

ショートカットキーの変化と、設定で組み込んだ構文(強調表示)ファイルが機能するかを確認。

-

1). 作業するディレクトリに移動:

$ mkdir -p  ~/ドキュメント/test
$ cd ~/ドキュメント/test/

→作業用のディレクトリを作っておくとファイル選択しやすくなります。

-

2). いつもの「Python」言語で確認:

$ nano hello.py

↓ 下記を貼付け:

print("Hello world!")

name = input('input your name: ')
message = 'Hello ' + name + ' !'
print(message)

Ctrl + W で保存:

書き込むファイル: hello.py                                                
^H ヘルプ         M-D DOS フォーマッM-A 末尾に追加    M-B バックアップファ
^C 取消           M-M Mac フォーマッM-P 先頭に追加    ^T ファイル一覧

→書き込むと、すぐにハイライト表示:

Ctrl + Q で終了

-

3). 基本の定義ファイルにない「Lisp」言語で確認:

$ nano hello.lisp

↓ 下記を貼付け:

(defun main ()
  (write-line "Hello world!"))

(sb-ext:save-lisp-and-die "hello"
                          :toplevel #'main
                          :executable t)

Ctrl + W で保存:

書き込むファイル: hello.lisp                                               
^H ヘルプ         M-D DOS フォーマッM-A 末尾に追加    M-B バックアップファ
^C 取消           M-M Mac フォーマッM-P 先頭に追加    ^T ファイル一覧

→書き込むと、すぐにハイライト表示:

Ctrl + Q で終了

-

4). 行番号付きで「nano」を起動:

$ nano -l hello.lisp

-

→バッファにファイルの内容が読み込まれました:

-

5). Ctrl + H で「ヘルプ表示」:

Ctrl + H で終了

Ctrl + Q で終了

-

6). ファイル指定なしで「nano」を起動:

$ nano

-

7). Ctrl + O オーで「ファイルを開く」(バッファに読込):

新しいバッファへ読み込むファイル [./ から]:                              
^H ヘルプ               M-F 新しいバッファ      ^X コマンドを実行
^C 取消                 M-N 変換しない          ^T ファイル一覧

-

8). Ctrl + T で「ファイル一覧」を表示:

→矢印キーで「hello.lisp」ファイルを選んで、Enter

-

ファイルが 新しいバッファ [2/2] に読み込まれました:

Alt + 「←」 で以前のバッファ [1/2] に切替えできます:

→空のままです。

-

9). Ctrl + Q でバッファを「閉じます」

バッファ [2/2] が、[1/1] で表示されました:

-

10). Ctrl + P でカーソル位置を確認できます:

カーソル位置が 2行目にあったとき、マウスで 4行目をクリックするか、範囲選択して、位置指定したつもりになります。

→Ctrl + P で表示されているのは 2行目なので、削除とかすると、予期しないところが削除されます。

-

11). Ctrl + Q で、「nano」を「終了」

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----

6. 参考:「nano」を起動する時のオプション:

-

「nano」のコマンドのヘルプ表示から抜粋:

-

「こちら」 を参照:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- -----

7. 参考:「nano」の「ヘルプ」表示:

-

「nano」アプリで「ヘルプ」表示したときの抜粋:

-

1). nano の画面にある 4つのセクション:

表示例:

-

(1). 一番上の行は、「nano のバージョン、編集中のファイル名、更新の有無」を表示。

(2). 次に、「ファイルを編集する領域」。

(3). 下から 3行目は、「重要なメッセージ」を表示。

(4). 下から 2行は、「ショートカットキー」を表示。

-

2). 「ヘルプ」画面のショートカットキーの記述について:

(^) で表記されているショートカットは、Ctrl キーを押すか、Esc キーを二回続けて押します。

(M-) で表記されているショートカットは、Alt キー、Cmd キー、Esc キーなどのメタキーを押します。

また、Esc キーを二回押した後に 000 から 255 までの十進数を入力すると、コードに対応する文字を入力できます。

代替のキーストロークは、括弧で囲っています。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ---

7-1 . 「デフォルト」のショートカットキー:

-

「nano」の Ctrl+G の「ヘルプ」表示からの抜粋:

-

Ctrl+G  (F1)         ヘルプを表示
Ctrl+X  (F2)         現在のバッファを閉じて nano を終了
Ctrl+O  (F3)         現在のバッファ(またはマークした範囲)をディスクへ書き込み
Ctrl+R  (Ins)        他のファイルから現在のバッファ(または新しいバッファ)に読み込み

Ctrl+W  (F6)         正規表現で文字列を前方に向かって検索
Ctrl+\  (Alt+R)      正規表現置換
Ctrl+K  (F9)         現在の行(またはマークした範囲)を切り取って、カットバッファに格納
Ctrl+U  (F10)        カットバッファの内容をカーソル位置に貼り付け

Ctrl+T               関数または外部コマンドの実行
Ctrl+J  (F4)         段落を均等割付

Ctrl+C  (F11)        カーソル位置を表示
Ctrl+/  (Alt+G)      指定位置へ移動

Alt+U                直前の操作を取り消す (undo)
Alt+E                取り消した直前の操作をやり直す (redo)

Alt+A   (Ctrl+6)     カーソル位置から始まる単語をマーク
Alt+6   (Alt+Ctrl+)  現在の行(またはマークした範囲)をコピーして、カットバッファに格納

Alt+]                対応する括弧へ移動

Ctrl+Q               正規表現で文字列を後方に向かって検索
Alt+Q                次を検索(前方へ)
Alt+W                次を検索(後方へ)

Ctrl+B  (◂)          前の文字へ戻る
Ctrl+F  (▸)          次の文字へ進む
Ctrl+◂  (Alt+Space)  前の単語へ戻る
Ctrl+▸  (Ctrl+Space) 次の単語へ進む
Ctrl+A  (Home)       現在行の先頭へ移動
Ctrl+E  (End)        現在行の末尾へ移動

Ctrl+P  (▴)          前の行へ移動
Ctrl+N  (▾)          次の行へ移動
Alt+▴   (Alt+-)      文中のカーソル位置を変えずに一行上にスクロール
Alt+▾   (Alt++)      文中のカーソル位置を変えずに一行下にスクロール

Ctrl+▴  (Alt+7)      前のテキストブロックへ移動
Ctrl+▾  (Alt+8)      次のテキストブロックへ移動
Alt+(   (Alt+9)      段落の先頭へ移動、カーソルがその位置にある場合その前の段落へ移動
Alt+)   (Alt+0)      段落の末尾の次の位置へ移動、カーソルがその位置にある場合その次の段落へ移動

Ctrl+Y  (PgUp)       前のページへ移動
Ctrl+V  (PgDn)       次のページへ移動
Alt+\   (Ctrl+Home)  ファイルの先頭行へ移動
Alt+/   (Ctrl+End)   ファイルの最終行へ移動

Alt+◂   (Alt+<)      前のバッファに切替え
Alt+▸   (Alt+>)      次のバッファに切替え

Ctrl+I  (Tab)        カーソル位置にタブ文字を挿入(またはマークした行をインデント)
Ctrl+M  (Enter)      行の挿入

Ctrl+H  (Bsp)            カーソルの前の文字を削除
Ctrl+D  (Del)            カーソル位置の文字を削除
Alt+Bsp (Shift+Ctrl+Del) カーソルから単語の先頭までを削除
Ctrl+Del                 カーソルから次の単語の先頭までを削除
Alt+T                    カーソル位置からファイル終端までを切り取り

Alt+J                ファイル全体を均等割付
Alt+D                行数、単語数、文字数を表示
Alt+V                後に続く特殊キーをそのまま入力

                     エディタを一時中断する (シェルに戻る)
Ctrl+L               画面の更新

Alt+}                現在行(またはマークされた行)をインデント
Alt+{   (Shift+Tab)  現在行(またはマークされた行)のインデントを縮小

Alt+3                現在行(またはマークされた行)をコメント/コメント解除
Ctrl+]               現在の単語の補完を試みる

Alt+:                マクロの記録を開始/停止
Alt+;                直前に記録されたマクロを実行

Alt+Ins              現在の行にアンカーを設置または削除
Alt+PgUp             後方にジャンプし直近のアンカーへ
Alt+PgDn             前方にジャンプし直近のアンカーへ

Alt+Del              現在行(またはマークされた範囲)を捨てる

F12                  スペルチェッカを起動 (利用可能な場合)
Alt+B                構文チェッカを起動 (利用可能な場合)
Alt+F                プログラムを呼び出しバッファを 整形/編集/操作します

Ctrl+L               カーソル位置の行を中寄せ

Ctrl+S               ファイルを確認なしで保存

Alt+Z                隠れたインターフェース 有効/無効
Alt+X                ヘルプ 有効/無効
Alt+C                常にカーソル位置を表示 有効/無効
Alt+S                長い行を画面上で折り返す 有効/無効
Alt+N                行番号 有効/無効
Alt+P                空白を表示 有効/無効
Alt+Y                単語の強調 有効/無効

Alt+H                スマートホームキー 有効/無効
Alt+I                自動インデント 有効/無効
Alt+K                改行の前まで削除 有効/無効
Alt+L                長い行を強制的に改行で折り返す 有効/無効
Alt+O                タブをスペースに変換 有効/無効
Alt+M                マウスのサポート 有効/無効

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----

7-2 . 「一般的なキー」にカスタマイズしたときの、ショートカットキー:

-

「nano」の Ctrl+H の「ヘルプ」表示からの抜粋:

Ctrl+H  (F1)         ヘルプを表示
Ctrl+Q  (F2)         現在のバッファを閉じて nano を終了
Ctrl+W  (F3)         現在のバッファ(またはマークした範囲)をディスクへ書き込み
Ctrl+O  (Ins)        他のファイルから現在のバッファ(または新しいバッファ)に読み込み

Ctrl+F  (F6)         正規表現で文字列を前方に向かって検索
Ctrl+R  (Ctrl+\)     正規表現置換
Ctrl+X  (F9)         現在の行(またはマークした範囲)を切り取って、カットバッファに格納
Ctrl+V  (F10)        カットバッファの内容をカーソル位置に貼り付ける

Ctrl+E               関数または外部コマンドの実行
Ctrl+J  (F4)         段落を均等割付

Ctrl+P  (F11)        カーソル位置を表示
Ctrl+T  (Ctrl+/)     指定位置へ移動

Ctrl+Z  (Alt+U)      直前の操作を取り消す (undo)
Alt+E                取り消した直前の操作をやり直す (redo)

Ctrl+A  (Alt+A)      カーソル位置から始まる単語をマーク
Ctrl+C  (Alt+6)      現在の行(またはマークした範囲)をコピーして、カットバッファに格納

Alt+]                対応する括弧へ移動

Ctrl+B               正規表現で文字列を後方に向かって検索
Ctrl+D  (Alt+Q)      次を検索(前方へ)
Ctrl+G  (Alt+W)      次を検索(後方へ)

◂                    前の文字へ戻る
▸                    次の文字へ進む
Ctrl+◂  (Alt+Space)  前の単語へ戻る
Ctrl+▸  (Ctrl+Space) 次の単語へ進む
Home                 現在行の先頭へ移動
End                  現在行の末尾へ移動

▴                    前の行へ移動
▾                    次の行へ移動
Alt+▴    (Alt+-)     文中のカーソル位置を変えずに一行上にスクロール
Alt+▾    (Alt++)     文中のカーソル位置を変えずに一行下にスクロール

Ctrl+▴   (Alt+7)     前のテキストブロックへ移動
Ctrl+▾   (Alt+8)     次のテキストブロックへ移動
Alt+(    (Alt+9)     段落の先頭へ移動、カーソルがその位置にある場合、
                       その前の段落へ移動
Alt+)    (Alt+0)     段落の末尾の次の位置へ移動、カーソルがその位置にある場合、
                       その次の段落へ移動

PgUp     (F7)        前のページへ移動
PgDn     (F8)        次のページへ移動
Alt+\    (Ctrl+Home) ファイルの先頭行へ移動
Alt+/    (Ctrl+End)  ファイルの最終行へ移動

Alt+◂    (Alt+<)     前のバッファに切替え
Alt+▸    (Alt+>)     次のバッファに切替え

Ctrl+I   (Tab)       カーソル位置にタブ文字を挿入(またはマークした行をインデント)
Ctrl+M   (Enter)     行の挿入

Bsp      (Shift+Del)      カーソルの前の文字を削除
Del                       カーソル位置の文字を削除
Alt+Bsp  (Shift+Ctrl+Del) カーソルから単語の先頭までを削除
Ctrl+Del                  カーソルから次の単語の先頭までを削除
                          カーソル位置からファイル終端までを切り取り

             ファイル全体を均等割付
Alt+D        行数、単語数、文字数を表示
Alt+V        後に続く特殊キーをそのまま入力

             エディタを一時中断する (シェルに戻る)
Ctrl+L       画面の更新

Alt+}                     現在行(またはマークされた行)をインデント
Alt+{    (Shift+Tab)      現在行(またはマークされた行)のインデントを縮小

Alt+3        現在行(またはマークされた行)をコメント/コメント解除
Ctrl+]       現在の単語の補完を試みる

Alt+:        マクロの記録を開始/停止
Alt+;        直前に記録されたマクロを実行する

Alt+Ins      現在の行にアンカーを設置または削除
Alt+PgUp     後方にジャンプし直近のアンカーへ
Alt+PgDn     前方にジャンプし直近のアンカーへ

Alt+Del      現在行(またはマークされた範囲)を捨てる

F12          スペルチェッカを起動 (利用可能な場合)
Alt+B        構文チェッカを起動 (利用可能な場合)
Alt+F        プログラムを呼び出しバッファを 整形/編集/操作します

Ctrl+L       カーソル位置の行を中寄せ

Ctrl+S       ファイルを確認なしで保存

Alt+Z         隠れたインターフェース 有効/無効
Alt+X         ヘルプ 有効/無効
Alt+C         常にカーソル位置を表示 有効/無効
Alt+S         長い行を画面上で折り返す 有効/無効
Alt+N         行番号 有効/無効
Alt+P         空白を表示 有効/無効
Alt+Y         単語の強調 有効/無効

Alt+H         スマートホームキー 有効/無効
Alt+I         自動インデント 有効/無効
Alt+K         改行の前まで削除 有効/無効
Alt+L         長い行を強制的に改行で折り返す 有効/無効
Alt+O         タブをスペースに変換 有効/無効
Alt+M         マウスのサポート 有効/無効

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- -

8. 参考:「nano」のデフォルトの設定ファイル: ★

-

日本語のコメント行は、実際にはありません。
わかりやすくするために追記しました。

-

1). 設定を変更するときは、こちらではなく、「~/.nanorc」を作成して変更点を追記します。

-

2). 「nano」の設定ファイルの内容を確認:

$ cat /etc/nanorc
## Sample initialization file for GNU nano.
### GNU nano の初期化ファイルのサンプル
##
## For the options that take parameters, the default value is shown.
## Other options are unset by default.  To make sure that an option
## is disabled, you can use "unset <option>".
### パラメータのあるオプションは、デフォルト値を表示してます。
### その他のオプションは、デフォルトでは設定されていません。
### オプションが無効かの確認は、「unset <option>」を使います。
##
## Characters that are special in a shell should not be escaped here.
## Inside string parameters, quotes should not be escaped -- the last
## double quote on the line will be seen as the closing quote.
### シェルで特殊な文字は、ここでエスケープしないでください。
### 文字列パラメーター内では、引用符をエスケープしないでください。
### 行の最後の二重引用符は、終了引用符と見なされます。

## Make 'nextword' (Ctrl+Right) and 'chopwordright' (Ctrl+Delete)
## stop at word ends instead of at beginnings.
### 「次の単語」(Ctrl+「→」)と「単語の右を切る」(Ctrl+Delete) を、
### 単語の先頭ではなく末尾で停止させます:
# set afterends

## When soft line wrapping is enabled, make it wrap lines at blanks
## (tabs and spaces) instead of always at the edge of the screen.
### ソフト行折り返しが有効な場合、常に画面の端ではなく、
### 空白 (タブとスペース) で行を折り返します:
# set atblanks

## Automatically indent a newly created line to the same number of
## tabs and/or spaces as the preceding line -- or as the next line
## if the preceding line is the beginning of a paragraph.
### 新しく作成された行を、前の行と同じ数のタブ、
### および/またはスペースに自動的にインデントします。
### 前の行が段落の始まりの場合は、次の行にインデントします:
# set autoindent

## Back up files to the current filename plus a tilde.
### ファイルを「現在のファイル名~」にバックアップします: ☆
# set backup

## The directory to put unique backup files in.
### 一意のバックアップ ファイルを配置するディレクトリ: ☆
# set backupdir ""

## Use bold text instead of reverse video text.
### 反転したテキストの代わりに、太字のテキストを使います:
# set boldtext

## Treat any line with leading whitespace as the beginning of a paragraph.
### 先頭に空白がある行は、段落の始まりとして扱います:
# set bookstyle

## The characters treated as closing brackets when justifying paragraphs.
## This may not include any blank characters.  Only closing punctuation,
## optionally followed by these closing brackets, can end sentences.
### 段落のときに閉じ括弧として扱われる文字。
### これには空白文字を含めることはできません。
### 文を終了できるのは、オプションで指定する
### これらの閉じ括弧が後に続く閉じ括弧のみです:
# set brackets ""')>]}"

## Automatically hard-wrap the current line when it becomes overlong.
### 現在の行が長くなりすぎると、自動的にハードラップします:
# set breaklonglines

## Do case-sensitive searches by default.
### デフォルトで大文字と小文字を区別して検索します:
# set casesensitive

## Constantly display the cursor position in the status bar or minibar.
### ステータスバーまたはミニバーに常にカーソル位置を表示します:
# set constantshow

## Use cut-from-cursor-to-end-of-line by default.
### デフォルトでは、カーソルから行末までのカットを使用します:
# set cutfromcursor

## Do not use the line below the title bar, leaving it entirely blank.
### タイトル バーの下の行は使用せず、完全に空白のままにします:
# set emptyline

## Set the target width for automatic hard-wrapping and for justifying
## paragraphs.  If the specified value is 0 or less, the wrapping point
## will be the terminal's width minus this number.
### 自動ハードラップと段落の両端揃えのターゲット幅を設定します。
### 指定値が 0 以下の場合、折り返し点は、
### 端末の幅からこの数値を引いた値になります:
# set fill -8

## Draw a vertical stripe at the given column, to help judge text width.
## (This option does not have a default value.)
### テキストの幅がわかりやすいように、指定された列に縦線を引きます:
###   (このオプションにはデフォルト値がありません。)
# set guidestripe 75

## Remember the used search/replace strings for the next session.
### 次のセッションのために、使用した検索/置換文字列を記憶します:
# set historylog

## Display a "scrollbar" on the righthand side of the edit window.
### 編集ウィンドウの右側に「スクロールバー」を表示します: ☆
# set indicator

## Scroll the buffer contents per half-screen instead of per line.
### 行ごとではなく、半画面ごとにバッファの内容をスクロールします:
# set jumpyscrolling

## Display line numbers to the left (and any anchors in the margin).
### 左側に行番号を表示 (および余白にアンカーを表示):
### (●● 行番号表示したいとき、下記のコメント解除)★
# set linenumbers

## Enable vim-style lock-files.  This is just to let a vim user know you
## are editing a file [s]he is trying to edit and vice versa.  There are
## no plans to implement vim-style undo state in these files.
### vim スタイルのロック ファイルを有効にします。
###  これは、編集しようとしているファイルを編集していること、
### およびその逆であることをユーザに知らせるためのものです:
# set locking

## Fall back to slow libmagic to try and determine an applicable syntax.
### 遅い libmagic に後退して、適用可能な構文を試して判断します:
# set magic

## The opening and closing brackets that are found by a matching-bracket
## search.  This may not contain blank characters.  The opening brackets
## must come before the closing ones, and they must be in the same order.
### 閉じ括弧の検索に使う「左の閉じ括弧」と「右の閉じ括弧」の指定には
### 空白文字を含めることはできません。
### 「左の閉じ括弧」は「右の閉じ括弧」より前に来なければならず、
### それらは同じ順序でなければなりません:
# set matchbrackets "(<[{)>]}"

## Suppress the title bar and show the filename plus a cursor-position
## percentage in the space of the status bar.
### タイトル バーを非表示にし、ステータス バーの領域に
### ファイル名とカーソル位置のパーセンテージを表示します:
# set minibar

## Enable mouse support, if available for your system.  When enabled,
## mouse clicks can be used to place the cursor, set the mark (with a
## double click), and execute shortcuts.  The mouse will work in the
## X Window System, and on the console when gpm is running.
### システムで利用可能な場合は、マウスのサポートを有効にします。
### 有効にすると、マウス クリックを使用してカーソルを配置できます。☆
### マークを設定(ダブルクリック)し、ショートカットを実行します。
### マウスは X Window System で動作し、gpm が実行されている場合は
### コンソールで動作します:
# set mouse

## Switch on multiple file buffers (inserting a file will put it into
## a separate buffer).
### 複数のファイル バッファをオンにします。
###  (ファイルを挿入すると、別のバッファに入れられます): ☆
# set multibuffer

## Don't convert files from DOS/Mac format.
### DOS/Mac フォーマットからファイルを変換しないでください:
# set noconvert

## Don't display the helpful shortcut lists at the bottom of the screen.
### 画面の下部に役立つショートカットの一覧を表示しません: ☆
# set nohelp

## Don't automatically add a newline when a file does not end with one.
### ファイルが改行で終わっていない場合、自動的に改行を追加しません:
# set nonewlines

## Set operating directory.  nano will not read or write files outside
## this directory and its subdirectories.  Also, the current directory
## is changed to here, so any files are inserted from this dir.  A blank
## string means the operating-directory feature is turned off.
### 操作するディレクトリを設定します。
### nano は、このディレクトリとそのサブディレクトリ以外の
### ファイルを読み書きしません。
### 現在のディレクトリがここに変更されるため、ファイルは
### このディレクトリから挿入されます。
### 空白の指定は、この機能がオフになっていることを意味します: ☆
# set operatingdir ""

## Remember the cursor position in each file for the next editing session.
### 次の編集のために、各ファイルのカーソル位置を記憶します: ☆
# set positionlog

## Preserve the XON and XOFF keys (^Q and ^S).
### XON および XOFF キー (^Q および ^S) を保持します:
# set preserve

## The characters treated as closing punctuation when justifying paragraphs.
## This may not contain blank characters.  Only these closing punctuations,
## optionally followed by closing brackets, can end sentences.
### 段落を正当化する際に、閉じ句読点として扱われる文字を指定。
### これには空白文字を含めることはできません。
### 文を終了できるのは、これらの閉じ句読点のみであり、
### オプションで閉じ括弧が続きます:
# set punct "!.?"

## Make status-bar messages disappear after 1 keystroke instead of after 20.
### ステータス バーのメッセージが 20 回ではなく 1 回のキーストロークで消えます:
# set quickblank

## The regular expression that matches quoting characters in email
## or line-comment introducers in source code.  The default is:
### 電子メールの引用文字またはソース コードの行コメント
### などの紹介に一致する正規表現。
### デフォルトは次のとおりです:
# set quotestr "^([     ]*([!#%:;>|}]|//))+"

## Try to work around a mismatching terminfo terminal description.
### terminfo の端末記述の不一致を回避します:
# set rawsequences

## Fix Backspace/Delete confusion problem.
### Backspace/Delete の混乱の問題を修正:
# set rebinddelete

## Do regular-expression searches by default.
## Regular expressions are of the extended type (ERE).
### デフォルトで正規表現検索を行います。
### 正規表現は拡張型 (ERE) です:
# set regexp

## Save a changed buffer automatically on exit; don't prompt.
### 終了時に変更されたバッファを自動的に保存します。
### プロンプトなし:
# set saveonexit

## Put the cursor on the highlighted item in the file browser, and
## show the cursor in the help viewer; useful for people who use a
## braille display and people with poor vision.
### ファイル ブラウザで強調表示された項目にカーソルを置き、
### ヘルプ ビューアにカーソルを表示します。
### 点字ディスプレイを使用している人や視力の弱い人に便利です:
# set showcursor

## Make the Home key smarter: when Home is pressed anywhere but at the
## very beginning of non-whitespace characters on a line, the cursor
## will jump to that beginning (either forwards or backwards).  If the
## cursor is already at that position, it will jump to the true start
## of the line (the left edge).
### 行の非空白文字の先頭以外の場所で Home を押すと、
### カーソルはその先頭にジャンプします (前方または後方)。
### カーソルがすでにその位置にある場合は、
### 行の真の開始点 (左端) にジャンプします:
# set smarthome

## Spread overlong lines over multiple screen lines.
### 長すぎる行を複数のスクリーン行に広げます:
# set softwrap

## Use this spelling checker instead of the internal one.  This option
## does not have a default value.
### 内部のスペル チェックではなく、このスペル チェックを使用します。
### このオプションにはデフォルト値がありません:
# set speller "aspell -x -c"

## Use the end of the title bar for some state flags: I = auto-indenting,
## M = mark, L = hard-wrapping long lines, R = recording, S = soft-wrapping.
### タイトル バーの末尾をいくつかの状態フラグに使用します。
### I = 自動インデント、M = マーク、L = 長い行のハード ラップ、
### R = 録音、S = ソフト ラップ:
# set stateflags

## Use this tab size instead of the default; it must be greater than 0.
### デフォルトの代わりにこのタブ サイズを使用します。☆
### 0 より大きくなければなりません:
# set tabsize 8

## Convert each typed tab to the fitting number of spaces.
### 入力された各タブを適切な数のスペースに変換します: ☆
# set tabstospaces

## Snip whitespace at the end of lines when justifying or hard-wrapping.
### 正当化またはハードラップする場合は、行末の空白を切り取ります:
# set trimblanks

## Save files by default in Unix format (also when they were DOS or Mac).
### デフォルトでファイルを Unix 形式で保存します。
###  (DOS または Mac の場合も同様)
# set unix

## The two single-column characters used to display the first characters
## of tabs and spaces.  187 in ISO 8859-1 (0000BB in Unicode) and 183 in
## ISO-8859-1 (0000B7 in Unicode) seem to be good values for these.
## The default when in a UTF-8 locale:
### タブとスペースの最初の文字を表示するために使用される 2 つの単一列文字。
### ISO 8859-1 では 187 (Unicode では 0000BB)、
### ISO-8859-1 では 183 (Unicode では 0000B7) が適切な値のようです。
### UTF-8 ロケールの場合のデフォルト:
# set whitespace "»·"
## The default otherwise:
### それ以外の場合のデフォルト:
# set whitespace ">."

## Detect word boundaries differently by treating punctuation
## characters as parts of words.
### 句読点を単語の一部として扱うことで、
### 単語の境界を別の方法で検出します:
# set wordbounds

## The characters (besides alphanumeric ones) that should be considered
## as parts of words.  This option does not have a default value.  When
## set, it overrides option 'set wordbounds'.
### 単語の一部と見なされる文字 (英数字以外)。
### このオプションにはデフォルト値がありません。
### 設定すると、オプション 'set wordbounds' がオーバーライドされます。
# set wordchars "<_>."

## Let an unmodified Backspace or Delete erase the marked region (instead
## of a single character, and without affecting the cutbuffer).
### 変更されていない Backspace または Delete で、
### マークされた領域を消去します
### (単一の文字ではなく、カットバッファに影響を与えずに)
# set zap

## Hide the bars plus help lines and use the whole terminal as edit area.
### バーとヘルプ行を非表示にして、
### 「端末」画面全体を編集エリアとして使用します: ☆
# set zero


## Paint the interface elements of nano.  These are examples; there are
## no colors by default, except for errorcolor and spotlightcolor.
### nano のインターフェース要素の色指定。 これらは例です。 ☆
### errorcolor と spotlightcolor を除いて、デフォルトでは色はありません。
# set titlecolor bold,white,blue
# set promptcolor lightwhite,grey
# set statuscolor bold,white,green
# set errorcolor bold,white,red
# set spotlightcolor black,lightyellow
# set selectedcolor lightwhite,magenta
# set stripecolor ,yellow
# set scrollercolor cyan
# set numbercolor cyan
# set keycolor cyan
# set functioncolor green

## In root's .nanorc you might want to use:
### ルートの .nanorc では、次を使用できます:
# set titlecolor bold,white,magenta
# set promptcolor black,yellow
# set statuscolor bold,white,magenta
# set errorcolor bold,white,red
# set spotlightcolor black,orange
# set selectedcolor lightwhite,cyan
# set stripecolor ,yellow
# set scrollercolor magenta
# set numbercolor magenta
# set keycolor lightmagenta
# set functioncolor magenta


## === Syntax coloring ===
## For all details, see 'man nanorc', section SYNTAX HIGHLIGHTING.
### === 構文の色分け ===
### すべての詳細については、「man nanorc」の
### 「SYNTAX HIGHLIGHTING」(構文の強調表示) を参照。

## To include most of the existing syntax definitions, you can do:
### 既存の構文定義のほとんどを含めるには、次のようにします: ☆
# include "/usr/share/nano/*.nanorc"

## Or you can select just the ones you need.  For example:
### または、必要なものだけを選択することもできます。例えば: ☆
# include "/usr/share/nano/html.nanorc"
# include "/usr/share/nano/python.nanorc"
# include "/usr/share/nano/sh.nanorc"

## In /usr/share/nano/extra/ you can find some syntaxes that are
## specific for certain distros or for some less common languages.
### /usr/share/nano/extra/ には、特定のディストリビューションや
### あまり一般的でない言語に固有の構文がいくつかあります。

## If <Tab> should always produce four spaces when editing a Python file,
## independent of the settings of 'tabsize' and 'tabstospaces':
### 'tabsize' と 'tabstospaces' の設定に関係なく、
### Python ファイルを編集するときに
### <Tab> が常に 4 つのスペースを生成する必要がある場合:
# extendsyntax python tabgives "    "

## If <Tab> should always produce an actual TAB when editing a Makefile:
### Makefile の編集時に <Tab> が常に実際の TAB を生成する必要がある場合:
# extendsyntax makefile tabgives "  "


## === Key bindings ===
## For all details, see 'man nanorc', section REBINDING KEYS.
### === キーバインディング ===
### すべての詳細については、「man nanorc」の
### 「REBINDING KEYS」(キーの再バインド)を参照。

## If you want to suspend nano with one keystroke (instead of with ^T^Z):
### nano を 1回のキーストロークで (^T^Z ではなく) サスペンドしたい場合:
# bind ^Z suspend main

## The <Ctrl+Delete> keystroke deletes the word to the right of the cursor.
## On some terminals the <Ctrl+Backspace> keystroke produces ^H, which is
## the ASCII character for backspace, so it is bound by default to the
## backspace function.  The <Backspace> key itself produces a different
## keycode, which is hard-bound to the backspace function.  So, if you
## normally use <Backspace> for backspacing and not ^H, you can make
## <Ctrl+Backspace> delete the word to the left of the cursor with:
### <Ctrl+Delete> キーストロークは、カーソルの右側の単語を削除します。
### 一部の端末では、<Ctrl+Backspace> キーストロークにより、
### バックスペースの ASCII 文字である ^H が生成されるため、
### デフォルトでバックスペース機能にバインドされます。
### <Backspace> キー自体が別のキーコードを生成し、
### これは backspace 関数にハードバインドされています。
### したがって、通常、バックスペースに ^H ではなく
### <Backspace> を使用する場合、次のように <Ctrl+Backspace> で
### カーソルの左側の単語を削除できます:
# bind ^H chopwordleft main

## For a more mnemonic Comment keystroke (overriding Cut-from-cursor):
### よりニーモニックなコメント キーストロークの場合 (Cut-from-cursor を上書き):
# bind M-K comment main

## If you want ^L to just refresh the screen and not center the cursor:
### ^L で画面を更新するだけで、カーソルを中央に配置しない場合:
# bind ^L refresh main

## When you sometimes type M-J instead of M-K, or M-T instead of M-R:
### M-K の代わりに M-J を入力したり、M-R の代わりに M-T を入力したりする場合:
# unbind M-J main
# unbind M-T main
## (Those functions are still accessible through ^T^J and ^T^V.)
### (これらの機能は、^T^J および ^T^V から引き続きアクセスできます。)

## For quickly uppercasing or lowercasing the word under or after the cursor.
## (These effectively select a word and pipe it through a sed command.)
### カーソルの下または後の単語をすばやく大文字または小文字にします。
### (これらは効果的に単語を選択し、それを sed コマンドにパイプします)
#bind Sh-M-U "{nextword}{mark}{prevword}{execute}|sed 's/.*/\U&/'{enter}" main
#bind Sh-M-L "{nextword}{mark}{prevword}{execute}|sed 's/.*/\L&/'{enter}" main

## For copying a marked region to the system clipboard:
### マークされた領域をシステムのクリップボードにコピーするには: ☆
# bind Sh-M-T "{execute}|xsel -ib{enter}{undo}" main

## For snipping trailing blanks when you save a file:
### ファイルを保存するときに末尾の空白を切り取るには:
# bind ^S "{execute}| sed 's/\s\+$//' {enter}{savefile}" main

## If you would like nano to have keybindings that are more "usual",
## such as ^O for Open, ^F for Find, ^H for Help, and ^Q for Quit,
## then uncomment these:
### nano にもっと「通常の」キー割り当てを持たせたい場合は、
### ^O で開く、^F で検索、^H でヘルプ、^Q で終了する場合は、
### これらのコメントを外します:
### (●●「通常の」キー操作にしたいとき、以下のコメントを解除)★
#bind ^X cut main
#bind ^C copy main
#bind ^V paste all
#bind ^Q exit all
#bind ^S savefile main
#bind ^W writeout main
#bind ^O insert main
#set multibuffer
#bind ^H help all
#bind ^H exit help
#bind ^F whereis all
#bind ^G findnext all
#bind ^B wherewas all
#bind ^D findprevious all
#bind ^R replace main
#bind ^Z undo main
#bind ^Y redo main
#unbind ^K main
#unbind ^U all
#unbind ^N main
#unbind ^Y all
#unbind M-J main
#unbind M-T main
#bind ^A mark main
#bind ^P location main
#bind ^T gotoline main
#bind ^T gotodir browser
#bind ^T cutrestoffile execute
#bind ^L linter execute
#bind ^E execute main

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- --

9. 参考: 「nano」を使うときの留意点:

-

1). 別に起動した「端末」画面と並べて使った方が効率アップします

「ファイルの後ろや頭にファイルの内容を追加」する機能(メニュー項目)がありますが、 「端末」画面でコマンドを実行し、範囲指定して、バッファに中央ボタンで貼付け、が楽です。

-

2). カーソルの移動に、マウスは使えないので注意。

マウスで範囲指定してそこを削除しようとして、別の場所が削除されたことがありました。 機能を理解していないと混乱します。

-

3). 記憶場所は 3つ:

  • ファイルが読み込まれる「バッファ」→複数持てます。

  • 「nano」の中で、Ctrl+C や Ctrl+V でコピーされる「カットバッファ」

  • マウスで範囲指定「クリップボード」→システムの機能で、中央ボタンで貼付け

  • 「nano」の外で、Ctrl+C や Ctrl+V でコピーされる「クリップボード」→システムの機能で、中央ボタンで貼付け

-

4). 「マウスで範囲指定」して、切り貼りするとき:

-

5). 通常は「行単位」のコピーと貼付け:

  • その行にカーソルを移動して、Ctrl+C(でカットバッファにコピー)。

  • Ctrl+V で(カットバッファを)貼付け。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- -----

10 . 「デフォルトの設定」に戻したい場合:

-

1). 一部の言語ファイルのみ、ハイライト定義を解除したい場合:

言語ファイルの「拡張子」が「ファイル名」です。

-

例: 「lisp」言語のみ、ハイライト定義を解除する場合:

$ mousepad ~/.nanorc

-

下記の 行をコメントにします:

include "~/.nano/lisp.nanorc"

# include "~/.nano/lisp.nanorc"

-

確認:
$ nano ~/ドキュメント/hello.lisp

→色分けされなくなりました。

-

2). 一時的に、デフォルトの設定に戻したい場合:

カスタマイズした設定も、ハイライト表示も解除したい場合:

$ mv ~/.nanorc ~/.nanorc-UnUsed

-

再び、カスタマイズの設定に戻す場合:

$ mv ~/.nanorc-UnUsed ~/.nanorc

-

3). 一時的に、キー定義のみ、デフォルトに戻したい場合:

$ cp ~/.nanorc ~/.nanorc-UnUsed
$ cp ~/.nanorc-Github ~/.nanorc

-

4). 再び使う予定がなく、すべて削除したい場合:

$ rm ~/.nanorc
$ rm -r ~/.nano

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- -

11 . ハイライトの定義をインストールせずに、一般的なショートカットキーにカスタマイズする場合:

-

まずは、カラー定義なしで使ってみるのも良いと思います。

基本の定義ファイルを使った場合の方がシンプルで、見やすい場合もあります。

-


1). 既存の「設定ファイル」をバックアップ:

$ cp ~/.nanorc ~/.nanorc-ORG2

-


2). 設定ファイル「~/.nanorc」の作成:

使うエディタはどれでもよいです。

$ mousepad ~/.nanorc

↓ すべて消してから、下記をすべて貼付け:

## Display line numbers to the left (and any anchors in the margin).
### 左側に行番号を表示 (および余白にアンカーを表示): 未使用
#set linenumbers

## If you would like nano to have keybindings that are more "usual":
### 「一般的な」キーバインドに変更:
bind ^X cut main
bind ^C copy main
bind ^V paste all
bind ^Q exit all
bind ^S savefile main
bind ^W writeout main
bind ^O insert main
set multibuffer
bind ^H help all
bind ^H exit help
bind ^F whereis all
bind ^G findnext all
bind ^B wherewas all
bind ^D findprevious all
bind ^R replace main
bind ^Z undo main
bind ^Y redo main
unbind ^K main
unbind ^U all
unbind ^N main
unbind ^Y all
unbind M-J main
unbind M-T main
bind ^A mark main
bind ^P location main
bind ^T gotoline main
bind ^T gotodir browser
bind ^T cutrestoffile execute
bind ^L linter execute
bind ^E execute main

-


3). nano を起動して確認:

画面下のガイド行のキー定義がカスタマイズされていることに注目:

-

基本の定義ファイルがある言語の場合:

$ nano ~/ドキュメント/hello.py

→色分けは、基本の定義ファイルが使われます。

-

基本の定義ファイルがない言語の場合:

$ nano ~/ドキュメント/hello.lisp

→基本の定義ファイルがないので、カラー表示なしです。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- --

12 . 個人的に使っている「カスタマイズ」と、色使いの「markdown」の定義ファイル:

-

markdown」ファイルの作成が多いので、使いやすい色使いの定義に修正しました:

定義ファイルの追加インストールはしましたが、色使いが好みではないので使っていません。 必要なときに、組み込めばいいかな。

-

1). 個人的に色分けした「markdown」の定義ファイルを作成:

追加の「markdown」の定義ファイルは、構文によって色使いの漏れがあるので、 「nano」と一緒に入った基本のハイライト定義ファイルの方を参考にしました:

-

$ mkdir -p ~/ダウンロード/test
$ mousepad ~/ダウンロード/test/markdown.nanorc

-

↓ すべて貼付け:

## Syntax highlighting for Markdown files.
### Markdown ファイルのシンタックス ハイライト:

## Original authors:  Ryan Westlund and Benno Schulenberg
## License:  GPL version 3 or newer

#syntax markdown "\.md$"
### 拡張子の指定:
syntax "Markdown" "\.(md|markdown)$"

### コメントの指定:
comment "<!--|-->"

# Quoted:
### 引用:
color brightmagenta "^[       ]*>.*"

# List-item markers:
### リスト項目マーカー:
color brightmagenta "^(    |    )* ? ? ?(\*|\+|-|[1-9]+\.)( +|  )"

# Emphasis and strong:
### 強調:
color yellow "\*[^*     ][^*]*\*|_[^_   ][^_]*_"
color brightyellow "\*\*[^*]+\*\*|__[^_]+__"

# Strikethrough:
### 取り消し線:
color red "~~[^~]+~~"

# Line breaks:
### 改行:
color ,blue "  $"

# URLs and links:
### URL とリンク:
color brightblue "\[[^]]+\]\([^)]+\)"
color magenta "!?\[[^]]+\]"

# Code snippet, indented code, and fenced code:
### コード指定:
color cyan "`[^`]+`"
color cyan "^(    |     )+ *([^*+0-9>   -]|[*+-]\S|[0-9][^.]).*"
color cyan start="```" end="```$"

# Headings and the underlining of headings:
### 見出し:
color brightgreen "^#.*"
color brightgreen "^(=+|-+)$"

# HTML tags and comments:
### HTML タグとコメント:
color brightblack "<[^>]+>"
color brightblack start="<!--" end="-->"

→よく使う機能のみ確認。その他は調整が必要かも。

コード指定の中で、ハイライト表示されるのが課題。

-

2). 設定ファイルの変更:

$ nano ~/.nanorc

-

↓ すべて貼付け:

### ハイライトの定義ファイル:
#include "~/.nano/markdown.nanorc"
include "~/ダウンロード/test/markdown.nanorc"

## Display line numbers to the left (and any anchors in the margin).
### 左側に行番号を表示 (および余白にアンカーを表示): 未使用
#set linenumbers

## Spread overlong lines over multiple screen lines.
### 長すぎる行を「ソフト行折り返し」します:
set softwrap

## When soft line wrapping is enabled, make it wrap lines at blanks
## (tabs and spaces) instead of always at the edge of the screen.
### 「ソフト行折り返し」が有効な場合、常に画面の端ではなく、
### 空白 (タブと半角スペース) で行を折り返します:
set atblanks
          
## If you would like nano to have keybindings that are more "usual":
### 「一般的な」キーバインドに変更:
bind ^X cut main
bind ^C copy main
bind ^V paste all
bind ^Q exit all
bind ^S savefile main
bind ^W writeout main
bind ^O insert main
set multibuffer
bind ^H help all
bind ^H exit help
bind ^F whereis all
bind ^G findnext all
bind ^B wherewas all
bind ^D findprevious all
bind ^R replace main
bind ^Z undo main
bind ^Y redo main
unbind ^K main
unbind ^U all
unbind ^N main
unbind ^Y all
unbind M-J main
unbind M-T main
bind ^A mark main
bind ^P location main
bind ^T gotoline main
bind ^T gotodir browser
bind ^T cutrestoffile execute
bind ^L linter execute
bind ^E execute main

→長すぎる行をソフト行折り返しするように設定しました。

-

3). 確認:

$ nano ~/ドキュメント/2023-01-07-test.md

-

ソフト行折り返し、が無効の設定の場合:

→色使いは見やすくなったと思います。

デフォルトでは、長い行は折り返されません。

コード指定が多い場合は、折返しは要りません。

-

ソフト行折り返し、を有効に設定した場合:

→ソフト行折り返しは、「半角スペース」か「Tab」で折り返す設定にしたので、見出しにある、最初の「半角スペース」で折り返されてます。

日本語の句読点の「、」や「。」でも、行が折り返されて欲しいところ。

-

回避策: 句読点の「、」や「。」の後ろに「半角スペース」を追加:

→ファイルをさわらずにそのままにしても良いし、「半角スペース」を付けても支障はないと思います。

-

-

-


まとめ

「nano」を、使い慣れた一般的なショートカットキーに(機能が違うけど)近づけてみたら、作業しやすくなりました。

機能を理解したことで、カスタマイズしていない、デフォルト定義の「nano」でも、以前より活用できそう。

-

ちなみに、ファイル指定して「nano」を起動した場合は、Ctrl + S(上書き保存)が使えます。編集中に、逐次使っています。ただし、警告なしで上書きされるので注意。

-

-

-


-

-

    目次

-

「投稿の先頭 へ」

-

-


-

「この目次 の先頭へ」

「本編の目次 に戻る」

-