Last update: 24. 8. 2024
Show help in top window or left window
help leader
vert help leader
change window focus
ctrl+ww
change ordering
ctrl+wr
Debian/openbox/urxvt/vim8
apt install vim-gtk # vim-gtk3
ctrl+alt+v < should now work to paste stuff from other clipboard, or
middle-mouse-button < paste behaves differently
"+p < paste from other clipboard
"+gp < this horror should paste as well
"+yy < copy current line
"+y20 < copy this and 20 lines below
:help "+ < actually finds clipboard related help
http://vim.wikia.com/wiki/Using_tab_pages
Open multiple files in tabs:
vim -p one.txt two.txt three.txt
shortkeys in normal mode
gt < next
gT < previous
{i}gt < go to tab at position i
btw
:e filename < opens file
:tabe filename < opens file in new tab
:qall < close all and exit
make each buffer appear in tab
:tab sball
:buffers or :ls < list buffers
:bi < jump to buffer i, where i is buffer number
:bn :bp < next, previous buffer
:Explore
:Sexplore or :Sex < in horizontal split
:Vexplore < in vertical split
:Texplore < in new tab
/pattern
?pattern < backward
n N < repeat
* < search for word under cursor
:%s/old/new/g < replace
:%s/old/new/gc < with confirmations
gg < goto start of file
G < goto end of file
end, home < end, start of line (also 0 and $)
i, o < insert or insert on next line
a < insert after selected char
dw < delete word
ci+brackets < delete stuff inside brackets
:w < write
:wq < write and quit
:q < quit
:q! < quit without saving
di( < delete inside ()
b < to go to beginning of current or previous word
w < to go the beginning of next word
e < to go to the end of current or next word
ge < to go the end of the previous word
# Try :h word-motions for more details and how to combine them with operations.
ggVG < select contents of entire file
U < selected text to UPPERCASE
u < selected text to lowercase
:retab < convert tabs to spaces
In insert mode start typing something and then
ctrl+n
In insert mode
ctrl+t < insert indent at start of line
ctrl+d < remove indent at start of line
In normal mode
>> < indent line by shiftwidth spaces
<< < deindent line
3>> < indent 3 lines
In visual mode, select lines and »
:split < horizontal
:vsplit < vertical
ctrl+w+j < move down a screen
ctrl+w+k < up
ctrl+w+h < left
ctrl+w+l < right
:only < close others
:0r !ls < insert output of ls before 0 line
:0r !head ~/bin/somescript < similar
:r < below the cursor
:$r !pwd < below the last line
http://vim.wikia.com/wiki/Insert_a_file
https://brigade.engineering/sharpen-your-vim-with-snippets-767b693886db
Just insert head part of say previous file that will now act as a template
:r !head previous_file
ctrl+z, fg < will push vim to bg, fg in shell will bring it back
or
:shell or just :sh "do your shell stuff" then
exit
insert output of the shell command to the current document
:r ! ls
One can also execute commands directly from the editor
:! python %
will run the active (must be saved) file with python interpreter.
vi and vim are the same, they are symbolic links to
/usr/bin/vim.basic
vi and vim are the same on OSX as well.
brew install vim # brew update && brew upgrade # before that if needed
# should install in /usr/local/bin/vim
# do a softlink in user bin if defined and on $PATH, like
cd $HOME/bin
ln -s /usr/local/bin/vim vim # that should now call brew installed vim in the future sessions
https://shapeshed.com/vim-packages
q: https://stackoverflow.com/questions/ a: Your problem with Vim is that you don’t grok vi.