LoginSignup
6
6

More than 5 years have passed since last update.

toggle つくった

Last updated at Posted at 2015-06-10

Toggle つくった

toggle

テキストを onoff truefalse を相互に一発で書き換える。
Vim だと以下のようなプラグインがあった(使ってなかったが)。

※ switch.vim はかなり Advanced な事が出来るので、このカテゴリに収まりきらないが。

gif

機能

  • カーソル下(toggle:here)の word を次の word へ差し替え(Toggle)
  • この時カーソル位置を動かす(toggle:visit)、動かさない(toggle:there)で、カレント行の word を差し替え
  • ユーザーが単語グループのリストを設定可能
  • カーソル位置の Grammar スコープを使用する(gfm の中の coffeescript等で便利).
  • 特定スコープ限定と、デフォルト(*)の単語グループ
  • toggle:open-configでユーザー設定を開き、保存時に自動ロード
  • 複数カーソル(multiple cursor)で動作する
  • デフォルトの単語グループ全体を無効に出来る
  • デフォルトの単語グループの特定のスコープのみを無効に出来る

コマンド

  • toggle:here: カーソル下の word を差し替え
  • toggle:there: カレント行で、カーソル位置を変えずに、word を差し替え
  • toggle:visit: カレント行で、差し替え可能な word に移動して、差し替え
  • toggle:open-config: 設定ファイルを開く

Keymap

※ 個人的にはカーソルを移動しないで差し替える toggle:there がおすすめ。

デフォルトのキーマップは無し.

  • ノーマル・ユーザー
'atom-text-editor:not([mini])':
  'ctrl--': 'toggle:there'
'atom-text-editor.vim-mode.command-mode':
  '-': 'toggle:there'

設定例

# '*' is wildcard scope, which is always searched finally.
'*': [
  ['yes'   , 'no']
  ['up'    , 'down']
  ['right' , 'left']
  ['true'  , 'false']
  ['high'  , 'low']
  ['column', 'row']
  ['and'   , 'or']
  ['not'   , '']
  ['on'    , 'off']
  ['in'    , 'out']
  ['one'   , 'two'   , 'three']
  ['bar'   , 'bar']
],
'source.coffee': [
  ['this', '@']
  ['is'  , 'isnt']
  ['if'  , 'unless']
]

TODO

  • Support language specific keyword handling
  • Disable default words group by configuration.
  • Toggle without changing cursor position.
  • Highlight toggled word?
  • Improve default words group.
6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6