One tiny piece of functionality I find myself missing increasingly often is the ability to move vertically in a similar fashion to f
and t
. Usually what I want is to move to the top or bottom of a paragraph without losing my column position, and while I "could" just write a script for it, I wondered if there is any known way around this problem that you guys know of.
Example ( [ ] = current position, < > = destination ):
set tabstop=4
set shiftwidth=4
set <s>ofttabstop=4
set gfn=Source\ Code\ Pro:h14
set encoding=utf-8
set [t]_Co=256
set number
Like a vertical fs
, or t<space>
.
Again, this is usually useful when working with blocks of code. Any ideas?
vim regex provides \%nc
(n is col idx) to match only in certain column.
so without installing plugin, what you could do is :
nnoremap <leader>f :<c-u>exe line('.').'/\%'.col('.').'c'.nr2char(getchar())<cr>
in this way, you press <leader>f
, then press a key, vim will search that char in the same col. next, you press n/N
If you want to have the same but search backwards, use ?
.
The most basic way is to use forward search, /t_<CR>
and backward search, ?so<CR>
, ideally with set incsearch
.
But there are quite a lot of plugins designed around that idea:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With