Vi: Difference between revisions

From My Mnemonic Rhyme
Jump to navigation Jump to search
>Homaar
 
No edit summary
Line 8: Line 8:
*https://jdhao.github.io/2019/04/29/nvim_spell_check/
*https://jdhao.github.io/2019/04/29/nvim_spell_check/
*https://en.wikibooks.org/wiki/Learning_the_vi_Editor/Vim
*https://en.wikibooks.org/wiki/Learning_the_vi_Editor/Vim
=copy selection to command line=
https://stackoverflow.com/questions/3997078/how-to-paste-yanked-text-into-the-vim-command-line
Ctrl+R " / buffername


=movement=
=movement=

Revision as of 18:40, 5 February 2023

links

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