diff options
author | Max Christian Pohle | 2024-05-12 21:01:00 +0200 |
---|---|---|
committer | Max Christian Pohle | 2024-05-12 21:01:00 +0200 |
commit | eec48ff71881d8757b79dcd95aac9dac4d71bf72 (patch) | |
tree | 8e21c80a8fecbcf7a6b36c3db1d2aa061bda1959 /README.md | |
parent | f3eb203b4ad79090e36982e7b417c0cf0de52646 (diff) | |
download | vim-eec48ff71881d8757b79dcd95aac9dac4d71bf72.tar.bz2 vim-eec48ff71881d8757b79dcd95aac9dac4d71bf72.zip |
tidied this repo up and uploaded my new nvim from scratch config
Diffstat (limited to 'README.md')
-rwxr-xr-x | README.md | 298 |
1 files changed, 298 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100755 index 0000000..2d5747f --- /dev/null +++ b/README.md | |||
@@ -0,0 +1,298 @@ | |||
1 | # Installation | ||
2 | ``` | ||
3 | git clone http://git.entwicklerseite.de/vim ~/.config/nvim/ | ||
4 | ``` | ||
5 | |||
6 | # Overview | ||
7 | |||
8 | - init.lua :: my every day neovim config. It sources my vimrc (see below) | ||
9 | |||
10 | - init-mini.lua :: if you want to start from scratch this is a good start. It | ||
11 | sets up nvim with a language server to support the creation of a new config. | ||
12 | |||
13 | - vimrc :: commented version of a vimrc with sane defaults | ||
14 | |||
15 | |||
16 | ``` | ||
17 | . | ||
18 | ├── after | ||
19 | │ ├── ftdetect | ||
20 | │ │ └── log.vim | ||
21 | │ ├── ftplugin | ||
22 | │ │ └── python.vim | ||
23 | │ ├── indent | ||
24 | │ │ ├── html5.vim | ||
25 | │ │ ├── php.vim | ||
26 | │ │ └── yaml.vim | ||
27 | │ └── syntax | ||
28 | │ ├── c.vim | ||
29 | │ ├── log.vim | ||
30 | │ └── markdown.vim | ||
31 | ├── gvimrc | ||
32 | ├── init-mini.lua | ||
33 | ├── init.lua | ||
34 | ├── README.md | ||
35 | └── vimrc | ||
36 | ``` | ||
37 | |||
38 | |||
39 | # Cheat sheet | ||
40 | For different working scenarios. | ||
41 | |||
42 | ## vim | ||
43 | |||
44 | - use `<C-d>` to expand autocompletion on the `:` command line. That works for | ||
45 | example for `:setfiletype <C-d>` to show all available filetypes. | ||
46 | |||
47 | - use `gw` or `gq` in visual mode to break selected text at the current | ||
48 | textwidth (configured with `set textwidth=80` for example) | ||
49 | |||
50 | ``` | ||
51 | :viusage = summary of all keyboard shortcuts | ||
52 | :options = shows currently :set options (with descriptions) | ||
53 | leader key = usually set to backslash expects a quick command | ||
54 | |||
55 | |||
56 | [normal mode] | ||
57 | f{char} = move cursor to the character {char} | ||
58 | gf = open file under cursor | ||
59 | <C-w>gf = open file under cursor in a tab | ||
60 | <C-w>] = jump to the tag under the cursor in a new window | ||
61 | <C-t> = jump back from where that ^ brought you | ||
62 | K = keyword lookup for the word under the cursor (see :help kp) | ||
63 | w = next word | ||
64 | e = end of word (=inner word) | ||
65 | |||
66 | |||
67 | @see: :h text-objects | ||
68 | ci' = change between single quote | ||
69 | ci" = change between double quote | ||
70 | ci( = change between brace | ||
71 | cit = change XML Tag | ||
72 | ciw = select inner word | ||
73 | caw = select 'a word' | ||
74 | " where c can be replaced by v for visual mode | ||
75 | |||
76 | :%s/foo/bar/g = replace all foo with bar | ||
77 | :g/foo/s/bar//g = on lines with foo replace bar with nothing | ||
78 | :g!/foo/s/bar//g = on lines not containing foo replace bar with nothing | ||
79 | :g!/^foo/execute("normal dd") delete lines starting with foo | ||
80 | |||
81 | flags, end: after the last / | ||
82 | g = replace globally (all occurances on the current line) | ||
83 | c = confirm each replace, also allows to switch to g (use the flag to see the help message) | ||
84 | e = places the cursor in the end of the selection | ||
85 | |||
86 | flags, within the search string: | ||
87 | \v = use very magic search (more like perl) | ||
88 | \V = use no very magic, more like searching verbatim | ||
89 | \zs .. \ze = mark begin and end of a sub pattern (like perl lookaround assertions) | ||
90 | |||
91 | |||
92 | |||
93 | [visual mode] # with selected lines | ||
94 | gq = formats text so that it fits in whatever :set textwidth was set | ||
95 | iB = select block between curly braces (:help object-select) | ||
96 | |||
97 | |||
98 | [commands] | ||
99 | command line mode begins with : and has its own key mappings starting with c like in cnormap | ||
100 | |||
101 | :spell [word] = adds a word to the current dictionary (no mistake any more) | ||
102 | :set list = display non printable characters | ||
103 | :retab = replaces tabs with spaces | ||
104 | :set expandtab = in insert mode: replace tab with spaces | ||
105 | :Explore = cli version open file dialog (file explorer) | ||
106 | :Lex = use netrw as project drawer (stays open in its own window) | ||
107 | :only = 'maximize' current buffer | ||
108 | |||
109 | <c-r><c-w> = auto completion with the word under the cursor (interesting with incsearch) | ||
110 | <c-a> = expand pattern from command line (e.g. *.txt) | ||
111 | |||
112 | |||
113 | [navigation] | ||
114 | <CTRL-]> = look up the tag under the cursor (help links as well) | ||
115 | <CTRL-T> = return back from tag under the cursor | ||
116 | gd = jump to the declaration of the variable under the cursor | ||
117 | |||
118 | |||
119 | [macros] # record and play back a series of vim commands | ||
120 | qa = start (q) macro recording in register a (can be anything) | ||
121 | q = stop macro recording | ||
122 | @a = replay macro a | ||
123 | :'<,'>normal @a = apply a to every line in the current selection | ||
124 | :reg = lists all registers (including those with macros in them) | ||
125 | |||
126 | [registers] | ||
127 | notice, that registers get used for both: macro recordings and copying text | ||
128 | |||
129 | :reg = shows contents of all registers | ||
130 | "0p = pasts from register 0, which is the same as "", but not overwritten by dd | ||
131 | "ap = same for register a | ||
132 | "0yy = yanks to register 0 (same as y by itself) | ||
133 | "ay = yanks current selection to register a (in visual mode) | ||
134 | |||
135 | |||
136 | [marker] | ||
137 | ma = set marker a-z (a in this case) | ||
138 | mA = create a session persistent file marker which can be used to reopen a file (not bound to the buffer) | ||
139 | `a = go to marker a (line & column) | ||
140 | 'a = go to marker a (line, first non blank), same as `a^ | ||
141 | |||
142 | |||
143 | |||
144 | [hotkeys] | ||
145 | <C-A>, <C-X> = increment, decrement number under the cursor | ||
146 | |||
147 | |||
148 | [windows] | ||
149 | <C-W>v = splits buffer vertically (screen uses |) | ||
150 | <C-W>s = splits buffer horizontally (same as screen) | ||
151 | <C-W>w = moves the cursor to the next window and back | ||
152 | <C-W>[dir] = moves the cursor in that direction (use hjkl or arrow keys) | ||
153 | <C-W>[HK] = make a vertical split horizontal and vice versa | ||
154 | <C-W>o = only: close all other windows | ||
155 | <C-W>c = close: current window in which the cursor sits | ||
156 | |||
157 | |||
158 | [vimdiff] | ||
159 | do = get changes from other window into the current | ||
160 | dp = put changes from current window into the other | ||
161 | ]c = jump to the next change | ||
162 | [c = jump to the prevous change | ||
163 | |||
164 | [folds] | ||
165 | za = toggle a fold | ||
166 | zM = close all folds | ||
167 | zR = opens all folds (unfold all) | ||
168 | zE = eliminates all folds | ||
169 | |||
170 | |||
171 | [buffers] | ||
172 | :bn = buffer next | ||
173 | :bp = buffer previous | ||
174 | :bd = buffer dispatch (close) | ||
175 | :b <tab> = switch buffer by name (use <tab> and <return>) | ||
176 | :set nobuflisted = hide buffer in buffer list (great for neovim's terminal) | ||
177 | |||
178 | [args] | ||
179 | :n **/*.c = opens all files with that name or type in buffers and also fills the argument list | ||
180 | |||
181 | |||
182 | [special] | ||
183 | g CTRL-g = display file properties including word and char count | ||
184 | q: = show command history and use it like a normal buffer | ||
185 | z= = show spellcheck suggestions | ||
186 | |||
187 | |||
188 | [completions] | ||
189 | CTRL-O = display completions: omnicomplete (context dependant completions) | ||
190 | |||
191 | CTRL-X CTRL-F = display completions: file name (using vim-internals omnicomplete) | ||
192 | CTRL-N CTRL-P = display completions: file keywords | ||
193 | CTRL-K = display completions: dictionary | ||
194 | CTRL-T = display completions: thesaurus | ||
195 | CTRL-I = display completions: include files | ||
196 | CTRL-] = display completions: tags | ||
197 | CTRL-D = display completions: (marcro-) definitions | ||
198 | CTRL-V = display completions: vim command line | ||
199 | CTRL-U = display completions: user-defined | ||
200 | |||
201 | |||
202 | [annoyances] | ||
203 | gv = visual mode: reselect last selection | ||
204 | CTRL-o = lets the caret jump back to the previous location | ||
205 | CTRL-L = redraws the complete screen | ||
206 | CTRL-R<register> = in insert mode and command line: paste contents of <register> (e.g. : for last command, * for clipboard) | ||
207 | CTRL-R = in normal mode: redoes what has been undone with u | ||
208 | "<register>p = in normal mode: paste paste contents of <register> | ||
209 | |||
210 | [registers] | ||
211 | "/ = last search expression | ||
212 | ": = last command entered | ||
213 | "= = expression register (to do calculations or call vim functions) | ||
214 | |||
215 | |||
216 | |||
217 | [netrw] | ||
218 | :Lex = open the netrw-view as project drawer | ||
219 | gn = makes the directory under the cursor the root directory | ||
220 | a = toggles display of hidden files | ||
221 | |||
222 | [filetype:css] | ||
223 | viB:sort = sort inner block by name | ||
224 | |||
225 | [vim commands] | ||
226 | :for i in range(1,12) | put ='2016-'.i | endfor | ||
227 | |||
228 | [fancy utf-8 symbols] | ||
229 | ௵ | ||
230 | |||
231 | [debugging] | ||
232 | :profile! start /tmp/profile.log | ||
233 | :profile func * | ||
234 | :profile file * | ||
235 | " At this point do slow actions | ||
236 | :profdel * | ||
237 | :e /tmp/profile.log | ||
238 | " add a break point to a vim script (like vimrc) to invoke the internal debugger | ||
239 | :breakadd here | ||
240 | |||
241 | :finish = from within a viml-script: stop sourcing it | ||
242 | |||
243 | [substitutions] | ||
244 | delete all comments: %s/\/\*\*< [^(\*\/)]*\*\///g | ||
245 | remove empty lines: global/^$/d | ||
246 | remove non-empty lines: v/^$/d | ||
247 | |||
248 | [programs] | ||
249 | gpm - cut and paste helper for the linux console (to get text from CTRL-ALT-F2 to CTRL-ALT-F3) | ||
250 | |||
251 | |||
252 | [vim modeline] | ||
253 | filetype can have multiple values, like python.django | ||
254 | The last line can be a mode line, which holds settings like tab width: | ||
255 | ``` | ||
256 | |||
257 | |||
258 | ## git | ||
259 | |||
260 | undo last commit: git reset HEAD~ | ||
261 | diff two branches: git diff branch1 branch2 path/to/file | ||
262 | |||
263 | |||
264 | |||
265 | To `~/.gitconfig` add: | ||
266 | [alias] | ||
267 | branchvv = for-each-ref --sort='committerdate:raw' --format='%(HEAD)%(if)%(HEAD)%(then)%(color:bold green)%(end) %(align:width=24)%(refname:short)%(end) %(objectname:short) %(color:bold blue)%(committerdate:iso)%(color:reset) %(if)%(upstream)%(then)[%(color:blue)%(upstream:short)%(color:reset)] %(end)%(subject)' refs/heads | ||
268 | |||
269 | Provides you with `git branchvv`, a command that works similar to `git branch`, | ||
270 | but sorts the branches by modification date and displays them. | ||
271 | |||
272 | |||
273 | # gnu screen | ||
274 | |||
275 | To run Vim in a gnu screen session: | ||
276 | |||
277 | TERM=vte-256color screen vim | ||
278 | |||
279 | But if you are using another terminal there may be further options with even | ||
280 | more capabilities. Starting point for you search could be something like: | ||
281 | |||
282 | find /usr/share/terminfo/ | grep screen | grep 256 | ||
283 | |||
284 | # gvim | ||
285 | |||
286 | Change the default brackground of applications if you see an ugly grey border | ||
287 | around your beatiful theme: | ||
288 | |||
289 | ``` | ||
290 | /* to be saved as ~/.config/gtk-3.0/gtk.css | ||
291 | * thanks to http://stackoverflow.com/users/6899000/proprefenetre */ | ||
292 | @define-color YOUR_BACKGROUND_COLOR #rrggbb; | ||
293 | |||
294 | window#vim-main-window { | ||
295 | background-color: @YOUR_BACKGROUND_COLOR; | ||
296 | } | ||
297 | ``` | ||
298 | |||