Movements

gi - " Insert text in the same position as
     " where Insert mode wasa stopped last

Searching

Within text/file

Search ONLY in VISUAL mode with /\%V<pattern>, more in :help /\%V

Count the number of times some pattern occurs: :%s/pattern//gn

Files

Finding Files in VIM

Death by a thousand files

Lista direktorijuma koju koriste komande gf, gF, find se namešta preko path promenljive.

Path promenljiva može da bude i . što znači radni dir, ali ne može da nađe datoteke koje su u poddir, za to treba path=**,*. ** je skupa operacija, ali ako se namesti da pretražuje na manje direktorijume onda je brza.

set path?              " What is it?
set path-=/usr/include " Remove dir
set path=**,*          " Current dir with all subdir
set path=.,**

Browsing oldfiles

Komanda :ol[dfiles] omogućava lako pristupanje skoro izmenjenim datotekama. Dovoljno je videti broj i zatim :e #<num, gde je num broj npr 7. #< znači ‘old file number..’. Radi još i sa komandama :edit, :split, :tabedit, :vsplit, :next, :args

Da bi ukucali broj: bro[wse] ol[dfiles][!]. Ali mora da se prvo ukuca q, da li može bez toga? TODO

Kako promeniti duzinu komande oldfiles? :browse oldfiles and :oldfiles read from the viminfo file, so changing the maximum number of previously edited files to be remembered in the ‘viminfo’ option should work. You can do this by changing the number after the ’ character in the viminfo option. :set viminfo='50

However, this will overwrite everything currently set in the the ‘viminfo’ option, so make sure to set the other desired options as well. For example, doing :set viminfo='50,<50,s10,h would also mean that the maximum number of lines saved for each register would be 50, the maximum size of saved items is 10 KB and the effect of ‘hlsearch’ is disabled when loading the viminfo file.

Ako se otvara prazan vim bez buffera onda moze i ovako:
Nađe se :old zatim se prebaci u normal mode i ukuca '<num>. Ali treba biti pažljiv zašto?

Promenljiva v:oldfiles sadrži listu starih datoteka. Verovatno moze da se koristi kako bi se napravio drugačiji format (is it possible to put custom format oldfiles vim). Ovaj odgovor pomaže link1 kao i ovaj link2, takođe je od pomoći quickfixlist.

Primeri:


:old
:e #<number
:args #<18 #<17 #<5

" For prompt
:bro ol

Pogledaj ove linkove kako da unapredis oldfile

Useful built-in commands

" Open file on specific line from vim
:e +<num> path/to/file

How to load different .vimrc file for different working directory? link. Just do :set exrc

Statusline

%!: This is used to call an external function that returns a string to be displayed in the statusline. It’s often used when you want to generate dynamic content from a function, such as our custom buffer list. When you use %!, Vim expects the function to return a string (the contents for the statusline). This approach is useful for evaluating a function that dynamically generates the entire statusline content. It allows the function to execute logic and return the result to Vim, which will then display it as part of the statusline.

%{}: This is used when you want to evaluate an expression inside the statusline. This method is often used for more straightforward expressions, like showing the current file name, buffer number, or status flags (e.g., modified flag, filetype, etc.). It is more typically used for simple evaluations rather than entire functions that construct complex strings.

set statusline+=%{CustomStatusLine()} WON'T WORK
set statusline+=%!CustomStatusLine()

let buffs = GetBuffNames()
"echo buffs

Vim and Pandoc

:'<,'>!pandoc -f csv -t commonmark_x
" head, face, ears
" arms, chest, back
" legs, calfs, toes

SREDI

https://github.com/romainl/idiomatic-vimrc

https://vim.rtorr.com/

https://dmitryfrank.com/articles/vim_project_code_navigation

Effective editing of multiple files in Vim link