我希望使用Vim进行无干扰的写作,而不是PyRoom/TextRoom。这篇文章已经告诉我如何获取大部分设置,但我还想知道如何启用类似TextRoom风格的流模式:
如何禁用回退和删除键(不包括像d$这样的快捷键)?
我希望使用Vim进行无干扰的写作,而不是PyRoom/TextRoom。这篇文章已经告诉我如何获取大部分设置,但我还想知道如何启用类似TextRoom风格的流模式:
如何禁用回退和删除键(不包括像d$这样的快捷键)?
您可以通过将特定键映射到特殊的<Nop>
目标来禁用单个键:
:inoremap <BS> <Nop>
:inoremap <Del> <Nop>
(假设您只想在插入模式下禁用它们。)
#!/bin/sh
saved_tty=$(stty -g < /dev/tty)
bail()
{
stty $saved_tty < /dev/tty
exit $?
}
trap bail EXIT INT
stty raw -echo < /dev/tty
while true ; do
ch=$(dd bs=1 count=1 < /dev/tty 2> /dev/null)
code=$(printf "%d" "'$ch")
if [ $code -eq 4 ] ; then
printf "\r\n" > /dev/tty
printf "\n"
break
elif [ $code -eq 13 -o $code -eq 10 ] ; then
printf "\r\n" > /dev/tty
printf "\n"
elif [ $code -ge 32 -a $code -lt 127 ] ; then
printf "%s" "$ch" > /dev/tty
printf "%s" "$ch"
fi
done
flow
,执行chmod a+x flow
,然后就可以使用了:$ flow > file.txt
Backspace and del not allowed
here just type and type.
Then hit Ctrl-D when you're done; no Enter
required.
$ flow
ffoorrggoott ttoo rreeddiirreecctt!!
clear
或将屏幕清除添加到脚本中。