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=
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>
You can put this in your .vimrc
file:
" F3: Toggle list (display unprintable characters).
nnoremap <F3> :set list!<CR>
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