VIM:VIMに焦点を合わせる
通常モードで画面の中央にカーソルを置いてください
:nnoremap j jzz
:nnoremap k kzz
ジャンプ・バック
ご存知のように、Vimはジャンプリストを持っており、以前はCTRLOとジャンプし、ジャンプリストに新しい位置に移動するCTRLiを使用してアクセスすることができます.
通常、
j
とk
はJumpListを変更しませんが、この動作を変更できます." source: https://www.vi-improved.org/vim-tips/
nnoremap <expr> j v:count ? (v:count > 5 ? "m'" . v:count : '') . 'j' : 'gj'
nnoremap <expr> k v:count ? (v:count > 5 ? "m'" . v:count : '') . 'k' : 'gk'
あなたが5j
を入力するならばフラッシュ関数
私はLuaを使用して設定私のneovimと私はcursorlineを無効にしている.私はcursorlineをフラッシュして、いくつかのジャンプに関連付ける機能を作成しました
-- ~/.config/nvim/lua/core/utils.lua
local M = {} -- M stands for module
-- https://vi.stackexchange.com/questions/31206
-- https://vi.stackexchange.com/a/36950/7339
M.flash_cursorline = function()
local cursorline_state = lua print(vim.opt.cursorline:get())
vim.opt.cursorline = true
vim.cmd([[hi CursorLine guifg=#FFFFFF guibg=#FF9509]])
vim.fn.timer_start(200, function()
vim.cmd([[hi CursorLine guifg=NONE guibg=NONE]])
if cursorline_state == false then
vim.opt.cursorline = false
end
end)
end
-- map helper
M.map = function(mode, lhs, rhs, opts)
local options = { noremap = true }
if opts then
options = vim.tbl_extend("force", options, opts)
end
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
end
map('n', 'n', 'nzz:lua require("core.utils").flash_cursorline()<CR>Nn')
map('n', 'N', 'Nzz:lua require("core.utils").flash_cursorline()Beacon<CR>nN')
-- Why nzzNn: https://vi.stackexchange.com/a/36950/7339
-- zz will remove the count display ([n/nn]) in the statusbar if the view is changed.
-- A quick and dirty solution to show the count again is to hit n or N again, ie.
-- nnoremap n nzzNn
map("n", "<C-o>", '<C-o>zv:lua require("core.utils").flash_cursorline()<CR>')
map("n", "<C-i>", '<C-i>zv:lua require("core.utils").flash_cursorline()<CR>')
return N
Reference
この問題について(VIM:VIMに焦点を合わせる), 我々は、より多くの情報をここで見つけました https://dev.to/voyeg3r/vim-enhancing-focus-on-vim-5giiテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol