【问题标题】:Re-open vim to same line after compiling tex编译tex后重新打开vim到同一行
【发布时间】:2023-03-25 11:37:02
【问题描述】:

我的 .vimrc 中有:

map = :w !pdflatex %

无需离开vim即可快速编写和编译tex。但是,当它编译完成并且我回到 vim 时,我在文档的顶部。有没有办法让这个映射让我回到我离开的那一行?谢谢!

【问题讨论】:

  • 我的 vim (7.4) 没有这种行为。您可能想要禁用一些其他映射和/或插件,以查看这是否是某种冲突。我还建议确保您拥有最新版本的 Vim。我还建议您像这样更改映射:nnoremap = :w !pdflatex %<cr>= 命令非常方便,因此您可能需要选择另一个映射,以免遮盖它,可以使用 <f5> 或使用更无用的键,如 <space><leader>
  • 我不知道为什么,但我将映射修改为:map = :w<CR>:silent !pdflatex %<CR>:!open %<.pdf<CR> :<CR>,这让我回到了我的位置。唯一的区别是它在不同的地方打开编译的pdf和回车。

标签: vim tex pdflatex


【解决方案1】:

您可以在 vimrc 中取消注释以保留您之前的位置。

" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
    au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif

【讨论】:

  • 你取消注释了什么? if 语句已经被取消注释了?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-29
  • 1970-01-01
  • 1970-01-01
  • 2021-12-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多