Vim: Vertical "f" and "t"

One tiny functionality that I often lose is the ability to move vertically in the same way fand t. Usually I want to go to the top or bottom of a paragraph without losing the position in the column, and although I “could” just write a script for it, I wondered if there was any known way to solve this problem that you guys know.

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 vertical fs, or t<space>.

Again, this is usually useful when working with blocks of code. Any ideas?

+4
source share
5 answers

vim regex \%nc (n is col idx), .

, :

nnoremap <leader>f :<c-u>exe line('.').'/\%'.col('.').'c'.nr2char(getchar())<cr>

, <leader>f, , vim char . n/N

, , ?.

+3

- /t_<CR> ?so<CR>, set incsearch.

:

+2

<n>j <n>k. " " " " . '{' '}' . , , ...

0

, .

(<leader>j) (<leader>k) , :

vnoremap <leader>j <Esc>m`:let b:ss=@/<CR>:let b:zz=col('.') - 1<CR>/\%<C-r>=b:zz<CR>c.\zs.\+\n.\{,<C-r>=b:zz<CR>}$<CR>:let @/=b:ss<CR><C-v>``o
vnoremap <leader>k <Esc>m`:let b:ss=@/<CR>:let b:zz=col('.') - 1<CR>?^.\{,<C-r>=b:zz<CR>}\n.*\%<C-r>=b:zz<CR>c.\zs.<CR>:let @/=b:ss<CR><C-v>``o

. , .

0

JumpToVerticalOccurrence ( ), f{char} ]V{char}. , , , - .

0

All Articles