3

我最近开始在这里做复习任务(编辑第一篇文章/迟到的答案等)。

  • 起初我试图从 Firefox 本身进行编辑
  • 然后我开始复制到 Vim 并在那里进行格式化
  • 不久我发现它是Firefox 编辑多行文本字段的所有文本插件

所以现在我正试图找到下一步,这将消除所有那些鼠标点击(编辑/提交等)以仅在 Vim 上完成这项工作。Firefox 中的当前界面(只需单击一下即可为您提供下一篇第一篇文章)似乎非常有能力集成到 Vim 本身中,所以我想知道是否/如何实现这一点?

如果没有,您有哪些好的做法?

4

3 回答 3

1

好吧,这是一种方法:

  1. 安装Vimperator,一个很棒的类似 Vim 的 Firefox 插件
  2. 将以下内容添加到 ~/.vimperatorrc

    autocmd LocationChange .* :set editor="xterm -x vim"

浏览器中的 Vim 编辑器由 vim 按键控制,无需鼠标。赢。(替换您选择的 xterm,顺便说一句)

另一种方法是切换到终端并使用 w3m。很容易配置它以使用 vim 作为编辑器。但是,如果没有 JavaScript,使用 stackoverflow 就不是那么容易了。

于 2012-10-03T20:57:32.900 回答
1

特别是由于 Stack Overflow 等现代 Web 应用程序的用户界面越来越丰富(以及底层 JavaScript 要求),我建议不要离开浏览器,尤其是因为实现基于 Vim 的客户端(尽管可以使用curlwget等工具) ,甚至像webapi.vim这样的可用库)需要付出很多努力。

我发现使用您提到的 Firefox 附加组件(我已经转移到Pentadactyl,一个Vimperator分支)和一个单独的 GVIM 实例已经非常有效,特别是如果您简化它。我在一篇文中描述了如何自动设置markdownStack Overflow 文本区域的文件类型。

于 2012-10-04T08:35:53.207 回答
0

我刚开始尝试 w3m 在终端中浏览。您可以将所有键绑定更改为类似于 vim(对于特定于 web 的内容,我在 Vimium 中复制了绑定),并直接使用 vim 编辑站点上的文本字段。我只用了一天,我还不知道如何处理“你是机器人”的检查......但它似乎很好地缩小了 vim 编码和谷歌搜索 + 复制和将东西粘贴回vim。

我已经设置好了,所以当我在 w3m 中按 v 时,它会在 vim 中打开页面,我设置 vim 以立即将文件另存为 /tmp/w3m_scratch 并退出回 w3m。然后我转到我正在编码的 vim 实例,并使用另一个映射来切换水平分割与 /tmp/w3m_scratch 文件(即我感兴趣的网页)。这让我可以快速将页面上的所有信息获取到我正在编码的同一个 vim 实例中,并且可以使用 vim 的所有功能将来自 stackoverflow(或其他站点)的文本集成到我的工作中:

function! WriteW3MToScratch()
    " only if the file matches this highly specific reg exp will we do anything
    "(e.g. a file that looks like: .w3m/w3mtmp7352-3)
    if match(@%, "\.w3m/w3mtmp\\d\\+-\\d") != -1
        :silent! wq! /tmp/w3m_scratch
    endif
endfunction

function! ToggleW3M()
    if bufexists("/tmp/w3m_scratch")
        :bwipe! /tmp/w3m_scratch
    else
        :silent! split /tmp/w3m_scratch
    endif
endfunction

" anytime we read in a buffer, if it came from w3m then write to scratch
autocmd BufReadPost * :call WriteW3MToScratch()

" open/close horizontal split containing w3m_scratch
nnoremap <leader>w :call ToggleW3M()<cr>

我使用这个 git repo上的键盘映射文件作为基础,这就是我到目前为止所拥有的。我不得不说,这些设置确实让人感觉很 vim。

# w3m keymap file with Vim key bindings
# by Felipe Saa (https://github.com/felipesaa/A-vim-like-firefox-like-configuration-for-w3m)
# adapted by Matthew Bennett
#
# Ctrl      : C-, ^
# Escape    : ESC-, M-, ^[
# Space     : SPC, ' '
# Tab       : TAB, ^i, ^I
# Shift+Tab : ^[[Z
# Delete    : DEL, ^?
# Up        : UP, ^[[A
# Down      : DOWN, ^[[B
# Right     : RIGHT, ^[[C
# Left      : LEFT, ^[[D
# Re Pag    : M-[5~
# Av Pag    : M-[6~
# Enter     : C-j  RET(pendant confirm)

#-custom map commands..........................................................
# switch the color of links for light/dark colourscheme
keymap  SPCd    COMMAND         "SET_OPTION  anchor_color=yellow"
keymap  SPCl    COMMAND         "SET_OPTION  anchor_color=blue"
# skip past all the cruft on the stack sites to where the question is asked
keymap  st      COMMAND         "WHEREIS Ask\ Question;  CENTER_V;  NEXT_HALF_PAGE"

#-scrolling....................................................................
keymap  C-y     DOWN
keymap  C-e     UP
keymap  gg      BEGIN
keymap  G       END
keymap  C-d     NEXT_HALF_PAGE
keymap  C-u     PREV_HALF_PAGE
keymap  C-f     COMMAND         "NEXT_HALF_PAGE;  NEXT_HALF_PAGE"
keymap  C-b     COMMAND         "PREV_HALF_PAGE;  PREV_HALF_PAGE"
keymap  zz      CENTER_V
keymap  zt      COMMAND         "CENTER_V;        NEXT_HALF_PAGE"
keymap  zb      COMMAND         "CENTER_V;        PREV_HALF_PAGE"

#-cursor.......................................................................
keymap  l       MOVE_RIGHT1
keymap  h       MOVE_LEFT1
keymap  j       MOVE_DOWN1
keymap  k       MOVE_UP1
keymap  0       LINE_BEGIN
keymap  $       LINE_END
keymap  w       NEXT_WORD
keymap  b       PREV_WORD
keymap  C-o     UNDO            # Undo cursor movement.
# keymap  C-i  REDO             # Undo undone cursor movement (confused with TAB)

#-tab..........................................................................
# Close current tab and save it to be able to restore it.
keymap  x       COMMAND         "EXTERN 'echo %s >> ~/.w3m/RestoreTab.txt' ; CLOSE_TAB"

# new search in new tab (drops right into google search)
keymap  o       COMMAND         "GOTO https://google.com; GOTO_LINE 6; NEXT_LINK; GOTO_LINK"

# new search (drops right into google search)
keymap O        COMMAND         "TAB_GOTO https://google.com; GOTO_LINE 6; NEXT_LINK; GOTO_LINK"

keymap J        PREV_TAB        # Change focus to right tab
keymap K        NEXT_TAB        # Change focus to left tab
keymap gJ       TAB_LEFT        # Move tab to the left
keymap gK       TAB_RIGHT       # Move tab to the right
keymap yt       NEW_TAB         # Duplicate current tab
keymap gt       TAB_MENU        # Tab menu
keymap :t       TAB_MENU        # Tab menu
# keymap X        TAB_GOTO        /usr/lib/w3m/cgi-bin/restore_tab.cgi # Restore last closed tab

#-url operations...............................................................
keymap f        GOTO_LINK       # Follow link in current tab
keymap gf       TAB_LINK        # Follow link in a new foreground tab
keymap F        COMMAND         "TAB_LINK; PREV_TAB" # follow link under cursor in new background tab
keymap gF       MOVE_LIST_MENU  # link list --> move cursor to link
keymap r        RELOAD          # Reload current page.

#-link navigation..............................................................
keymap [        NEXT_LEFT_UP
keymap ]        NEXT_RIGHT_DOWN

#-history navigation...........................................................
keymap L        NEXT            # Go forward in history
keymap H        PREV            # Go back in history
keymap :b       SELECT_MENU     # Recent pages
keymap :B       HISTORY         # Show history

#-bookmarks....................................................................
# keymap C-d      ADD_BOOKMARK  # Add current page to bookmarks
# keymap gb       VIEW_BOOKMARK # Show bookmarks
# keymap :b       VIEW_BOOKMARK # Show bookmarks

#-search.......................................................................
keymap /        ISEARCH         # Enter find mode
keymap ?        ISEARCH_BACK    # Enter find mode backwards (incremental)
keymap n        SEARCH_NEXT     # Find next
keymap N        SEARCH_PREV     # Find previous

#-commands.....................................................................
keymap !        COMMAND         
keymap |        PIPE_BUF        # Send rendered document to pipe

keymap :h       HELP            # View help
keymap :o       OPTIONS         # Option setting panel
keymap :q       QUIT            # Quit w3m with confirmation (q alone works too)
keymap ZZ       EXIT            # Quit w3m without confirmation.

# Reload configuration files.
keymap :s       REINIT

#-info.........................................................................
keymap gC-g     INFO            # current page info
keymap C-g      LINE_INFO       # line under cursor info

#-miscellaneous................................................................
keymap v        EDIT_SCREEN     # Edit current rendered document with sensible-editor

#-unused url operations.......................................................
# keymap        PEEK                        # Show current page url.
# Focus in address bar.
# keymap ef    PEEK_LINK                    # Show link under cursor.
# Execute external browser = open current link in $BROWSER
# tip: number(2-9) + external browser shortcut(M-o) executes executes the
# external browser command linked to the prefix number.
# See "External Program Settings" in "Option Setting Panel"(OPTIONS)
# Open current link with external browser = sensible browser
# keymap M-o   EXTERN
# copy current url and remove newline at the end.
# keymap yy    EXTERN     copy_url.sh
# keymap yy       EXTERN     "echo -n %s | xclip -i -selection clipboard"
# keymap yy       EXTERN     "echo -n %s | xsel -b"
# open link under cursor with external browser = sensible browser
# keymap M-p   EXTERN_LINK
# Copy link under cursor, It does not copy images urls
# keymap yf       EXTERN_LINK 'env printf %s "$0" | xsel -b'
# keymap yf    EXTERN_LINK  copy_url.sh
# follow link in clipboard in the current tab.
# keymap p   GOTO       /usr/lib/w3m/cgi-bin/goto_clipboard.cgi
# follow link in clipboard in new foreground tab.
# keymap P     TAB_GOTO /usr/lib/w3m/cgi-bin/goto_clipboard.cgi

#-.............................................................................
于 2021-04-11T01:12:41.910 回答