Re:Wrapping Text in Vim
by 1MachineElf on Monday November 28, 2022 @01:51AM
(#33770486)
What is the option that allows one to navigate the cursor up and down a wrapped line as if it were multiple non-wrapped lines? The ability to do so would the reduce friction I experience while attempting to use Vim/Neovim to write my notes.
[ Parent
| on HN ]
I use the below to get that behavior when working with txt files.
autocmd BufNewFile,BufReadPost *.txt noremap <buffer> <silent> k gk
autocmd BufNewFile,BufReadPost *.txt noremap <buffer> <silent> j gj
autocmd BufNewFile,BufReadPost *.txt noremap <buffer> <silent> 0 g0
autocmd BufNewFile,BufReadPost *.txt noremap <buffer> <silent> $ g$
If you want this for all filetypes, just remove everything before "noremap". noremap <buffer> <silent> k gk
noremap <buffer> <silent> j gj
noremap <buffer> <silent> 0 g0
noremap <buffer> <silent> $ g$