0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

vimのmarksをquickfixに表示してみる

Posted at

marks一覧を覚えられない問題

vimを使うにあたり、vimのmarksを覚えられない問題があります。見やすくするためのプラグインは色々あります。
調べた範囲ではこのあたりですね。

いいですね!
でも僕は沢山プラグインを入れるのは好きではないのです。僕のvimの戦闘力は150です。関数でやります。

実装

function! Marks()
  let qflist = []
  for n in execute('marks')->split('\n')
    if str2nr(n[6:8]) == 0
      continue
    endif
    let qflist = qflist->add(
          \#{filename: n[15] == '/'? n[15:] : expand('%'),
          \lnum: str2nr(n[6:8]),
          \col: str2nr(n[11:13]),
          \text: n[1].': '.n[15:]})
  endfor
  call setqflist(qflist, 'r')
  copen
  hi QuickFixLine ctermbg=Yellow guibg=Yellow
  au QuickFixCmdPre hi
endfunction

関数はこんな感じ。あとはキーマップをあてましょう。

noremap <leader>` :silent! call Marks()<CR>

これで

<leader>`

を打てばquickfixに表示されて自分で選ぶ事ができます。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?