我们偶尔会有灵光一闪、稍踪即逝的绝妙想法,这些突发奇想何时会出现无从循迹、无法臆测,灵感来无影去无踪,我们必须在最短的时间、用最快的方法将之记录起来,以下介绍使用Obsidian将灵感快速新增成为笔记的方法。
- 第一种方法是立即建立一篇笔记。
- 第二个方法是直接新增到每日笔记,并将之变成待办事项。
- 第三个方法是使用AutoHotkey在外部直接输入文字再插入Obsidian对应位置。macOS的使用者请试试AppleScript或Alfred等方法来达成。
主要使用到的插件如下:
- Templater
- QuickAdd
- Advanced Obsidian URI (URI: 统一资源标识符)
💡 建议
灵感/闪念笔记应该在一天或两天里清理掉(整理、合并到永久笔记或删除),以免又形成另一个资料垃圾场。
方法1. 建立灵感笔记
使用QuickAdd新增一个Template的Choice,并设定一个快捷键。输入灵感文字後会产生同名的笔记。
操作步骤
- QuickAdd选项→新增Template: Fleeting note的Choice
- 指定【Template path】为「模板资料夹/templater-fleeting-note.md」
- 勾选【File Name Format】,【File Name】栏位输入「{{VALUE:灵光一闪}}」
- 【Create in folder】指定资料夹为「030-Inbox」
▼ templater-fleeting-note.md
---
created: [ <% tp.date.now("YYYY-MM-DD HH:mm") %> ]
aliases: [ <% tp.file.title %> ]
tags: [ fleeting, todo ]
---
# <% tp.file.title %>
Modified:: <%+ tp.file.last_modified_date() %>
<% tp.file.title %>
<% await tp.system.clipboard() %>
⚠️ 缺点
生成了一个新档案,最後需要删除或搬移等档案操作
方法2. 输入内容後新增到每日笔记
此方法适用有使用Obsidian每日笔记与任务管理的状况。在弹出视窗输入内容後直接插入每日笔记指定标题处。
操作步骤
- QuickAdd选项→新增Capture: Fleeting note的Choice
- 指定【File Name】栏位为「020-Daily/{{DATE:YYYY-MM-DD_ddd}}」
- 勾选【Task】以形成待办事项格式
- 勾选【Insert after】,指定要插入内容到那个段落
- 输入标题文字
- 勾选【Insert at end of section】
- 变更【Create line if not found】为【Bottom】
- 勾选【Capture format】并输入脚本码(全形倒引号要改成半形):
```js quickadd
let text = await this.quickAddApi.utility.getClipboard();
text = await this.quickAddApi.inputPrompt("✍添加灵感笔记", "输入内容", text);
text = text.replace("\n", "<br>");
return text;
⚠️ 缺点
方法1与方法2者都必须在Obsidian里操作,但有可能灵感来时正好在使用别的应用程式。
方法3. 由外部应用直接新增
不必在Obsidian里,直接执行AutoHotkey的弹出式视窗,输入内容後透过Advanced Obsidian URI将内容插入每日笔记的指定标题处。
;; fleeting-note.ahk
;; Input any ideas into Obsidian's Daily note.
;; Hotkey: Alt+D
;; Author: emisjerry, http://jdev.tw/blog/
#SingleInstance Force
global valut := "MOC"
global note := "020-Daily/" . A_YYYY . "-" . A_MM . "-" . A_DD . "_" . A_DDD
global heading := "靈光一閃"
!d::
text = %Clipboard%
text := MultiLineInputBox("Your ideas: ", text, "Insert your ideas into Daily note")
if (text != "") {
text := StrReplace(text, "`n", "<br>")
text := StrReplace(text, "`r", "")
text := encodeURI("- [ ] " . text) ;; encodes and changes to a todo item
text := StrReplace(text, "`n", "<br>")
text := StrReplace(text, "`r", "")
;;msgbox text=%text%$
Run obsidian://advanced-uri?vault=%valut%&filepath=%note%&heading=%heading%&data=%text%&mode=append
}
return
MultiLineInputBox(Text:="", Default:="", Caption:="Multi Line Input Box"){
static
ButtonOK:=ButtonCancel:= false
if !MultiLineInputBoxGui{
Gui, MultiLineInputBox: Font, s14, Segoe UI
Gui, MultiLineInputBox: add, Text, r1 w600 , % Text
Gui, MultiLineInputBox: add, Edit, r10 w600 vMultiLineInputBox, % Default
Gui, MultiLineInputBox: add, Button, w100 h50 x380 gMultiLineInputBoxOK , &OK
Gui, MultiLineInputBox: add, Button, w100 h50 x+10 gMultiLineInputBoxCancel, &Cancel
MultiLineInputBoxGui := true
}
GuiControl,MultiLineInputBox:, MultiLineInputBox, % Default
Gui, MultiLineInputBox: Show,, % Caption
SendMessage, 0xB1, 0, -1, Edit1, A
while !(ButtonOK||ButtonCancel)
continue
if ButtonCancel
return
Gui, MultiLineInputBox: Submit, NoHide
Gui, MultiLineInputBox: Cancel
return MultiLineInputBox
;----------------------
MultiLineInputBoxOK:
ButtonOK:= true
return
;----------------------
MultiLineInputBoxGuiEscape:
MultiLineInputBoxCancel:
ButtonCancel:= true
Gui, MultiLineInputBox: Cancel
return
}
encodeURI(Uri, Enc = "UTF-8")
{
StrPutVar(Uri, Var, Enc)
f := A_FormatInteger
SetFormat, IntegerFast, H
Loop
{
Code := NumGet(Var, A_Index - 1, "UChar")
If (!Code)
Break
If (Code >= 0x30 && Code <= 0x39 ; 0-9
|| Code >= 0x41 && Code <= 0x5A ; A-Z
|| Code >= 0x61 && Code <= 0x7A) ; a-z
Res .= Chr(Code)
Else
Res .= "%" . SubStr(Code + 0x100, -1)
}
SetFormat, IntegerFast, %f%
Return, Res
}
decodeURI(Uri, Enc = "UTF-8")
{
Pos := 1
Loop
{
Pos := RegExMatch(Uri, "i)(?:%[\da-f]{2})+", Code, Pos++)
If (Pos = 0)
Break
VarSetCapacity(Var, StrLen(Code) // 3, 0)
StringTrimLeft, Code, Code, 1
Loop, Parse, Code, `%
NumPut("0x" . A_LoopField, Var, A_Index - 1, "UChar")
StringReplace, Uri, Uri, `%%Code%, % StrGet(&Var, Enc), All
}
Return, Uri
}
StrPutVar(Str, ByRef Var, Enc = "")
{
Len := StrPut(Str, Enc) * (Enc = "UTF-16" || Enc = "CP1200" ? 2 : 1)
VarSetCapacity(Var, Len, 0)
Return, StrPut(Str, &Var, Enc)
}相关链接
- temlater-fleeting-note.md: https://gist.github.com/emisjerry/8939f9aa8f4de9eab377b1461cb4f9bd
- fleeting-note.ahk: https://gist.github.com/emisjerry/01ec842be695a5248db642206b96dee7
教学视频
Bilibili视频:https://www.bilibili.com/video/BV1Dq4y1d7YE/
##
