English 中文(简体)
VIM - 我如何把我目前的立场列入跳跃名单?
原标题:VIM - How can I put my current position in jumplist?
  • 时间:2014-11-28 17:58:13
  •  标签:
  • vim
  • shortcut

我很想知道,我能 vi回头来,在我最后一次停下3秒钟的时候,我可以 vi。 然后,我可以坐下来,并有一个小小小小.,在我与原来的CTRL+o站在一起时跳出来。

我很想知道,其中一半在我看来是毫无用处的,因此我怎么能这样做?

换言之,我试图使跳跃名单更加敏感。

ps: Netbeans and VS has a similar conduct.

最佳回答

为使现有职位自动列入jump list,您可使用CursorHold活动:

:autocmd CursorHold * normal! m 

导航为默认<代码><C-o>/<C-i>

问题回答

可在<代码>登记册上打上标记。 关键中点为<代码>m。

I found this in vim s documentation :help jumplist.

你们可以通过把标识“m”明确添加一个跳跃。

下面的<代码>vimrc设置。 它只在以下几段添加新的跳跃:<代码>CursorHold的触发点,这一段不是第1段)、由<代码>CursorHold设定的最近<代码>m的位置、跳跃或2)跳跃历史中目前选定的地点的位置(例如与<代码>的滚动;C-o>><C-i>。

function! s:reset_jumps() abort
  let [line1, line2] = [line(" {"), line(" }")]
  let [items, pos] = getjumplist()
  let pos = min([pos, len(items) - 1])  " returns length if outside of list
  let [prev, curr] = [line("  "), items[pos][ lnum ]]
  if (line1 > curr || line2 < curr) && (line1 > prev || line2 < prev)
    call feedkeys("m ",  n )  " update mark to current position
  endif
endfunction
augroup jumplist_setup
  au!
  au CursorHold * call s:reset_jumps()
augroup END

我也采取了以下不同的常规跳跃行为:

noremap n <Cmd>keepjumps normal! n<CR>
noremap N <Cmd>keepjumps normal! N<CR>
noremap ( <Cmd>keepjumps normal! (<CR>
noremap ) <Cmd>keepjumps normal! )<CR>
noremap { <Cmd>keepjumps normal! {<CR>
noremap } <Cmd>keepjumps normal! }<CR>




相关问题
Autoupdate VIM Plugins?

Is it possible to update vim plugins automatically?

how to unindent in vim without leaving edit mode?

I m writing a lot of python code recently, and i used the tab-to-space mode in vim. I was just wondering how would i unindent in vim without leaving edit mode for example after i finished if...: block....

Scrolling inside Vim in Mac s Terminal

I ve been googling around trying to figure out if it s possible to use my mouse wheel to scroll while inside Vim in Mac s Terminal, with no luck. It seems as if only X11 or iTerm support this. Before ...

Vim - Deleting XML Comments

How do I delete comments in XML? If the opening and the closing comment tags are on the same line, I use :g/^<!--.*-->$/d to delete the comment. How to delete the comments that are spread ...

Limiting a match in vim to certain filetypes?

I have the following in my .vimrc to highlight lines longer than 80 chars: highlight OverLength ctermbg=red ctermfg=white guibg=#592929 match OverLength /\%81v.*/ This works quite well. However, the ...

Profiling Vim startup time

I’ve got a lot of plugins enabled when using Vim – I have collected plugins over the years. I’m a bit fed up with how long Vim takes to start now, so I’d like to profile its startup and see which of ...

热门标签