Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kozo2/8498739171da1ec34aec91e6d920ff73 to your computer and use it in GitHub Desktop.
Save kozo2/8498739171da1ec34aec91e6d920ff73 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"このノートブックは https://thinca.hatenablog.com/entry/20100201/1265009821 の複写物になります。"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. 基礎"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 全てコマンド\n",
"Vimスクリプトはコマンドの羅列です。単純な代入や関数の呼び出し、if などの制御構文も全てコマンドです。\n",
"### echo コマンド"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello, world!"
]
}
],
"source": [
"echo 'Hello, world!'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
":echo コマンドの出力には必ず改行が含まれます。改行を含みたくない場合は :echon コマンドを使います。"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello, world!"
]
}
],
"source": [
"echon 'Hello, '\n",
"echon 'world!'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### コメント"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\" から行末までが行コメントです。"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"\" コメント"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Vimの~~キモい~~制約により、コマンドによってはコメントが使えない場合があります*1。\n",
"### 代入\n",
"値の代入には :let コマンドを使います。"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"let a = 1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### データの型\n",
"データには型があり、以下のいずれかです。\n",
"\n",
"- 整数値\n",
"- 小数値\n",
"- 文字列\n",
"- リスト\n",
"- 辞書\n",
"- 関数参照\n",
"\n",
"関数参照はこの記事では省略します。\n",
"\n",
"### 実行\n",
"実行するには :source コマンドを使います。"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Vim(source):E484: Can't open file script.vim"
]
}
],
"source": [
"source script.vim"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Vim",
"language": "",
"name": "vim_kernel"
},
"language_info": {
"file_extension": ".vim",
"mimetype": "text/plain",
"name": "vim"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment