美文网首页
vim: useful operations

vim: useful operations

作者: 早起祷告的猴子 | 来源:发表于2017-03-06 21:59 被阅读17次

    enter different modes:

    • i :insert
    • v: visual
    • shift+v :visual line
    • control+v :visual block

    quit different modes:

    • esc : quit insert
    • v :quit visual
    • shift+v :quit visual line
    • control+v :quit visual block

    quit & save

    • :q :quit
    • :x :quit and save
    • :q! :force quit without saving

    undo & redo

    • u :undo
    • control + r :redo after too much undo:

    move the cursor

    • h :left
    • j :down
    • k :up
    • l :right
    • fX :pressing f and X together moves cursor to next 'X' in the same line (X is any character)
    • ; :repeat fX in same direction

    search

    • :/text :search text
    • n :next matching
    • N :previous matching
    • ggn :jump to the first matching
    • GN :jump to the last matching
    • :/<text> : search your exact text
    • :^text :search text at beginning of one line

    write lines to file/clipboard

    • :1,2w filename :write line 1-2 to a file
    • set clipboard=unnamed :add to .vimrc to share the Mac clipboard with vim
    • :1,2w !pbcopy : copy line 1-2
    • :r !pbpaste :paste the clipboard

    references:

    1. Vim最少必要知识
    2. Vim基础-Markdown语法练习
    3. All the right moves
    4. Mac OS X clipboard sharing

    相关文章

      网友评论

          本文标题:vim: useful operations

          本文链接:https://www.haomeiwen.com/subject/yctpgttx.html