From 7a68dc8c39f29ae1ee6737cd22508ac957e4b14a Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 4 Dec 2022 21:58:59 +0200 Subject: Changed format of text that shows headers into an unordered list --- tools/vim.md | 78 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/tools/vim.md b/tools/vim.md index 6470add..601ecd5 100644 --- a/tools/vim.md +++ b/tools/vim.md @@ -1,4 +1,4 @@ -## Copy text from (n)vim to +* Copy text from (n)vim to ``` * linux: :w !xclip -sel c # copy the whole file @@ -11,29 +11,29 @@ or :%w !pbcopy # copy the whole file :r !pbpaste # paste from the clipboard ``` -# To open the current window in a new tab (maximize) with the cursor in the same place, enter +* To open the current window in a new tab (maximize) with the cursor in the same place, enter :tab sp or T # which splits the current window into a new tab. -# To close the current window, press +* To close the current window, press c # That will close the newly opened tab. -# To make a file executable +* To make a file executable :! chmod +x % -# Shortcut command to backup current file +* Shortcut command to backup current file :!cp % %.backup -# Use hjkl... at vim's command history mode by using or even go straight into it with +* Use hjkl... at vim's command history mode by using or even go straight into it with : # can exit by pressing -# Split existing buffer into a horizontal/vertical window +* Split existing buffer into a horizontal/vertical window :sb# :vert sb# -# Search and Replace, The :substitute command searches for a text pattern, and replaces it with a text string. There are many options, but these are what you probably want: +* Search and Replace, The :substitute command searches for a text pattern, and replaces it with a text string. There are many options, but these are what you probably want: :s/foo/bar/g # Find each occurrence of 'foo' (in the current line only), and replace it with 'bar'. :%s/foo/bar/g @@ -49,13 +49,13 @@ or :%s/foo/bar/gcI # Change each 'foo' (case sensitive due to the I flag) to 'bar'; ask for confirmation. -# Create a new file named filename in the same directory as the currently open file, and write it. +* Create a new file named filename in the same directory as the currently open file, and write it. :e %:h/filename -# VIM KEYBOARD SHORTCUTS +* VIM KEYBOARD SHORTCUTS -### MOVEMENT +*** MOVEMENT ``` h - Move left j - Move down @@ -97,7 +97,7 @@ n - Repeat the last / or ? command N - Repeat the last / or ? command in the opposite direction ``` -### NORMAL MODE -> INSERT MODE +*** NORMAL MODE -> INSERT MODE ``` i - Enter insert mode to the left of the cursor a - Enter insert mode to the right of the cursor @@ -112,7 +112,7 @@ cc - Delete current line and enter insert mode (unlike dd which leaves y C - Delete (change) from cursor to end of line, and enter insert mode ``` -### DELETION +*** DELETION ``` x - Delete character forward (under cursor). use x do delete backwards (before cursor) r - Replace single character under cursor, and remain in normal mode @@ -123,7 +123,7 @@ dd - Delete entire current line D - Delete until end of line ``` -### YANK & PUT +*** YANK & PUT ``` y - Yank (copy) highlighted text yy - Yank current linepPut (paste) yanked text below current line @@ -135,7 +135,7 @@ J - Join current line with the next line. Use gJ to exclude join-positi xp - Transpose two letters (delete and paste, technically) ``` -### VISUAL MODE +*** VISUAL MODE ``` v - Enter visual mode and highlight characters V - Enter visual mode and highlight lines @@ -151,7 +151,7 @@ vac - Highlight all text including the pair marked with c (like va<, va' vic - Highlight all text inside the pair marked with c ``` -### MARKING +*** MARKING ``` ma - Set a marker a at cursor position to come back to later. a can be any character you choose mb - Set a marker b at current position @@ -170,7 +170,7 @@ y`a - Yank text to unnamed buffer from cursor to position of mark a ``` -### VIM FOLDING +*** VIM FOLDING ``` zf#j - creates a fold from the cursor down # lines. zf/string - creates a fold from the cursor to string . @@ -199,7 +199,7 @@ zR - decreases the foldlevel to zero -- all folds will be open. :set foldmethod=indent - automatically fold programms per its indentation ``` -### MISCELLANEOUS +*** MISCELLANEOUS ``` u - Undo U - Undo all changes on current line @@ -225,7 +225,7 @@ vim +/bash cronjob-lab.yml - opens the file cronjob-lab.yml on the first occ vim scp://balasundaramm@mgmt-bst:22/~/automation/test-file.txt - Edit a remote file via scp ``` -### HISTORY/COMMAND BUFFER +*** HISTORY/COMMAND BUFFER ``` q: - list history in command buffer q/ - search history in command buffer @@ -238,7 +238,7 @@ CTRL+n - Press after typing part of a word. It scrolls down the list CTRL+p - Press after typing part of a word. It scrolls up the list of all previously used words ``` -### BUFFERS +*** BUFFERS ``` :ls (or :buffers) - list / show available buffers :e filename - Edit a file in a new buffer @@ -256,7 +256,7 @@ CTRL+p - Press after typing part of a word. It scrolls up the list of :.! cat - reads the output of the command (eg: cat) into buffer or !! in ex-mode ``` -### TAB VIEWS +*** TAB VIEWS ``` :tabe filename - opens the file in newtab :tabe new - open an empty tab @@ -270,14 +270,14 @@ CTRL+p - Press after typing part of a word. It scrolls up the list of vim -p *.txt - open all txt files in tabs ``` -### TAB NAVIGATION +*** TAB NAVIGATION ``` gt - go to next tab gT - go to previous tab {i}gt - go to tab in position i ``` -### TAB SHORTCUTS +*** TAB SHORTCUTS ``` CTRL+W T - Break out current window into a new tabview CTRL+W o - Close every window in the current tabview but the current one @@ -285,28 +285,28 @@ CTRL+W n - create a new window in the current tabview CTRL+W c - Close current window in the current tabview ``` -### WINDOW MANAGEMENT +*** WINDOW MANAGEMENT ``` -#split screen horizontal +*split screen horizontal :split filename vim -o file1 file2 -#split screen vertical +*split screen vertical :vs filename or :vsplit filename vim -O file1 file2 -#close current window +*close current window :hide -#Horizontal resize in active window +*Horizontal resize in active window :resize 20 -#vertical resize +*vertical resize :vertical resize 20 -#diff +*diff :windo diffthis - diff between 2 vsplit windows :diffs, diffsplit {filename} - diffs the current window with the file given :diffoff - turns off diff selection @@ -318,13 +318,13 @@ CTRL+w c - Close current window CTRL+w m - Move to window according to motion m CTRL+w o - Maxmize current window (note: this overwrites your current window configuration) -# EX Mode +* EX Mode :Vex - Open Vertical Split in ex mode with file browser :Sex - Open Vertical Split in ex mode with file browser ``` -### MOVING WINDOWS +*** MOVING WINDOWS ``` CTRL+W r - Swap bottom/top if split horizontally CTRL+W R - Swap top/bottom if split horizontally @@ -338,7 +338,7 @@ CTRL+w K - Move current window the far top and full width of the screen CTRL+w L - Move current window the far right and full height of the screen ``` -### NAVIGATE BETWEEN WINDOWS +*** NAVIGATE BETWEEN WINDOWS ``` CTRL+w CTRL+w - switch between windows CTRL+w UP - Move to the top window from current window @@ -347,9 +347,9 @@ CTRL+w LEFT - Move to the left window from current window CTRL+w RIGHT - Move to the right window from current window ``` -### RESIZING WINDOWS +*** RESIZING WINDOWS ``` -#Sometimes windows open up funny or are rendered incorrectly after separating from an external monitor. Or maybe you want to make more room for an important file. +*Sometimes windows open up funny or are rendered incorrectly after separating from an external monitor. Or maybe you want to make more room for an important file. CTRL+w _ - Max out the height of the current split CTRL+w | - Max out the width of the current split @@ -361,20 +361,20 @@ CTRL+w - - Incrementally decrease the window's height. Takes a parameter CTRL+w + - Incrementally increase the window's height. Takes a parameter, e.g. CTRL-w 10 + ``` -### COMMENT LINES (TCOMMENT PLUGIN) +*** COMMENT LINES (TCOMMENT PLUGIN) ``` CTRL+_ CTRL+_ - Comment a line using tcomment CTRL+V - #{Select the block before commenting a block, CTRL+_ CTRL+_ - Comment a block of line using tcomment} ``` -### MODELINE MAGIC +*** MODELINE MAGIC ``` :set modeline - Enable modeline magic or add this option to your .vimrc \ml - write the modeline based on your settings to the file ``` -### NERDTree Plugin +*** NERDTree Plugin ``` CTRL-n - Toggle @@ -384,7 +384,7 @@ i - horizontal split s - vertical split CTRL-w + <-|-> - (left or right) to navigate ``` -### PERMISSION OVERRIDE ### +*** PERMISSION OVERRIDE *** ``` :w !sudo tee % - Allows to override the permission of the written file :w !sudo sh -c "cat > %" - " " -- cgit v1.2.3