Vi

From My Mnemonic Rhyme
Revision as of 17:29, 20 February 2023 by Weiss (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Add to end of the line

A

Also works with multiple visually selected lines!

copy selection to command line

https://stackoverflow.com/questions/3997078/how-to-paste-yanked-text-into-the-vim-command-line

Ctrl+R " / buffername

movement

Q # Ex-Mode
e # move to the end of a word
gi # restart insert mode at the previous positition
s3 # substitue the next three characters
ci] # change until the closing square bracket
vi) # visually mark everything till the next parentesis
"ky # save marked part in register k
"Ky # append marked part to register k (use capital letter)
f # move forward to the next occurence of a character
F # move forward to the next occurence of a character
q: # show list of commands
q\ # show list of past searches

buffers

:buffers
:MBEToggle # ,t
:b1 # jump to first buffer
:1bd # close first buffer

neovim

alias vi=nvim

Config is located at ~/.config/nvim

Update plugins

:PlugUpdate

.vimrc

lrwxrwxrwx  1 homaar homaar   17 Nov  4 04:14 .vimrc -> c_praktikum/vimrc

Help

helpg 'pattern'
:set [no]nu - Zeilennummerierung
:set autoindent - Automatischer formatierter Zeilenumbruch

follow links:
CTRL+] (forward)
CTRL+T (back)

Split Windows

STRG-W n

Move between Windows

STRG-W hjkl

Header Link folgen

gf
Strg-O springt zurück

Visual Mode

V - markiert ganze Zeile
v - markiert einzelne Zeichen
> - Einrücken (:set sw=...)
. - letzte Aktion wiederholen

search highlighted text

Visually select the text you want to search.

y q / p
Enter

q/ works similarly to vanilla search / except you're in command mode so p actually does "paste" instead of typing the character p. So the above will yank the characters you're searching for, then paste them into a search.

(see :help q/)

ganze Textbereiche ein- oder auskommentieren

STRG+V drücken, dies aktiviert den Blockmodus (im Status erscheint: – VISUAL BLOCK –)
Mit shift+i (großes I) in den Eingabemodus wechseln und das gewünschte Kommentarzeichen (#, / / ) eingeben.
ESC z

forgotten sudo

:w !sudo tee %

text selection

 
vi' #"select inner single quotes"

vib # "select inner block"

viB # "capital B"

:help text-objects

variable scoping

s... The variable is local to the current script file a... The variable is a parameter of the current function

see https://www.gilesorr.com/blog/vim-variable-scope.html

how to document

:help help-writing

write key mappings to a file

:redir! > vim_keys.txt
:silent verbose map
:redir END

add current folder to path

set path+=**
# now files are findable in subfolders
:find asdf

links