Vim



♡ Coding Demo ♡

                              GNU Linux - First Notes

                                    First Links


Content

Vim - First Notes - First Links
Learn Shortcuts
tmux
Vim
Notes
Links

GNU Linux - C - terasof.com




tmux

tmux (Terminal Multiplexer) - install at Terminal command line - $ tmux - follow how to install - WP - written in C - github.com tmux website - The Tao of tmux online book - Amazon 1st edition January 22, 2017 - tmuxp.git-pull.com
start tmux: $ tmux
quit tmux: ctrl+b d -

Foreword - ...
About this book
started with The Tao of tmux, part of documentation for tmuxp session manager sudo apt install python-pip
pip install tmuxp -U
manpage for tmux reference - book culmination of years explaining tmux - break down tmux by objects from servers down to panes - written a popular tmux starter configuration, a pythonic tmux library, and a tmux session manager - I am writing this from vim running in a tmux pane, inside a window, in a session running on a tmux server, through a client - install - updates on TW 0.2K
Styles
grey text padding for source - $ for command - prefix = Ctrl-B, can be changed, prefix + symbol like d etc. (detach tmux client from session = quit in terminal)
How this book is structured ...
1. Thinking in tmux
2 realms: text and graphic - ... - terminal can run multiple apps - multiple panes - multople windows - switch between workspaces like virtual desktops - create multiple terminals and windows - copy paste scroll - common scenarios: ... - text editor in pane - apps in background - detaching - ... - chatting - ... - recommended books - ...
2. Terminal fundamentals
... - languages and interpreters - paths - ...
3. Practical usage
$ tmux - prefix sends commands into tmux, split move switch windows, sessions, send in commands etc. --- set-option -g prefix C-a --- default prefix is Ctrl-b - Ctrl-b d quits tmux, detaches session - reattach via $ tmux attach - ... - from now on called prefix + ... - tmux uses commands - configs are automatically running commands - ... - source code files are prefixed cmd- ...
4. Server
the server holds sessions and the windows and panes within them - when tmux starts we are connected to a server via a socket connection - ...
5. Sessions
...

new session:tmux new -s vim(or other name) quit/detach session: ctrl+b d --- attach session: tmux attach -t vim(or other name) horzontal (l/r) split: ctrl+b % --- vertical (u/d) split: ctrl+b " --- switch panes clockwise: ctrl+b o

Tmux Tutorial: An Easy Guide with Screenshots and Examples (2018 Update) - edricteo.com

How to Use Vim and Tmux Together – Workflow for Beginners - slothparadise.com
Tmux and Vim - even better together - bugsnag.com - Benefits of using tmux - lessons from streamlining a development environment - bugsnag.com
vim + tmux: A Perfect Match - teamgaslight.com




Vim

vim path/.../filename = open file
esc --- :set number --- shows now line numbers --- toggle: :set nu!
:set nonumbers --- removes showing line numbers

www.vim.org - WP
openvim.com
vim-adventures.com - - YT
Level 1: h left - j down - k up - l right - :help ...
Level 2: w word - e end of word - b back word -
Level 3: x delete - back to level 1 treasure box - on ! shift+B
Level 4: • 6 months access to VIM Adventures • 13 fun and engaging levels • More than 60 commands and motions • Covers most of the keyboard • Now for only $25 --- Shortcuts, commands and motions taught:
h j k l : w W e E b B x X r d dd D ~ 0 ^ $ f F t T ; , % z zt zz zb g gg G
digits (1-9) * # n N p P " y yy Y :reg "" "- "_ numbered-registers
letter-registers i I a A c cc C s S o O { } ( ) [{ ]} [( ]) . text-objects
H M L nu | / ? ` ' m :marks :delmarks u CTRL-R buffers (:b :ls) files (:w :e)

Graphical vi-vim Cheat Sheet and Tutorial - viemu.com - all shortcuts or keys:
Move / Motion / Search - <-h j-v ^-k l-> - w word - W WORD - e end of word, eow - E end of WORD, eow - b backw"o"rd(s), bw - B backW"O"RD(s) - /+text basic search motion - ?+text same as / backwards - n repeats last search - N repeats last search backwards - * search next instance of identifier under cursor - # same as * backwards - f+char find character - F+char same as f backwards - t+char or T+char same as f or F, but stops before char - 0 beginning of line, bol - ^ first nonblank - $ end of line, eol - -/+ previous/next line - (/) begin/end sentence - {/} begin/end paragraph, previous/next empty line - % go to matching pair ({[ etc. - [[/]] previous/next { in column o - G go to end of file, eof - H screen high, top - M screen mid - L screen low, bottom - ctrl+F/B page up/down - ctrl+E/Y scroll up/down
Search / Mark / Macro - ... see above under Move - m+char set mark - `+char go to that mark - '+char go to first nonblank in that line, A-Z marks are global, a-z per-buffer - q+char starts macro recording, again q stops recording - @=char replays macro, @@ repeats last macro played
Insert / Delete - i insert - I insert beginning of line, bol - a append, insert after cursor - A append end of line, eol - o open above - O open below - r replace - R replace mode - s substitute - S substitute line - c change - C change to end of line, eol, shorthand for c$ - x delete - X delete left - d+motion/character/word delete to character/word (also dw, df... etc.) - c same as d, stays insert mode - D delete to end of line, eol - ~ toggle case - (leave from insert mode with escape esc to normal mode)
Visual Mode - v enters visual mode, move, text highlighted, press operator - V like v, selects lines - ctrl+v selects rectangular blocks - (leave from visual mode with escape esc to normal mode)
Count / Repeat - d2w delete up to 2nd word, d2t, delete up to not including , - 2i etc. - . repeats last editing action, like text input, delete, change etc. - dd or cc repeat operator
Undo / Redo - u undo - U undo line - ctrl+r redo
Yank(Copy) / Paste - y+motion yank/copy - Y yank/copy line, shorthand for yy - p paste after - P paste before
Save / Quit - :w save/write - :q quit - :q! quit without save/write - :qw - (for commands after : press enter)
Other - K help - </> unindent/indent, <<  >> - "+(a-z) before any yank/delete/paste chooses register, (A-Z) register means append-copy - "* or "+ select system clipboard - deleted text with d/c/x is also copied - J joins current and next line, or all in visual selection - Q ex mode - ! external filter - & repeat :s - _ soft bol down - = autoformat - | bol, go to col - \ not used - : ex command line - ; repeat t/T/f/F - , reverse t/T/f/F - z+... extra commands - Z+... quit - learn Vim at terasof.com/vim.html

Move / Motion / Search
left up down right cursor_keys touchpad
word /cap - end_of_word /cap - backw"o"rds /cap
basic search /bw - repeat last search /bw
find character /bw
Insert / Delete
insert - replace 2 - delete
quit, learn different

Vim documentation - vimdoc.sourceforge.net
VIM Editor Commands - radford.edu
How to set and use a vim color scheme - alvinalexander.com

Practical Vim

Practical Vim: Edit Text at the Speed of Thought - (Pragmatic Programmers) - 1st Edition by Drew Neil - Amazon - github.com

Read Me
xv - text at the speed of thought - book is fast track to mastery - learn Vim tutor interactive lesson distributed with Vim - $ vimtutor - (continued after Vim Tutor)

keyboard English = German
` ~ = ^ ° (< >) - _ = ß ? = + = ´ ` [ { = ü Ü ] } = + * \ | = # ' / ? = - _ ; : = ö Ö ' " = ä Ä , < = , ; . > = . : / ? = - _

*     *     *     *     *

Vim Tutor - open terminal, $ vimtutor
describes enough commands to get started - time 25-30 min - Lesson 1.1 hjkl, j like down arrow - hold j key to repeat - Lesson 1.2 when typed wrong press escape (esc) to cancel unwanted or partially completed command - :q! quit, discarding any changes made - get back command vimtutor - cursor keys work, too (and touchpad), faster is using hjkl - Lesson 1.3 x delete character under/behind cursor - Lesson 1.4 insert i - curser after character to be deleted, i and character, esc for normal mode - L1.5 A append (einfügen) - move to line, press A, insert, esc - L1.6 open file vim filename - edit and then save with :w or :wq save+quit - summary
Lesson 2.1 dw delete word, then esc - L2.2 d$ delete end of line (eol), move cursor to first character to be deleted - L2.3 Operators and Motion - d delete operator, + motions: w e (cursor to end of word) $ - dw de d$ - L2.4 2w 3e moves 2 or 3 times - 0 start of line - L2.5 d number motion - d2w delete 2 words etc. - L2.6 dd 2dd delete line - L2.7 u undo - U undoes all line changes - ctrl+R redo - summary
Lesson 3.1 dd delete line and p put (paste) under cursor line, or deleted word after cursor - L3.2 r replace character (R more than one) - L3.3 ce change until end of word, switches to i insert, then esc - L3.4 c (change) operator same motions as d (delete), c [number] motion, as w $ - cw, ce or c$ - backspace for mistakes while typing - summary
Lesson 4.1 - ctrl+G shows location and filename - G file bottom, gg file start - enter last line-number+G return to last position - L4.2 /+word search word forward - n next, N opposite direction - ?+word for backward - ctrl+o back to older position - ctrl+i to newer position - L4.3 % matching )]} - useful for debugging unmatched - L4.4 substitute (ersetzen) :s/thee/the + enter changes thee into the - :s/thee/the/g line globally - :#,#s/old/new/g between #-lines - :%s/.../old/new/g whole file - :%s/old/new/gc whole file, promt to substitute or not, y/n - summary
Lesson 5.1 :! for external shell command like ls etc., also with arguments - L5.2 save file with :w or :w filename - check with :!ls - remove :!rm filename - check again :!ls - L5.3 save excerpt: curser at beginning of excerpt text, press v (starts visual selsction), select text moving cursor, pressing : shows :'<, '> - add w filename - created file TEST in ~ - visual selection can be manipulated with operator like d etc. - L5.4 retrieve from file with :r TEST (your filename), file text will be entered under curser line - :r !ls (or other command) puts output of external command in text to read and puts below cursor - summary :!command executes external command
Lesson 6.1 o opens line below cursor in Insert mode, enter text, leave with esc - capital O does same above curser line - L6.2 a inserts text after cursor, leave with esc - a i A all open Insert mode, difference is insertion place - L6.3 R replaces more than one character under cursor (L3.2 r only one), like i, deletes existing character - L6.4 select with v (Visual), then yank/copy with y - y can be an operator, like yw yanks/copies word - L6.5 search /ignore (or other word), find next with n, repeat - :set ic (Ignore case), undo with :set noic, sets/unsets ignore case - :set hls ic (hlsearch highlight search - incsearch partial match) - repeat /ignore highlighted - :nohlsearch removes highlighted matches - for just one search use /ignore\c (backslash) - summary :set ... sets options - can use long or short option name - prepend no switches option off, :set noic
Lesson 7.1 online help with Help-key, F1, or :help - ctrl-w jump windows - :help w --- :help c_CTRL-D --- :help insert-index --- :help user-manual - L7.2 Vim many more features than Vi, most of them disabled by default - create file :e ~/.vimrc created .vimrc.swp - next Vim start will do syntax highlighting - add all prferred settings - more info :help vimrc-intro - L7.3 :set nocp (no compatible mode) - look for existing files :!ls - :e ctrl+D shows list of commands starting with e - press Tab, Vim completes name and goes through listed e controls - Completion works for many commands - useful for :help - summary
end Vim Tutor - brief overview, enough to use editor easily, far from complete - read :help user-manual next (pdf download) - book recommendation "Vim - Vi Improved" - by Steve Oualline for beginners - or older book "Learn the Vi Editor" by Linda Lamb, 6e about Vim

:u undo - b word back - e end of word - $ end of line (eol) - w word - : set number / set nonumber

*     *     *     *     *

(continued:) Vim highly configurable - vimrc file no preferences - focus on core functionality which is always there, whether SSH or GVim and plugins - book structure: receipe book, not designed to read from start to finish - each chapter collection of tips related by a theme - Vim always more than one way - chapter 1 . command could be solved using :substitute command etc. - first learn to touch type not looking down on keyboard - Vim traces back to Unix editors vi and ed (p53), predating mouse etc. - Vim everything can be done with keyboard, faster
Read the Forgotten Manual
book shows rather examples than descriptions - contents and keystrokes of Vim buffer - can skip this chapter and jump to action, ch1 - this chapter about each convention in book - find answer to symbols in chapter - Vim's built-in documentation - hyperlink :h vimtutor or internet - :h abbreviation for command help - Querty (= shift ctrl cmd alt etc.( like piano notes or chords - ctrl-s pressed together, modal command set not - x dw dap - <C-p> means ctrl-p, pressed together - also <S-...> shift-key, <M-...> meta- or alt-key, <A-...> alt-key same as M, <D-...> command-key (Macintosh only) - used by Vim, can be used for own key mappings - combinations of both:
<C-n> Press <Ctrl> and n at the same time
g<C-]> Press g , followed by <Ctrl> and ] at the same time
<C-r>0 Press <Ctrl> and r at the same time, then 0
<C-w><C-=> Press <Ctrl> and w at the same time, then <Ctrl> and = at the same time
... other notations ... - switching modes ... - interacting with command line: $ grep -n Waldo * in command-line or :grep Waldo * in Vim - $ for command-line, : for Vim - also:
/ Use Command-Line mode to perform a forward search
? Use Command-Line mode to perform a backward search
= Use Command-Line mode to evaluate a Vim script expression
<CR> for Enter/Return, and exeptions ... - for space bar - show curser position in buffer ...
xxii - selecting in visual mode ... - downloading examples in Vim, press link, opens in browser - all examples at http://pragprog.com/titles/dnvim/source_code - Vim factory settings, defaults can all be changed - test: launching Vim with $ vim -u NONE -N - -u NONE causes not to source from vimrc, custumizations not applied, no plugins, reverting to vi compatible mode and disabling many useful features - -N flag prevents it setting 'noncompatible' option - guarantees that mostly everything works as book describes - or try $ vim -u code/essential.vim (check and adjust path) containing: set nocompatible
filetype plugin on
in this way use features as tetrw (Tip 43) and omni-completion (Tip 117) and many others - recommendation: Vim’s factory settings to mean built-in plugins enabled and vi compatibility disabled - look out for subsections titled "Preparation" at the top of a tip, need to configure Vim accordingly, factory settings should help here - still problems, see Section 6, On Vim Versions, page xxiv - Vim script inables us adding new or changing existing functionality, using a complete scripting language (vimscript), which is not explained in this book, but used in Tips 16 70 94 95 - book shows using Vim's core without third-party plugins, except Tip 86 212 96, which add via plugins indispensable (unentbehrliche) features - implementation of visual-star.vim and Qargs.vim is presented inline without explanation (Vim is written in C and Vim Script, based on ex-editor (written in C) by Billy Joy for Unix - cheatsheet - Five Minute Vimscript by Andrew Scala - Vim Script supports plugins for Perl, Python, Lua, Ruby) - Vim versions: book tested all examples with 7.3 - some functionality can be disabled during compilation like --with-features=tiny option, disabling all but tie most fundamental features (also small, normal, big, huge), browse :h +feature-list - check by :version - on modern computers use huge feature set! - choose Vim terminal (could be called TUI, textual UI) or GUI (graphical user interface) - terminal feels natural if most of your day spent with Vim - GVim or MacVim are the GUIs, see :h gui - GUI more fonts and colors for syntax highlighting, and able to use mouse and some conventions of OS (like cmd-x and cmd-v, save with cmd-s, close window cmd-w etc.) - but there's always a better way - book can be used for both, terminal and GUI - We'll learn how to do things the Vim way
Ch 1 - The Vim Way
we repeat actions - repetetive workflow saves time multifold - dot command most versatile (vielseitig), ideal editing formula with one keystroke to move and one to execute
Tip 1 - Meet the Dot Command
repeats last change - change could act at level of characters, lines, or whole file - delete with x, then repeat with ., .. etc. - or dd deletes line, . etc. - >G indentation to end of file, j, ., j. - all three from normal mode - insert mode press i, back to normal with escVim records every keystroke - micro macro, Vim records and replays repetitive workflows - for best practices see Tip 9 and 23
Tip 2 - Don’t Repeat Yourself
p4 - example put semicolon at end of line for many lines: $a; esc - repeat with j$. - better A; esc - then j. - alternative Tip 30 - other examples, all switching from normal to insert mode: C or c$ - s or cl - S or ^C - I or ^i - A or $a - o or A<CR> - O or ko
Tip 3 -

Comparison of text editors - total 70 editors - WP
Best Text Editors for Linux Command Line - itsfoss.com
10 Best Text Editors For Linux And Programming (2018 Edition) - fossbytes.com

*     *     *     *     *

Emacs

Editor war - WP
Differences between Emacs and Vim - stackoverflow.com - Evil (extensible vi layer) mode on Emacs simulates main features of vi and Vim
Vimacs : Vim-Improved eMACS: Emacs emulation for Vim - vim.org




Notes

Machines for world knowledge 300 Exabytes, ship SH and spaceship SS - Computers should do what humans want them to do - input output - keyboard pad touchscreen cam mic controller etc. - based binary - ASM and C needed - terminal - IN HTML CSS JS WASM - Arduino Rapberry PI etc. - Linux - games animation sounddesign graficdesign - art FP MP WR - O MG




Links

...




Sessions

• Session 1 • Wed 2018-12-5 Auckland 18:30-19:00 WR vim.html - start





         

https://www.symptoma.es