VIM :set list! as a toggle in .vimrc

后端 未结 3 459
误落风尘
误落风尘 2021-02-08 05:57

Is there any way in my .vimrc file to use the command set list! with a keybind like F3 so it functions like this paste toggle set pastetoggle=

相关标签:
3条回答
  • 2021-02-08 06:37

    I found an answer about how to toggle set number in vim, https://stackoverflow.com/a/762633/1086911

    So can try the same way by putting following line into your vimrc file

    map <F3> :set list! list? <CR>
    
    0 讨论(0)
  • 2021-02-08 06:52

    You can put this in your .vimrc file:

    " F3: Toggle list (display unprintable characters).
    nnoremap <F3> :set list!<CR>
    
    0 讨论(0)
  • 2021-02-08 06:59

    This is the mapping for normal mode, visual+select mode, and operator-pending mode (e.g. after typing d):

    noremap <F3> :set list!<CR>
    

    The nice thing about the function keys (vs. <Leader>) is that they can also be mapped in insert mode:

    inoremap <F3> <C-o>:set list!<CR>
    

    To be complete, you could also create a map for command-line mode:

    cnoremap <F3> <C-c>:set list!<CR>
    

    Read more about the various mapping modes at :help map-modes

    0 讨论(0)
提交回复
热议问题