├── .vim ├── after │ └── syntax │ │ ├── python.vim │ │ └── vim.vim └── colors │ ├── solarized.vim │ ├── solarized8.vim │ ├── solarized8_flat.vim │ ├── solarized8_high.vim │ └── solarized8_low.vim ├── .vimrc ├── README.md ├── recordings ├── alt-keys-f8-f9-10.gif ├── alt-keys-f8-f9-10.mp4 ├── shift-arrows_then_ctrl-shift.gif └── shift-arrows_then_ctrl-shift.mp4 ├── refresh.sh ├── release ├── cutevim-20231225.com └── cutevim-20231229.com ├── screenshots ├── Windows-Terminal-Duplicate.png ├── Windows-Terminal-New-Profile.png ├── Windows-Terminal-Result.png └── cute-vim.png └── usr └── share └── vim ├── vimfiles ├── after │ └── syntax │ │ ├── python.vim │ │ └── vim.vim └── colors │ ├── solarized.vim │ ├── solarized8.vim │ ├── solarized8_flat.vim │ ├── solarized8_high.vim │ └── solarized8_low.vim └── vimrc /.vim/after/syntax/python.vim: -------------------------------------------------------------------------------- 1 | " a valid comment in italics 2 | "" another valid comment 3 | " also a valid comment 4 | syn match Comment '^\s*\#\s\+.*$' 5 | hi Comment term=NONE,italic cterm=NONE,italic gui=NONE,italic 6 | 7 | "# a valid comment adding bold to italics for emphasis 8 | "" ## another valid comment with emphasis 9 | "" ###### also a valid comment with emphasis 10 | syn match BoldComment '^\s*##\+.*$' 11 | hi BoldComment term=bold,italic cterm=bold,italic gui=bold,italic 12 | 13 | "_ for comment titles with underline added for emphasis 14 | ""_ another comment title with emphasis 15 | "" __ also a valid comment title with emphasis 16 | syn match UnderlineComment '^\s*\#\s*_.*$' 17 | hi UnderlineComment term=NONE,italic,underline cterm=NONE,italic,underline gui=NONE,italic,underline 18 | 19 | "#_ a valid comment adding bold + underline to italics for titles 20 | "" ## __ another valid comment title 21 | "" __ ## another valid comment title 22 | syn match BoldUnderlineComment '^\s*##\+\s*_\+.*$' 23 | hi BoldUnderlineComment term=bold,italic,underline cterm=bold,italic,underline gui=bold,italic,underline 24 | -------------------------------------------------------------------------------- /.vim/after/syntax/vim.vim: -------------------------------------------------------------------------------- 1 | " a valid comment in italics 2 | "" another valid comment 3 | " also a valid comment 4 | syn match Comment '^\s*".*$' 5 | hi Comment term=NONE,italic cterm=NONE,italic gui=NONE,italic 6 | 7 | "# a valid comment adding bold to italics for emphasis 8 | "" ## another valid comment with emphasis 9 | "" ###### also a valid comment with emphasis 10 | syn match BoldComment '^\s*"\+\s*\#.*$' 11 | hi BoldComment term=bold,italic cterm=bold,italic gui=bold,italic 12 | 13 | "# not a valid comment if the double quote is removed so use bold and red instead of italics 14 | syn match InvalidComment '^#.*$' 15 | hi InvalidComment term=bold cterm=bold gui=bold ctermfg=red guifg=red 16 | 17 | "_ for comment titles with underline added for emphasis 18 | ""_ another comment title with emphasis 19 | "" __ also a valid comment title with emphasis 20 | syn match UnderlineComment '^\s*"\+\s*_.*$' 21 | hi UnderlineComment term=NONE,italic,underline cterm=NONE,italic,underline gui=NONE,italic,underline 22 | 23 | "#_ a valid comment adding bold + underline to italics for titles 24 | "" ## __ another valid comment title 25 | "" __ ## another valid comment title 26 | syn match BoldUnderlineComment '^\s*"\+\s*\#\+\s*_\+.*$' 27 | syn match UnderlineBoldComment '^\s*"\+\s*_\+\s*\#\+.*$' 28 | hi link BoldUnderlineComment UnderlineBoldComment 29 | hi UnderlineBoldComment term=bold,italic,underline cterm=bold,italic,underline gui=bold,italic,underline 30 | -------------------------------------------------------------------------------- /.vim/colors/solarized.vim: -------------------------------------------------------------------------------- 1 | " Name: Solarized vim colorscheme 2 | " Author: Ethan Schoonover 3 | " URL: http://ethanschoonover.com/solarized 4 | " (see this url for latest release & screenshots) 5 | " License: OSI approved MIT license (see end of this file) 6 | " Created: In the middle of the night 7 | " Modified: 2011 Apr 14 8 | " 9 | " Usage "{{{ 10 | " 11 | " --------------------------------------------------------------------- 12 | " ABOUT: 13 | " --------------------------------------------------------------------- 14 | " Solarized is a carefully designed selective contrast colorscheme with dual 15 | " light and dark modes that runs in both GUI, 256 and 16 color modes. 16 | " 17 | " See the homepage above for screenshots and details. 18 | " 19 | " --------------------------------------------------------------------- 20 | " INSTALLATION: 21 | " --------------------------------------------------------------------- 22 | " 23 | " Two options for installation: manual or pathogen 24 | " 25 | " MANUAL INSTALLATION OPTION: 26 | " --------------------------------------------------------------------- 27 | " 28 | " 1. Put the files in the right place! 29 | " 2. Move `solarized.vim` to your `.vim/colors` directory. 30 | " 31 | " RECOMMENDED PATHOGEN INSTALLATION OPTION: 32 | " --------------------------------------------------------------------- 33 | " 34 | " 1. Download and install Tim Pope's Pathogen from: 35 | " https://github.com/tpope/vim-pathogen 36 | " 37 | " 2. Next, move or clone the `vim-colors-solarized` directory so that it is 38 | " a subdirectory of the `.vim/bundle` directory. 39 | " 40 | " a. **clone with git:** 41 | " 42 | " $ cd ~/.vim/bundle 43 | " $ git clone git://github.com/altercation/vim-colors-solarized.git 44 | " 45 | " b. **or move manually into the pathogen bundle directory:** 46 | " In the parent directory of vim-colors-solarized: 47 | " 48 | " $ mv vim-colors-solarized ~/.vim/bundle/ 49 | " 50 | " MODIFY VIMRC: 51 | " 52 | " After either Option 1 or Option 2 above, put the following two lines in your 53 | " .vimrc: 54 | " 55 | " syntax enable 56 | " set background=dark 57 | " colorscheme solarized 58 | " 59 | " or, for the light background mode of Solarized: 60 | " 61 | " syntax enable 62 | " set background=light 63 | " colorscheme solarized 64 | " 65 | " I like to have a different background in GUI and terminal modes, so I can use 66 | " the following if-then. However, I find vim's background autodetection to be 67 | " pretty good and, at least with MacVim, I can leave this background value 68 | " assignment out entirely and get the same results. 69 | " 70 | " if has('gui_running') 71 | " set background=light 72 | " else 73 | " set background=dark 74 | " endif 75 | " 76 | " See the Solarized homepage at http://ethanschoonover.com/solarized for 77 | " screenshots which will help you select either the light or dark background. 78 | " 79 | " Other options are detailed below. 80 | " 81 | " IMPORTANT NOTE FOR TERMINAL USERS: 82 | " 83 | " If you are going to use Solarized in Terminal mode (i.e. not in a GUI version 84 | " like gvim or macvim), **please please please** consider setting your terminal 85 | " emulator's colorscheme to used the Solarized palette. I've included palettes 86 | " for some popular terminal emulator as well as Xdefaults in the official 87 | " Solarized download available from [Solarized homepage]. If you use 88 | " Solarized *without* these colors, Solarized will need to be told to degrade 89 | " its colorscheme to a set compatible with the limited 256 terminal palette 90 | " (whereas by using the terminal's 16 ansi color values, you can set the 91 | " correct, specific values for the Solarized palette). 92 | " 93 | " If you do use the custom terminal colors, solarized.vim should work out of 94 | " the box for you. If you are using a terminal emulator that supports 256 95 | " colors and don't want to use the custom Solarized terminal colors, you will 96 | " need to use the degraded 256 colorscheme. To do so, simply add the following 97 | " line *before* the `colorschem solarized` line: 98 | " 99 | " let g:solarized_termcolors=256 100 | " 101 | " Again, I recommend just changing your terminal colors to Solarized values 102 | " either manually or via one of the many terminal schemes available for import. 103 | " 104 | " --------------------------------------------------------------------- 105 | " TOGGLE BACKGROUND FUNCTION: 106 | " --------------------------------------------------------------------- 107 | " 108 | " Solarized comes with a Toggle Background plugin that by default will map to 109 | " if that mapping is available. If it is not available you will need to 110 | " either map the function manually or change your current mapping to 111 | " something else. If you wish to map the function manually, enter the following 112 | " lines in your .vimrc: 113 | " 114 | " nmap ToggleBackground 115 | " imap ToggleBackground 116 | " vmap ToggleBackground 117 | " 118 | " Note that it is important to *not* use the noremap map variants. The plugin 119 | " uses noremap internally. You may run `:help togglebg` for more information. 120 | " 121 | " --------------------------------------------------------------------- 122 | " OPTIONS 123 | " --------------------------------------------------------------------- 124 | " 125 | " Set these in your vimrc file prior to calling the colorscheme. 126 | " 127 | " option name default optional 128 | " ------------------------------------------------ 129 | " g:solarized_termcolors= 16 | 256 130 | " g:solarized_termtrans = 0 | 1 131 | " g:solarized_degrade = 0 | 1 132 | " g:solarized_bold = 1 | 0 133 | " g:solarized_underline = 1 | 0 134 | " g:solarized_italic = 1 | 0 135 | " g:solarized_contrast = "normal"| "high" or "low" 136 | " g:solarized_visibility= "normal"| "high" or "low" 137 | " ------------------------------------------------ 138 | " 139 | " OPTION DETAILS 140 | " 141 | " ------------------------------------------------ 142 | " g:solarized_termcolors= 256 | 16 143 | " ------------------------------------------------ 144 | " The most important option if you are using vim in terminal (non gui) mode! 145 | " This tells Solarized to use the 256 degraded color mode if running in a 256 146 | " color capable terminal. Otherwise, if set to `16` it will use the terminal 147 | " emulators colorscheme (best option as long as you've set the emulators colors 148 | " to the Solarized palette). 149 | " 150 | " If you are going to use Solarized in Terminal mode (i.e. not in a GUI 151 | " version like gvim or macvim), **please please please** consider setting your 152 | " terminal emulator's colorscheme to used the Solarized palette. I've included 153 | " palettes for some popular terminal emulator as well as Xdefaults in the 154 | " official Solarized download available from: 155 | " http://ethanschoonover.com/solarized . If you use Solarized without these 156 | " colors, Solarized will by default use an approximate set of 256 colors. It 157 | " isn't bad looking and has been extensively tweaked, but it's still not quite 158 | " the real thing. 159 | " 160 | " ------------------------------------------------ 161 | " g:solarized_termtrans = 0 | 1 162 | " ------------------------------------------------ 163 | " If you use a terminal emulator with a transparent background and Solarized 164 | " isn't displaying the background color transparently, set this to 1 and 165 | " Solarized will use the default (transparent) background of the terminal 166 | " emulator. *urxvt* required this in my testing; iTerm2 did not. 167 | " 168 | " Note that on Mac OS X Terminal.app, solarized_termtrans is set to 1 by 169 | " default as this is almost always the best option. The only exception to this 170 | " is if the working terminfo file supports 256 colors (xterm-256color). 171 | " 172 | " ------------------------------------------------ 173 | " g:solarized_degrade = 0 | 1 174 | " ------------------------------------------------ 175 | " For test purposes only; forces Solarized to use the 256 degraded color mode 176 | " to test the approximate color values for accuracy. 177 | " 178 | " ------------------------------------------------ 179 | " g:solarized_bold = 1 | 0 180 | " ------------------------------------------------ 181 | " ------------------------------------------------ 182 | " g:solarized_underline = 1 | 0 183 | " ------------------------------------------------ 184 | " ------------------------------------------------ 185 | " g:solarized_italic = 1 | 0 186 | " ------------------------------------------------ 187 | " If you wish to stop Solarized from displaying bold, underlined or 188 | " italicized typefaces, simply assign a zero value to the appropriate 189 | " variable, for example: `let g:solarized_italic=0` 190 | " 191 | " ------------------------------------------------ 192 | " g:solarized_contrast = "normal"| "high" or "low" 193 | " ------------------------------------------------ 194 | " Stick with normal! It's been carefully tested. Setting this option to high 195 | " or low does use the same Solarized palette but simply shifts some values up 196 | " or down in order to expand or compress the tonal range displayed. 197 | " 198 | " ------------------------------------------------ 199 | " g:solarized_visibility = "normal"| "high" or "low" 200 | " ------------------------------------------------ 201 | " Special characters such as trailing whitespace, tabs, newlines, when 202 | " displayed using ":set list" can be set to one of three levels depending on 203 | " your needs. 204 | " 205 | " --------------------------------------------------------------------- 206 | " COLOR VALUES 207 | " --------------------------------------------------------------------- 208 | " Download palettes and files from: http://ethanschoonover.com/solarized 209 | " 210 | " L\*a\*b values are canonical (White D65, Reference D50), other values are 211 | " matched in sRGB space. 212 | " 213 | " SOLARIZED HEX 16/8 TERMCOL XTERM/HEX L*A*B sRGB HSB 214 | " --------- ------- ---- ------- ----------- ---------- ----------- ----------- 215 | " base03 #002b36 8/4 brblack 234 #1c1c1c 15 -12 -12 0 43 54 193 100 21 216 | " base02 #073642 0/4 black 235 #262626 20 -12 -12 7 54 66 192 90 26 217 | " base01 #586e75 10/7 brgreen 240 #4e4e4e 45 -07 -07 88 110 117 194 25 46 218 | " base00 #657b83 11/7 bryellow 241 #585858 50 -07 -07 101 123 131 195 23 51 219 | " base0 #839496 12/6 brblue 244 #808080 60 -06 -03 131 148 150 186 13 59 220 | " base1 #93a1a1 14/4 brcyan 245 #8a8a8a 65 -05 -02 147 161 161 180 9 63 221 | " base2 #eee8d5 7/7 white 254 #d7d7af 92 -00 10 238 232 213 44 11 93 222 | " base3 #fdf6e3 15/7 brwhite 230 #ffffd7 97 00 10 253 246 227 44 10 99 223 | " yellow #b58900 3/3 yellow 136 #af8700 60 10 65 181 137 0 45 100 71 224 | " orange #cb4b16 9/3 brred 166 #d75f00 50 50 55 203 75 22 18 89 80 225 | " red #dc322f 1/1 red 160 #d70000 50 65 45 220 50 47 1 79 86 226 | " magenta #d33682 5/5 magenta 125 #af005f 50 65 -05 211 54 130 331 74 83 227 | " violet #6c71c4 13/5 brmagenta 61 #5f5faf 50 15 -45 108 113 196 237 45 77 228 | " blue #268bd2 4/4 blue 33 #0087ff 55 -10 -45 38 139 210 205 82 82 229 | " cyan #2aa198 6/6 cyan 37 #00afaf 60 -35 -05 42 161 152 175 74 63 230 | " green #859900 2/2 green 64 #5f8700 60 -20 65 133 153 0 68 100 60 231 | " 232 | " --------------------------------------------------------------------- 233 | " COLORSCHEME HACKING 234 | " --------------------------------------------------------------------- 235 | " 236 | " Useful commands for testing colorschemes: 237 | " :source $VIMRUNTIME/syntax/hitest.vim 238 | " :help highlight-groups 239 | " :help cterm-colors 240 | " :help group-name 241 | " 242 | " Useful links for developing colorschemes: 243 | " http://www.vim.org/scripts/script.php?script_id=2937 244 | " http://vimcasts.org/episodes/creating-colorschemes-for-vim/ 245 | " http://www.frexx.de/xterm-256-notes/" 246 | " 247 | " 248 | " }}} 249 | " Default option values"{{{ 250 | " --------------------------------------------------------------------- 251 | if !exists("g:solarized_termtrans") 252 | if ($TERM_PROGRAM ==? "apple_terminal" && &t_Co < 256) 253 | let g:solarized_termtrans = 1 254 | else 255 | let g:solarized_termtrans = 0 256 | endif 257 | endif 258 | if !exists("g:solarized_degrade") 259 | let g:solarized_degrade = 0 260 | endif 261 | if !exists("g:solarized_bold") 262 | let g:solarized_bold = 1 263 | endif 264 | if !exists("g:solarized_underline") 265 | let g:solarized_underline = 1 266 | endif 267 | if !exists("g:solarized_italic") 268 | let g:solarized_italic = 1 269 | endif 270 | if !exists("g:solarized_termcolors") 271 | let g:solarized_termcolors = 16 272 | endif 273 | if !exists("g:solarized_contrast") 274 | let g:solarized_contrast = "normal" 275 | endif 276 | if !exists("g:solarized_visibility") 277 | let g:solarized_visibility = "normal" 278 | endif 279 | "}}} 280 | " Colorscheme initialization "{{{ 281 | " --------------------------------------------------------------------- 282 | hi clear 283 | if exists("syntax_on") 284 | syntax reset 285 | endif 286 | let colors_name = "solarized" 287 | 288 | "}}} 289 | " GUI & CSApprox hexadecimal palettes"{{{ 290 | " --------------------------------------------------------------------- 291 | " 292 | " Set both gui and terminal color values in separate conditional statements 293 | " Due to possibility that CSApprox is running (though I suppose we could just 294 | " leave the hex values out entirely in that case and include only cterm colors) 295 | " We also check to see if user has set solarized (force use of the 296 | " neutral gray monotone palette component) 297 | if (has("gui_running") && g:solarized_degrade == 0) 298 | let s:vmode = "gui" 299 | let s:base03 = "#002b36" 300 | let s:base02 = "#073642" 301 | let s:base01 = "#586e75" 302 | let s:base00 = "#657b83" 303 | let s:base0 = "#839496" 304 | let s:base1 = "#93a1a1" 305 | let s:base2 = "#eee8d5" 306 | let s:base3 = "#fdf6e3" 307 | let s:yellow = "#b58900" 308 | let s:orange = "#cb4b16" 309 | let s:red = "#dc322f" 310 | let s:magenta = "#d33682" 311 | let s:violet = "#6c71c4" 312 | let s:blue = "#268bd2" 313 | let s:cyan = "#2aa198" 314 | let s:green = "#859900" 315 | elseif (has("gui_running") && g:solarized_degrade == 1) 316 | " These colors are identical to the 256 color mode. They may be viewed 317 | " while in gui mode via "let g:solarized_degrade=1", though this is not 318 | " recommened and is for testing only. 319 | let s:vmode = "gui" 320 | let s:base03 = "#1c1c1c" 321 | let s:base02 = "#262626" 322 | let s:base01 = "#4e4e4e" 323 | let s:base00 = "#585858" 324 | let s:base0 = "#808080" 325 | let s:base1 = "#8a8a8a" 326 | let s:base2 = "#d7d7af" 327 | let s:base3 = "#ffffd7" 328 | let s:yellow = "#af8700" 329 | let s:orange = "#d75f00" 330 | let s:red = "#af0000" 331 | let s:magenta = "#af005f" 332 | let s:violet = "#5f5faf" 333 | let s:blue = "#0087ff" 334 | let s:cyan = "#00afaf" 335 | let s:green = "#5f8700" 336 | elseif g:solarized_termcolors != 256 && &t_Co >= 16 337 | let s:vmode = "cterm" 338 | let s:base03 = "8" 339 | let s:base02 = "0" 340 | let s:base01 = "10" 341 | let s:base00 = "11" 342 | let s:base0 = "12" 343 | let s:base1 = "14" 344 | let s:base2 = "7" 345 | let s:base3 = "15" 346 | let s:yellow = "3" 347 | let s:orange = "9" 348 | let s:red = "1" 349 | let s:magenta = "5" 350 | let s:violet = "13" 351 | let s:blue = "4" 352 | let s:cyan = "6" 353 | let s:green = "2" 354 | elseif g:solarized_termcolors == 256 355 | let s:vmode = "cterm" 356 | let s:base03 = "234" 357 | let s:base02 = "235" 358 | let s:base01 = "239" 359 | let s:base00 = "240" 360 | let s:base0 = "244" 361 | let s:base1 = "245" 362 | let s:base2 = "187" 363 | let s:base3 = "230" 364 | let s:yellow = "136" 365 | let s:orange = "166" 366 | let s:red = "124" 367 | let s:magenta = "125" 368 | let s:violet = "61" 369 | let s:blue = "33" 370 | let s:cyan = "37" 371 | let s:green = "64" 372 | else 373 | let s:vmode = "cterm" 374 | let s:bright = "* term=bold cterm=bold" 375 | let s:base03 = "0".s:bright 376 | let s:base02 = "0" 377 | let s:base01 = "2".s:bright 378 | let s:base00 = "3".s:bright 379 | let s:base0 = "4".s:bright 380 | let s:base1 = "6".s:bright 381 | let s:base2 = "7" 382 | let s:base3 = "7".s:bright 383 | let s:yellow = "3" 384 | let s:orange = "1".s:bright 385 | let s:red = "1" 386 | let s:magenta = "5" 387 | let s:violet = "13" 388 | let s:blue = "4" 389 | let s:cyan = "6" 390 | let s:green = "2" 391 | endif 392 | "}}} 393 | " Formatting options and null values for passthrough effect "{{{ 394 | " --------------------------------------------------------------------- 395 | let s:none = "NONE" 396 | let s:none = "NONE" 397 | let s:t_none = "NONE" 398 | let s:n = "NONE" 399 | let s:c = ",undercurl" 400 | let s:r = ",reverse" 401 | let s:s = ",standout" 402 | let s:ou = "" 403 | let s:ob = "" 404 | "}}} 405 | " Background value based on termtrans setting "{{{ 406 | " --------------------------------------------------------------------- 407 | if (has("gui_running") || g:solarized_termtrans == 0) 408 | let s:back = s:base03 409 | else 410 | let s:back = "NONE" 411 | endif 412 | "}}} 413 | " Alternate light scheme "{{{ 414 | " --------------------------------------------------------------------- 415 | if &background == "light" 416 | let s:temp03 = s:base03 417 | let s:temp02 = s:base02 418 | let s:temp01 = s:base01 419 | let s:temp00 = s:base00 420 | let s:base03 = s:base3 421 | let s:base02 = s:base2 422 | let s:base01 = s:base1 423 | let s:base00 = s:base0 424 | let s:base0 = s:temp00 425 | let s:base1 = s:temp01 426 | let s:base2 = s:temp02 427 | let s:base3 = s:temp03 428 | if (s:back != "NONE") 429 | let s:back = s:base03 430 | endif 431 | endif 432 | "}}} 433 | " Optional contrast schemes "{{{ 434 | " --------------------------------------------------------------------- 435 | if g:solarized_contrast == "high" 436 | let s:base01 = s:base00 437 | let s:base00 = s:base0 438 | let s:base0 = s:base1 439 | let s:base1 = s:base2 440 | let s:base2 = s:base3 441 | let s:back = s:back 442 | endif 443 | if g:solarized_contrast == "low" 444 | let s:back = s:base02 445 | let s:ou = ",underline" 446 | endif 447 | "}}} 448 | " Overrides dependent on user specified values"{{{ 449 | " --------------------------------------------------------------------- 450 | if g:solarized_bold == 1 451 | let s:b = ",bold" 452 | else 453 | let s:b = "" 454 | endif 455 | 456 | if g:solarized_underline == 1 457 | let s:u = ",underline" 458 | else 459 | let s:u = "" 460 | endif 461 | 462 | if g:solarized_italic == 1 463 | let s:i = ",italic" 464 | else 465 | let s:i = "" 466 | endif 467 | "}}} 468 | " Highlighting primitives"{{{ 469 | " --------------------------------------------------------------------- 470 | 471 | exe "let s:bg_none = ' ".s:vmode."bg=".s:none ."'" 472 | exe "let s:bg_back = ' ".s:vmode."bg=".s:back ."'" 473 | exe "let s:bg_base03 = ' ".s:vmode."bg=".s:base03 ."'" 474 | exe "let s:bg_base02 = ' ".s:vmode."bg=".s:base02 ."'" 475 | exe "let s:bg_base01 = ' ".s:vmode."bg=".s:base01 ."'" 476 | exe "let s:bg_base00 = ' ".s:vmode."bg=".s:base00 ."'" 477 | exe "let s:bg_base0 = ' ".s:vmode."bg=".s:base0 ."'" 478 | exe "let s:bg_base1 = ' ".s:vmode."bg=".s:base1 ."'" 479 | exe "let s:bg_base2 = ' ".s:vmode."bg=".s:base2 ."'" 480 | exe "let s:bg_base3 = ' ".s:vmode."bg=".s:base3 ."'" 481 | exe "let s:bg_green = ' ".s:vmode."bg=".s:green ."'" 482 | exe "let s:bg_yellow = ' ".s:vmode."bg=".s:yellow ."'" 483 | exe "let s:bg_orange = ' ".s:vmode."bg=".s:orange ."'" 484 | exe "let s:bg_red = ' ".s:vmode."bg=".s:red ."'" 485 | exe "let s:bg_magenta = ' ".s:vmode."bg=".s:magenta."'" 486 | exe "let s:bg_violet = ' ".s:vmode."bg=".s:violet ."'" 487 | exe "let s:bg_blue = ' ".s:vmode."bg=".s:blue ."'" 488 | exe "let s:bg_cyan = ' ".s:vmode."bg=".s:cyan ."'" 489 | 490 | exe "let s:fg_none = ' ".s:vmode."fg=".s:none ."'" 491 | exe "let s:fg_back = ' ".s:vmode."fg=".s:back ."'" 492 | exe "let s:fg_base03 = ' ".s:vmode."fg=".s:base03 ."'" 493 | exe "let s:fg_base02 = ' ".s:vmode."fg=".s:base02 ."'" 494 | exe "let s:fg_base01 = ' ".s:vmode."fg=".s:base01 ."'" 495 | exe "let s:fg_base00 = ' ".s:vmode."fg=".s:base00 ."'" 496 | exe "let s:fg_base0 = ' ".s:vmode."fg=".s:base0 ."'" 497 | exe "let s:fg_base1 = ' ".s:vmode."fg=".s:base1 ."'" 498 | exe "let s:fg_base2 = ' ".s:vmode."fg=".s:base2 ."'" 499 | exe "let s:fg_base3 = ' ".s:vmode."fg=".s:base3 ."'" 500 | exe "let s:fg_green = ' ".s:vmode."fg=".s:green ."'" 501 | exe "let s:fg_yellow = ' ".s:vmode."fg=".s:yellow ."'" 502 | exe "let s:fg_orange = ' ".s:vmode."fg=".s:orange ."'" 503 | exe "let s:fg_red = ' ".s:vmode."fg=".s:red ."'" 504 | exe "let s:fg_magenta = ' ".s:vmode."fg=".s:magenta."'" 505 | exe "let s:fg_violet = ' ".s:vmode."fg=".s:violet ."'" 506 | exe "let s:fg_blue = ' ".s:vmode."fg=".s:blue ."'" 507 | exe "let s:fg_cyan = ' ".s:vmode."fg=".s:cyan ."'" 508 | 509 | exe "let s:fmt_none = ' ".s:vmode."=NONE". " term=NONE". "'" 510 | exe "let s:fmt_bold = ' ".s:vmode."=NONE".s:b. " term=NONE".s:b."'" 511 | exe "let s:fmt_bldi = ' ".s:vmode."=NONE".s:b. " term=NONE".s:b."'" 512 | exe "let s:fmt_undr = ' ".s:vmode."=NONE".s:u. " term=NONE".s:u."'" 513 | exe "let s:fmt_undb = ' ".s:vmode."=NONE".s:u.s:b. " term=NONE".s:u.s:b."'" 514 | exe "let s:fmt_undi = ' ".s:vmode."=NONE".s:u. " term=NONE".s:u."'" 515 | exe "let s:fmt_uopt = ' ".s:vmode."=NONE".s:ou. " term=NONE".s:ou."'" 516 | exe "let s:fmt_curl = ' ".s:vmode."=NONE".s:c. " term=NONE".s:c."'" 517 | exe "let s:fmt_ital = ' ".s:vmode."=NONE". " term=NONE". "'" 518 | exe "let s:fmt_revr = ' ".s:vmode."=NONE".s:r. " term=NONE".s:r."'" 519 | exe "let s:fmt_stnd = ' ".s:vmode."=NONE".s:s. " term=NONE".s:s."'" 520 | 521 | if has("gui_running") 522 | exe "let s:sp_none = ' guisp=".s:none ."'" 523 | exe "let s:sp_back = ' guisp=".s:back ."'" 524 | exe "let s:sp_base03 = ' guisp=".s:base03 ."'" 525 | exe "let s:sp_base02 = ' guisp=".s:base02 ."'" 526 | exe "let s:sp_base01 = ' guisp=".s:base01 ."'" 527 | exe "let s:sp_base00 = ' guisp=".s:base00 ."'" 528 | exe "let s:sp_base0 = ' guisp=".s:base0 ."'" 529 | exe "let s:sp_base1 = ' guisp=".s:base1 ."'" 530 | exe "let s:sp_base2 = ' guisp=".s:base2 ."'" 531 | exe "let s:sp_base3 = ' guisp=".s:base3 ."'" 532 | exe "let s:sp_green = ' guisp=".s:green ."'" 533 | exe "let s:sp_yellow = ' guisp=".s:yellow ."'" 534 | exe "let s:sp_orange = ' guisp=".s:orange ."'" 535 | exe "let s:sp_red = ' guisp=".s:red ."'" 536 | exe "let s:sp_magenta = ' guisp=".s:magenta."'" 537 | exe "let s:sp_violet = ' guisp=".s:violet ."'" 538 | exe "let s:sp_blue = ' guisp=".s:blue ."'" 539 | exe "let s:sp_cyan = ' guisp=".s:cyan ."'" 540 | else 541 | let s:sp_none = "" 542 | let s:sp_back = "" 543 | let s:sp_base03 = "" 544 | let s:sp_base02 = "" 545 | let s:sp_base01 = "" 546 | let s:sp_base00 = "" 547 | let s:sp_base0 = "" 548 | let s:sp_base1 = "" 549 | let s:sp_base2 = "" 550 | let s:sp_base3 = "" 551 | let s:sp_green = "" 552 | let s:sp_yellow = "" 553 | let s:sp_orange = "" 554 | let s:sp_red = "" 555 | let s:sp_magenta = "" 556 | let s:sp_violet = "" 557 | let s:sp_blue = "" 558 | let s:sp_cyan = "" 559 | endif 560 | 561 | "}}} 562 | " Basic highlighting"{{{ 563 | " --------------------------------------------------------------------- 564 | " note that link syntax to avoid duplicate configuration doesn't work with the 565 | " exe compiled formats 566 | 567 | exe "hi! Normal" .s:fmt_none .s:fg_base0 .s:bg_back 568 | 569 | exe "hi! Comment" .s:fmt_ital .s:fg_base01 .s:bg_none 570 | " *Comment any comment 571 | 572 | exe "hi! Constant" .s:fmt_none .s:fg_cyan .s:bg_none 573 | " *Constant any constant 574 | " String a string constant: "this is a string" 575 | " Character a character constant: 'c', '\n' 576 | " Number a number constant: 234, 0xff 577 | " Boolean a boolean constant: TRUE, false 578 | " Float a floating point constant: 2.3e10 579 | 580 | exe "hi! Identifier" .s:fmt_none .s:fg_blue .s:bg_none 581 | " *Identifier any variable name 582 | " Function function name (also: methods for classes) 583 | " 584 | exe "hi! Statement" .s:fmt_none .s:fg_green .s:bg_none 585 | " *Statement any statement 586 | " Conditional if, then, else, endif, switch, etc. 587 | " Repeat for, do, while, etc. 588 | " Label case, default, etc. 589 | " Operator "sizeof", "+", "*", etc. 590 | " Keyword any other keyword 591 | " Exception try, catch, throw 592 | 593 | exe "hi! PreProc" .s:fmt_none .s:fg_orange .s:bg_none 594 | " *PreProc generic Preprocessor 595 | " Include preprocessor #include 596 | " Define preprocessor #define 597 | " Macro same as Define 598 | " PreCondit preprocessor #if, #else, #endif, etc. 599 | 600 | exe "hi! Type" .s:fmt_none .s:fg_yellow .s:bg_none 601 | " *Type int, long, char, etc. 602 | " StorageClass static, register, volatile, etc. 603 | " Structure struct, union, enum, etc. 604 | " Typedef A typedef 605 | 606 | exe "hi! Special" .s:fmt_none .s:fg_red .s:bg_none 607 | " *Special any special symbol 608 | " SpecialChar special character in a constant 609 | " Tag you can use CTRL-] on this 610 | " Delimiter character that needs attention 611 | " SpecialComment special things inside a comment 612 | " Debug debugging statements 613 | 614 | exe "hi! Underlined" .s:fmt_none .s:fg_violet .s:bg_none 615 | " *Underlined text that stands out, HTML links 616 | 617 | exe "hi! Ignore" .s:fmt_none .s:fg_none .s:bg_none 618 | " *Ignore left blank, hidden |hl-Ignore| 619 | 620 | exe "hi! Error" .s:fmt_bold .s:fg_red .s:bg_none 621 | " *Error any erroneous construct 622 | 623 | exe "hi! Todo" .s:fmt_bold .s:fg_magenta.s:bg_none 624 | " *Todo anything that needs extra attention; mostly the 625 | " keywords TODO FIXME and XXX 626 | " 627 | "}}} 628 | " Extended highlighting "{{{ 629 | " --------------------------------------------------------------------- 630 | if (g:solarized_visibility=="high") 631 | exe "hi! SpecialKey" .s:fmt_revr .s:fg_red .s:bg_none 632 | exe "hi! NonText" .s:fmt_bold .s:fg_base1 .s:bg_none 633 | elseif (g:solarized_visibility=="low") 634 | exe "hi! SpecialKey" .s:fmt_bold .s:fg_base02 .s:bg_none 635 | exe "hi! NonText" .s:fmt_bold .s:fg_base02 .s:bg_none 636 | else 637 | exe "hi! SpecialKey" .s:fmt_bold .s:fg_red .s:bg_none 638 | exe "hi! NonText" .s:fmt_bold .s:fg_base01 .s:bg_none 639 | endif 640 | if (has("gui_running")) || &t_Co > 8 641 | exe "hi! StatusLine" .s:fmt_none .s:fg_base02 .s:bg_base1 642 | exe "hi! StatusLineNC" .s:fmt_none .s:fg_base02 .s:bg_base00 643 | "exe "hi! Visual" .s:fmt_stnd .s:fg_none .s:bg_base02 644 | exe "hi! Visual" .s:fmt_none .s:fg_base03 .s:bg_base01 645 | else 646 | exe "hi! StatusLine" .s:fmt_none .s:fg_base02 .s:bg_base2 647 | exe "hi! StatusLineNC" .s:fmt_none .s:fg_base02 .s:bg_base2 648 | exe "hi! Visual" .s:fmt_none .s:fg_none .s:bg_base2 649 | endif 650 | exe "hi! Directory" .s:fmt_none .s:fg_blue .s:bg_none 651 | exe "hi! ErrorMsg" .s:fmt_revr .s:fg_red .s:bg_none 652 | exe "hi! IncSearch" .s:fmt_stnd .s:fg_orange .s:bg_none 653 | exe "hi! Search" .s:fmt_revr .s:fg_yellow .s:bg_none 654 | exe "hi! MoreMsg" .s:fmt_none .s:fg_blue .s:bg_none 655 | exe "hi! ModeMsg" .s:fmt_none .s:fg_blue .s:bg_none 656 | exe "hi! LineNr" .s:fmt_none .s:fg_base01 .s:bg_base02 657 | exe "hi! Question" .s:fmt_bold .s:fg_cyan .s:bg_none 658 | exe "hi! VertSplit" .s:fmt_bold .s:fg_base00 .s:bg_base00 659 | exe "hi! Title" .s:fmt_bold .s:fg_orange .s:bg_none 660 | exe "hi! VisualNOS" .s:fmt_stnd .s:fg_none .s:bg_base02 661 | exe "hi! WarningMsg" .s:fmt_bold .s:fg_red .s:bg_none 662 | exe "hi! WildMenu" .s:fmt_none .s:fg_base2 .s:bg_base02 663 | exe "hi! Folded" .s:fmt_undb .s:fg_base0 .s:bg_base02 .s:sp_base03 664 | exe "hi! FoldColumn" .s:fmt_bold .s:fg_base0 .s:bg_base02 665 | exe "hi! DiffAdd" .s:fmt_revr .s:fg_green .s:bg_none 666 | exe "hi! DiffChange" .s:fmt_revr .s:fg_yellow .s:bg_none 667 | exe "hi! DiffDelete" .s:fmt_revr .s:fg_red .s:bg_none 668 | exe "hi! DiffText" .s:fmt_revr .s:fg_blue .s:bg_none 669 | exe "hi! SignColumn" .s:fmt_none .s:fg_base0 .s:bg_base02 670 | exe "hi! Conceal" .s:fmt_none .s:fg_blue .s:bg_none 671 | exe "hi! SpellBad" .s:fmt_curl .s:fg_none .s:bg_none .s:sp_red 672 | exe "hi! SpellCap" .s:fmt_curl .s:fg_none .s:bg_none .s:sp_violet 673 | exe "hi! SpellRare" .s:fmt_curl .s:fg_none .s:bg_none .s:sp_cyan 674 | exe "hi! SpellLocal" .s:fmt_curl .s:fg_none .s:bg_none .s:sp_yellow 675 | exe "hi! Pmenu" .s:fmt_none .s:fg_base0 .s:bg_base02 676 | exe "hi! PmenuSel" .s:fmt_none .s:fg_base2 .s:bg_base01 677 | exe "hi! PmenuSbar" .s:fmt_none .s:fg_base0 .s:bg_base2 678 | exe "hi! PmenuThumb" .s:fmt_none .s:fg_base03 .s:bg_base0 679 | exe "hi! TabLine" .s:fmt_undr .s:fg_base0 .s:bg_base02 .s:sp_base0 680 | exe "hi! TabLineSel" .s:fmt_undr .s:fg_base2 .s:bg_base01 .s:sp_base0 681 | exe "hi! TabLineFill" .s:fmt_undr .s:fg_base0 .s:bg_base02 .s:sp_base0 682 | exe "hi! CursorColumn" .s:fmt_none .s:fg_none .s:bg_base02 683 | exe "hi! CursorLine" .s:fmt_uopt .s:fg_none .s:bg_base02 .s:sp_base1 684 | exe "hi! ColorColumn" .s:fmt_none .s:fg_none .s:bg_base02 685 | exe "hi! Cursor" .s:fmt_none .s:fg_base03 .s:bg_base0 686 | hi! link lCursor Cursor 687 | exe "hi! MatchParen" .s:fmt_bold .s:fg_red .s:bg_base01 688 | 689 | "}}} 690 | " vim syntax highlighting "{{{ 691 | " --------------------------------------------------------------------- 692 | exe "hi! vimLineComment" . s:fg_base01 .s:bg_none .s:fmt_ital 693 | exe "hi! vimCommentString".s:fg_violet .s:bg_none .s:fmt_none 694 | hi! link vimVar Identifier 695 | hi! link vimFunc Function 696 | hi! link vimUserFunc Function 697 | exe "hi! vimCommand" . s:fg_yellow .s:bg_none .s:fmt_none 698 | exe "hi! vimCmdSep" . s:fg_blue .s:bg_none .s:fmt_bold 699 | exe "hi! helpExample" . s:fg_base1 .s:bg_none .s:fmt_none 700 | hi! link helpSpecial Special 701 | exe "hi! helpOption" . s:fg_cyan .s:bg_none .s:fmt_none 702 | exe "hi! helpNote" . s:fg_magenta.s:bg_none .s:fmt_none 703 | exe "hi! helpVim" . s:fg_magenta.s:bg_none .s:fmt_none 704 | exe "hi! helpHyperTextJump" .s:fg_blue .s:bg_none .s:fmt_undr 705 | exe "hi! helpHyperTextEntry".s:fg_green .s:bg_none .s:fmt_none 706 | exe "hi! vimIsCommand" . s:fg_base00 .s:bg_none .s:fmt_none 707 | exe "hi! vimSynMtchOpt" . s:fg_yellow .s:bg_none .s:fmt_none 708 | exe "hi! vimSynType" . s:fg_cyan .s:bg_none .s:fmt_none 709 | exe "hi! vimHiLink" . s:fg_blue .s:bg_none .s:fmt_none 710 | exe "hi! vimHiGroup" . s:fg_blue .s:bg_none .s:fmt_none 711 | exe "hi! vimGroup" . s:fg_blue .s:bg_none .s:fmt_undb 712 | "}}} 713 | " html highlighting "{{{ 714 | " --------------------------------------------------------------------- 715 | exe "hi! htmlTag" . s:fg_base01 .s:bg_none .s:fmt_none 716 | exe "hi! htmlEndTag" . s:fg_base01 .s:bg_none .s:fmt_none 717 | exe "hi! htmlTagN" . s:fg_base1 .s:bg_none .s:fmt_bold 718 | exe "hi! htmlTagName" . s:fg_blue .s:bg_none .s:fmt_bold 719 | exe "hi! htmlSpecialTagName". s:fg_blue .s:bg_none .s:fmt_ital 720 | exe "hi! htmlArg" . s:fg_base00 .s:bg_none .s:fmt_none 721 | exe "hi! javaScript" . s:fg_yellow .s:bg_none .s:fmt_none 722 | "}}} 723 | " perl highlighting "{{{ 724 | " --------------------------------------------------------------------- 725 | exe "hi! perlHereDoc" . s:fg_base1 .s:bg_back .s:fmt_none 726 | exe "hi! perlVarPlain" . s:fg_yellow .s:bg_back .s:fmt_none 727 | exe "hi! perlStatementFileDesc". s:fg_cyan.s:bg_back.s:fmt_none 728 | 729 | "}}} 730 | " tex highlighting "{{{ 731 | " --------------------------------------------------------------------- 732 | exe "hi! texStatement" . s:fg_cyan .s:bg_back .s:fmt_none 733 | exe "hi! texMathZoneX" . s:fg_yellow .s:bg_back .s:fmt_none 734 | exe "hi! texMathMatcher" . s:fg_yellow .s:bg_back .s:fmt_none 735 | exe "hi! texMathMatcher" . s:fg_yellow .s:bg_back .s:fmt_none 736 | exe "hi! texRefLabel" . s:fg_yellow .s:bg_back .s:fmt_none 737 | "}}} 738 | " ruby highlighting "{{{ 739 | " --------------------------------------------------------------------- 740 | exe "hi! rubyDefine" . s:fg_base1 .s:bg_back .s:fmt_bold 741 | "rubyInclude 742 | "rubySharpBang 743 | "rubyAccess 744 | "rubyPredefinedVariable 745 | "rubyBoolean 746 | "rubyClassVariable 747 | "rubyBeginEnd 748 | "rubyRepeatModifier 749 | "hi! link rubyArrayDelimiter Special " [ , , ] 750 | "rubyCurlyBlock { , , } 751 | 752 | "hi! link rubyClass Keyword 753 | "hi! link rubyModule Keyword 754 | "hi! link rubyKeyword Keyword 755 | "hi! link rubyOperator Operator 756 | "hi! link rubyIdentifier Identifier 757 | "hi! link rubyInstanceVariable Identifier 758 | "hi! link rubyGlobalVariable Identifier 759 | "hi! link rubyClassVariable Identifier 760 | "hi! link rubyConstant Type 761 | "}}} 762 | " haskell syntax highlighting"{{{ 763 | " --------------------------------------------------------------------- 764 | " For use with syntax/haskell.vim : Haskell Syntax File 765 | " http://www.vim.org/scripts/script.php?script_id=3034 766 | " See also Steffen Siering's github repository: 767 | " http://github.com/urso/dotrc/blob/master/vim/syntax/haskell.vim 768 | " --------------------------------------------------------------------- 769 | " 770 | " Treat True and False specially, see the plugin referenced above 771 | let hs_highlight_boolean=1 772 | " highlight delims, see the plugin referenced above 773 | let hs_highlight_delimiters=1 774 | 775 | exe "hi! cPreCondit". s:fg_orange.s:bg_none .s:fmt_none 776 | 777 | exe "hi! VarId" . s:fg_blue .s:bg_none .s:fmt_none 778 | exe "hi! ConId" . s:fg_yellow .s:bg_none .s:fmt_none 779 | exe "hi! hsImport" . s:fg_magenta.s:bg_none .s:fmt_none 780 | exe "hi! hsString" . s:fg_base00 .s:bg_none .s:fmt_none 781 | 782 | exe "hi! hsStructure" . s:fg_cyan .s:bg_none .s:fmt_none 783 | exe "hi! hs_hlFunctionName" . s:fg_blue .s:bg_none 784 | exe "hi! hsStatement" . s:fg_cyan .s:bg_none .s:fmt_none 785 | exe "hi! hsImportLabel" . s:fg_cyan .s:bg_none .s:fmt_none 786 | exe "hi! hs_OpFunctionName" . s:fg_yellow .s:bg_none .s:fmt_none 787 | exe "hi! hs_DeclareFunction" . s:fg_orange .s:bg_none .s:fmt_none 788 | exe "hi! hsVarSym" . s:fg_cyan .s:bg_none .s:fmt_none 789 | exe "hi! hsType" . s:fg_yellow .s:bg_none .s:fmt_none 790 | exe "hi! hsTypedef" . s:fg_cyan .s:bg_none .s:fmt_none 791 | exe "hi! hsModuleName" . s:fg_green .s:bg_none .s:fmt_undr 792 | exe "hi! hsModuleStartLabel" . s:fg_magenta.s:bg_none .s:fmt_none 793 | hi! link hsImportParams Delimiter 794 | hi! link hsDelimTypeExport Delimiter 795 | hi! link hsModuleStartLabel hsStructure 796 | hi! link hsModuleWhereLabel hsModuleStartLabel 797 | 798 | " following is for the haskell-conceal plugin 799 | " the first two items don't have an impact, but better safe 800 | exe "hi! hsNiceOperator" . s:fg_cyan .s:bg_none .s:fmt_none 801 | exe "hi! hsniceoperator" . s:fg_cyan .s:bg_none .s:fmt_none 802 | 803 | "}}} 804 | " pandoc markdown syntax highlighting "{{{ 805 | " --------------------------------------------------------------------- 806 | 807 | "PandocHiLink pandocNormalBlock 808 | exe "hi! pandocTitleBlock" .s:fg_blue .s:bg_none .s:fmt_none 809 | exe "hi! pandocTitleBlockTitle" .s:fg_blue .s:bg_none .s:fmt_bold 810 | exe "hi! pandocTitleComment" .s:fg_blue .s:bg_none .s:fmt_bold 811 | exe "hi! pandocComment" .s:fg_base01 .s:bg_none .s:fmt_ital 812 | exe "hi! pandocVerbatimBlock" .s:fg_yellow .s:bg_none .s:fmt_none 813 | hi! link pandocVerbatimBlockDeep pandocVerbatimBlock 814 | hi! link pandocCodeBlock pandocVerbatimBlock 815 | hi! link pandocCodeBlockDelim pandocVerbatimBlock 816 | exe "hi! pandocBlockQuote" .s:fg_blue .s:bg_none .s:fmt_none 817 | exe "hi! pandocBlockQuoteLeader1" .s:fg_blue .s:bg_none .s:fmt_none 818 | exe "hi! pandocBlockQuoteLeader2" .s:fg_cyan .s:bg_none .s:fmt_none 819 | exe "hi! pandocBlockQuoteLeader3" .s:fg_yellow .s:bg_none .s:fmt_none 820 | exe "hi! pandocBlockQuoteLeader4" .s:fg_red .s:bg_none .s:fmt_none 821 | exe "hi! pandocBlockQuoteLeader5" .s:fg_base0 .s:bg_none .s:fmt_none 822 | exe "hi! pandocBlockQuoteLeader6" .s:fg_base01 .s:bg_none .s:fmt_none 823 | exe "hi! pandocListMarker" .s:fg_magenta.s:bg_none .s:fmt_none 824 | exe "hi! pandocListReference" .s:fg_magenta.s:bg_none .s:fmt_undr 825 | 826 | " Definitions 827 | " --------------------------------------------------------------------- 828 | let s:fg_pdef = s:fg_violet 829 | exe "hi! pandocDefinitionBlock" .s:fg_pdef .s:bg_none .s:fmt_none 830 | exe "hi! pandocDefinitionTerm" .s:fg_pdef .s:bg_none .s:fmt_stnd 831 | exe "hi! pandocDefinitionIndctr" .s:fg_pdef .s:bg_none .s:fmt_bold 832 | exe "hi! pandocEmphasisDefinition" .s:fg_pdef .s:bg_none .s:fmt_ital 833 | exe "hi! pandocEmphasisNestedDefinition" .s:fg_pdef .s:bg_none .s:fmt_bldi 834 | exe "hi! pandocStrongEmphasisDefinition" .s:fg_pdef .s:bg_none .s:fmt_bold 835 | exe "hi! pandocStrongEmphasisNestedDefinition" .s:fg_pdef.s:bg_none.s:fmt_bldi 836 | exe "hi! pandocStrongEmphasisEmphasisDefinition" .s:fg_pdef.s:bg_none.s:fmt_bldi 837 | exe "hi! pandocStrikeoutDefinition" .s:fg_pdef .s:bg_none .s:fmt_revr 838 | exe "hi! pandocVerbatimInlineDefinition" .s:fg_pdef .s:bg_none .s:fmt_none 839 | exe "hi! pandocSuperscriptDefinition" .s:fg_pdef .s:bg_none .s:fmt_none 840 | exe "hi! pandocSubscriptDefinition" .s:fg_pdef .s:bg_none .s:fmt_none 841 | 842 | " Tables 843 | " --------------------------------------------------------------------- 844 | let s:fg_ptable = s:fg_blue 845 | exe "hi! pandocTable" .s:fg_ptable.s:bg_none .s:fmt_none 846 | exe "hi! pandocTableStructure" .s:fg_ptable.s:bg_none .s:fmt_none 847 | hi! link pandocTableStructureTop pandocTableStructre 848 | hi! link pandocTableStructureEnd pandocTableStructre 849 | exe "hi! pandocTableZebraLight" .s:fg_ptable.s:bg_base03.s:fmt_none 850 | exe "hi! pandocTableZebraDark" .s:fg_ptable.s:bg_base02.s:fmt_none 851 | exe "hi! pandocEmphasisTable" .s:fg_ptable.s:bg_none .s:fmt_ital 852 | exe "hi! pandocEmphasisNestedTable" .s:fg_ptable.s:bg_none .s:fmt_bldi 853 | exe "hi! pandocStrongEmphasisTable" .s:fg_ptable.s:bg_none .s:fmt_bold 854 | exe "hi! pandocStrongEmphasisNestedTable" .s:fg_ptable.s:bg_none .s:fmt_bldi 855 | exe "hi! pandocStrongEmphasisEmphasisTable" .s:fg_ptable.s:bg_none .s:fmt_bldi 856 | exe "hi! pandocStrikeoutTable" .s:fg_ptable.s:bg_none .s:fmt_revr 857 | exe "hi! pandocVerbatimInlineTable" .s:fg_ptable.s:bg_none .s:fmt_none 858 | exe "hi! pandocSuperscriptTable" .s:fg_ptable.s:bg_none .s:fmt_none 859 | exe "hi! pandocSubscriptTable" .s:fg_ptable.s:bg_none .s:fmt_none 860 | 861 | " Headings 862 | " --------------------------------------------------------------------- 863 | let s:fg_phead = s:fg_orange 864 | exe "hi! pandocHeading" .s:fg_phead .s:bg_none.s:fmt_bold 865 | exe "hi! pandocHeadingMarker" .s:fg_yellow.s:bg_none.s:fmt_bold 866 | exe "hi! pandocEmphasisHeading" .s:fg_phead .s:bg_none.s:fmt_bldi 867 | exe "hi! pandocEmphasisNestedHeading" .s:fg_phead .s:bg_none.s:fmt_bldi 868 | exe "hi! pandocStrongEmphasisHeading" .s:fg_phead .s:bg_none.s:fmt_bold 869 | exe "hi! pandocStrongEmphasisNestedHeading" .s:fg_phead .s:bg_none.s:fmt_bldi 870 | exe "hi! pandocStrongEmphasisEmphasisHeading".s:fg_phead .s:bg_none.s:fmt_bldi 871 | exe "hi! pandocStrikeoutHeading" .s:fg_phead .s:bg_none.s:fmt_revr 872 | exe "hi! pandocVerbatimInlineHeading" .s:fg_phead .s:bg_none.s:fmt_bold 873 | exe "hi! pandocSuperscriptHeading" .s:fg_phead .s:bg_none.s:fmt_bold 874 | exe "hi! pandocSubscriptHeading" .s:fg_phead .s:bg_none.s:fmt_bold 875 | 876 | " Links 877 | " --------------------------------------------------------------------- 878 | exe "hi! pandocLinkDelim" .s:fg_base01 .s:bg_none .s:fmt_none 879 | exe "hi! pandocLinkLabel" .s:fg_blue .s:bg_none .s:fmt_undr 880 | exe "hi! pandocLinkText" .s:fg_blue .s:bg_none .s:fmt_undb 881 | exe "hi! pandocLinkURL" .s:fg_base00 .s:bg_none .s:fmt_undr 882 | exe "hi! pandocLinkTitle" .s:fg_base00 .s:bg_none .s:fmt_undi 883 | exe "hi! pandocLinkTitleDelim" .s:fg_base01 .s:bg_none .s:fmt_undi .s:sp_base00 884 | exe "hi! pandocLinkDefinition" .s:fg_cyan .s:bg_none .s:fmt_undr .s:sp_base00 885 | exe "hi! pandocLinkDefinitionID" .s:fg_blue .s:bg_none .s:fmt_bold 886 | exe "hi! pandocImageCaption" .s:fg_violet .s:bg_none .s:fmt_undb 887 | exe "hi! pandocFootnoteLink" .s:fg_green .s:bg_none .s:fmt_undr 888 | exe "hi! pandocFootnoteDefLink" .s:fg_green .s:bg_none .s:fmt_bold 889 | exe "hi! pandocFootnoteInline" .s:fg_green .s:bg_none .s:fmt_undb 890 | exe "hi! pandocFootnote" .s:fg_green .s:bg_none .s:fmt_none 891 | exe "hi! pandocCitationDelim" .s:fg_magenta.s:bg_none .s:fmt_none 892 | exe "hi! pandocCitation" .s:fg_magenta.s:bg_none .s:fmt_none 893 | exe "hi! pandocCitationID" .s:fg_magenta.s:bg_none .s:fmt_undr 894 | exe "hi! pandocCitationRef" .s:fg_magenta.s:bg_none .s:fmt_none 895 | 896 | " Main Styles 897 | " --------------------------------------------------------------------- 898 | exe "hi! pandocStyleDelim" .s:fg_base01 .s:bg_none .s:fmt_none 899 | exe "hi! pandocEmphasis" .s:fg_base0 .s:bg_none .s:fmt_ital 900 | exe "hi! pandocEmphasisNested" .s:fg_base0 .s:bg_none .s:fmt_bldi 901 | exe "hi! pandocStrongEmphasis" .s:fg_base0 .s:bg_none .s:fmt_bold 902 | exe "hi! pandocStrongEmphasisNested" .s:fg_base0 .s:bg_none .s:fmt_bldi 903 | exe "hi! pandocStrongEmphasisEmphasis" .s:fg_base0 .s:bg_none .s:fmt_bldi 904 | exe "hi! pandocStrikeout" .s:fg_base01 .s:bg_none .s:fmt_revr 905 | exe "hi! pandocVerbatimInline" .s:fg_yellow .s:bg_none .s:fmt_none 906 | exe "hi! pandocSuperscript" .s:fg_violet .s:bg_none .s:fmt_none 907 | exe "hi! pandocSubscript" .s:fg_violet .s:bg_none .s:fmt_none 908 | 909 | exe "hi! pandocRule" .s:fg_blue .s:bg_none .s:fmt_bold 910 | exe "hi! pandocRuleLine" .s:fg_blue .s:bg_none .s:fmt_bold 911 | exe "hi! pandocEscapePair" .s:fg_red .s:bg_none .s:fmt_bold 912 | exe "hi! pandocCitationRef" .s:fg_magenta.s:bg_none .s:fmt_none 913 | exe "hi! pandocNonBreakingSpace" . s:fg_red .s:bg_none .s:fmt_revr 914 | hi! link pandocEscapedCharacter pandocEscapePair 915 | hi! link pandocLineBreak pandocEscapePair 916 | 917 | " Embedded Code 918 | " --------------------------------------------------------------------- 919 | exe "hi! pandocMetadataDelim" .s:fg_base01 .s:bg_none .s:fmt_none 920 | exe "hi! pandocMetadata" .s:fg_blue .s:bg_none .s:fmt_none 921 | exe "hi! pandocMetadataKey" .s:fg_blue .s:bg_none .s:fmt_none 922 | exe "hi! pandocMetadata" .s:fg_blue .s:bg_none .s:fmt_bold 923 | hi! link pandocMetadataTitle pandocMetadata 924 | 925 | "}}} 926 | " Utility autocommand "{{{ 927 | " --------------------------------------------------------------------- 928 | " In cases where Solarized is initialized inside a terminal vim session and 929 | " then transferred to a gui session via the command `:gui`, the gui vim process 930 | " does not re-read the colorscheme (or .vimrc for that matter) so any `has_gui` 931 | " related code that sets gui specific values isn't executed. 932 | " 933 | " Currently, Solarized sets only the cterm or gui values for the colorscheme 934 | " depending on gui or terminal mode. It's possible that, if the following 935 | " autocommand method is deemed excessively poor form, that approach will be 936 | " used again and the autocommand below will be dropped. 937 | " 938 | " However it seems relatively benign in this case to include the autocommand 939 | " here. It fires only in cases where vim is transferring from terminal to gui 940 | " mode (detected with the script scope s:vmode variable). It also allows for 941 | " other potential terminal customizations that might make gui mode suboptimal. 942 | " 943 | autocmd GUIEnter * if (s:vmode != "gui") | exe "colorscheme " . g:colors_name | endif 944 | "}}} 945 | " License "{{{ 946 | " --------------------------------------------------------------------- 947 | " 948 | " Copyright (c) 2011 Ethan Schoonover 949 | " 950 | " Permission is hereby granted, free of charge, to any person obtaining a copy 951 | " of this software and associated documentation files (the "Software"), to deal 952 | " in the Software without restriction, including without limitation the rights 953 | " to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 954 | " copies of the Software, and to permit persons to whom the Software is 955 | " furnished to do so, subject to the following conditions: 956 | " 957 | " The above copyright notice and this permission notice shall be included in 958 | " all copies or substantial portions of the Software. 959 | " 960 | " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 961 | " IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 962 | " FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 963 | " AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 964 | " LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 965 | " OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 966 | " THE SOFTWARE. 967 | " 968 | " vim:foldmethod=marker:foldlevel=0 969 | "}}} 970 | -------------------------------------------------------------------------------- /.vimrc: -------------------------------------------------------------------------------- 1 | " .vimrc version 20240120 - Januarmaanad 2 | 3 | " #### WHEN STARTING/STOPPING 4 | 5 | " ### FILES 6 | 7 | " ## LOAD PLUGINS AUTOMATICALLY 8 | " Use vim defaults (much better!) to load plugins by default 9 | set nocompatible 10 | 11 | " ## IGNORE MODELINES INSIDE OPENED FILES 12 | " Prevent potential malicious modelines evaluations (default=5) 13 | set modelines=0 14 | 15 | " ## OPENING AND CLOSING FILES (:e, :n) 16 | 17 | " When using :edit autocomplete, deprioritize files named with these extensions: 18 | set suffixes=.aux,.bak,.dvi,.idx,.ps,.swp,.swo,.tar 19 | 20 | " Automatically save modifications to files on :next 21 | set autowrite 22 | 23 | " Disable the vim intro message to show something else 24 | set shortmess=I 25 | 26 | " ## WHEN STARTING WITHOUT A FILE, SHOW A CHOICE 27 | 28 | " Define a function that shows the list and opens the selected file 29 | function! LastFiles() 30 | " Make a list using the backups, turn to paths, then make unique with awk 31 | " (uniq would require sorting first) 32 | let l:recent_backup_files = split(system('find ' . $HOME . '/.vim/backup/ -printf "%T+@ %p\\n"|sort -nr | cut -f 2 -d" "| sed -e "s/.*backup\/%/%/" -e "s|%|/|g" -e "s/~.*//g"' . "| awk '!seen [$0]++'"), '\n') 33 | " Get the most recent 20 files 34 | let l:top20 = l:recent_backup_files[:20] 35 | " Add numbers to the list items 36 | let l:choices = map(copy(l:top20), '"[" . (v:key + 1) . "] " . v:val') 37 | " Display the list and prompt the user 38 | let l:choice = inputlist(l:choices) 39 | " Check if the choice is valid 40 | if l:choice > 0 && l:choice <= len(l:top20) 41 | " Edit the chosen file 42 | execute "edit" l:top20[l:choice - 1] 43 | endif 44 | endfunction 45 | 46 | if has("autocmd") 47 | autocmd VimEnter * if !argc() | call LastFiles() 48 | endif 49 | 50 | " ## KEEP BACKUPS AND UNDO ON A PER FILE BASIS 51 | " # ACCOMODATE WINDOWS BAREMETAL: NO $HOME DEFINED 52 | if (!exists('$HOME') && exists('$HOMEDRIVE') && exists('$HOMEPATH')) 53 | let $HOME=$HOMEDRIVE.$HOMEPATH 54 | endif 55 | 56 | " In ~/.vim/ : backup swap undo .netrwhist 57 | if !isdirectory($HOME."/.vim") 58 | call mkdir($HOME."/.vim", "", 0770) 59 | endif 60 | 61 | " In case of a crash, save a swapfile 62 | if !isdirectory($HOME."/.vim/swap") 63 | call mkdir($HOME."/.vim/swap", "", 0700) 64 | endif 65 | set directory=~/.vim/swap 66 | 67 | " In regular use, keep a per file undo history 68 | if !isdirectory($HOME."/.vim/undo") 69 | call mkdir($HOME."/.vim/undo", "", 0700) 70 | endif 71 | set undodir=~/.vim/undo 72 | set undofile 73 | 74 | " After saving, backup the old file as file~ 75 | if !isdirectory($HOME."/.vim/backup") 76 | call mkdir($HOME."/.vim/backup", "", 0700) 77 | endif 78 | set backupdir=~/.vim/backup 79 | set backup 80 | 81 | " ## JUMP TO THE LAST KNOWN CURSOR POSITION 82 | if has("autocmd") 83 | " Not done if the position is invalid or when inside an event handler 84 | " (happens when dropping a file on gvim). 85 | autocmd BufReadPost * 86 | \ if line("'\"") > 0 && line("'\"") <= line("$") | 87 | \ exe "normal g`\"" | 88 | \ endif " if line 89 | endif 90 | 91 | " ## KEEP PREVIOUS VERSIONS OF FILES 92 | " WARNING: autocmd can confuse to busybox vi, always make it conditional 93 | if has("autocmd") 94 | " Can limit max files per day with .strftime("%F") or if per hour: %F.%H etc 95 | " Use an extension to the buffer filename on open 96 | "autocmd BufWritePre * let &bex = '~' . strftime("%F") 97 | " On better, do that on write with the full recoded path 98 | " # WARNING: check an exclusion list to avoid saving sensitive files 99 | " only 1 exclusion so far: /var/tmp where sudoedit saves files 100 | if expand("%:p") =~ "^/var/tmp/" 101 | " cf https://vi.stackexchange.com/questions/16843/what-does-nowritebackup-actually-do 102 | autocmd BufWritePre * :silent! set nobackup nowritebackup 103 | autocmd BufWritePost * :silent! set backup 104 | else 105 | autocmd BufWritePost * :silent! execute ':w! ' . &backupdir . "/" . substitute(escape(substitute(expand('%:p'), "/", "%", "g"), "%"), ' ', '\\ ', 'g') . '~' . strftime("%F.%H") 106 | endif 107 | endif 108 | 109 | " ### TERMINAL 110 | 111 | " ## USE ALTERNATE SCREEN TO LEAVE A CLEAR SCREEN ON EXIT 112 | 113 | " Either don't clear the screen upon exit 114 | "set t_ti= 115 | "set t_te= 116 | 117 | " Or do not damage scrollback using the alternative screen buffer 118 | "set t_ti=^[[?1049h 119 | "set t_te=^[[?1049l 120 | 121 | " Or by default, leave it to terminfo based on $TERM: check if the test fails: 122 | " printf "Hello, \e[?1049h ABCDEFG \e[?1049l World\n" 123 | " as it can also be a (deprecated) variant of: 124 | " printf "Hello, \e[[?47h ABCDEFG \e[2J\e[[?47l World\n" 125 | 126 | " This is because ti clears memory before switching to the alternate screen. 127 | " The older and deprecated \E[?47h did not do this, requiring applications to embed 128 | " a \E[2J in the ti string which is called rmcup by terminfo. 129 | " It's seen with $TERM=xterm-old where rmcup=\E[2J\E[?47l\E8, smcup=\E7\E[?47h 130 | " set t_ti=^[7^[[r^[[?47h t_te=^[[?47l^[8 131 | 132 | " ## SAVE POWER BY CHANGING THE CURSOR TO NOT BLINK 133 | 134 | " When starting vi, based on the above, use a block curson 135 | "let &t_ti.="\e[1 q" " blinking 136 | let &t_ti.="\e[2 q" " not blinking 137 | "let &t_ti .= "\e[?2004h" 138 | " When leaving vim likewise: 139 | "let &t_te.="\e[0 q" " reset the cursor 140 | let &t_te.="\e[2 q" " block not blinking 141 | "let &t_te = "\e[?2004l" . &t_te 142 | 143 | " Then change cursor depending on mode: 144 | " (can also use colors ex blinking orange) 145 | " let &t_SI = "\e[5 q\e]12;orange\x7" 146 | 147 | " Insert mode 148 | let &t_SI.="\e[6 q" " bar unblinking 149 | "let &t_SI.="\e[5 q" " bar blinking 150 | " Replace mode 151 | let &t_SR.="\e[4 q" " underline unblinking 152 | "let &t_SR.="\e[3 q" " underline blinking 153 | " Otherwise 154 | let &t_EI.="\e[2 q" " block unblinking 155 | "let &t_EI.="\e[1 q" " unblinking 156 | 157 | " vim supports modifyOtherKeys (dedicated section below) 158 | "cf https://vi.stackexchange.com/questions/27399/whats-t-te-and-t-ti-added-by-vim-8 159 | " but foot needs a workaround for a vim bug to jump between prompts 160 | "cf https://github.com/vim/vim/issues/9014 161 | "cf https://codeberg.org/dnkl/foot/wiki#vim 162 | " Vim thinks modifyOtherKeys level 2 is enabled, even when it's not 163 | " The snippets below ensure modifyOtherKeys=2 is enabled. 164 | if &term =~ "foot" 165 | let &t_TI = "\e[>4;2m" 166 | let &t_TE = "\e[>4;m" 167 | endif 168 | 169 | " ## SET THE TITLEBAR 170 | " Filename associated with the current edit buffer in the xterm title 171 | set title 172 | let &titlestring = expand("%:t") 173 | 174 | " #### BACKSPACE AND DELETE KEYS 175 | 176 | " ### DELETE 177 | " Make delete work by approximating the right sequence even without terminfo 178 | set t_kD=^[[3~ 179 | " ...except in VT100 mode where it's Ctrl-? 180 | if &term =~ "vt100" 181 | set t_kD= 182 | endif 183 | 184 | " ## SHIFT-DELETE 185 | " Shift-Delete deletes to the end of the line like Ctrl-K 186 | inoremap d$ 187 | noremap d$ 188 | " Shift-Delete in foot, wezterm and others 189 | inoremap [3;2~ d$ 190 | noremap [3;2~ d$ 191 | 192 | " ## ALT-DELETE 193 | " TODO: currently the same for Alt-Delete, change it? 194 | inoremap d$ 195 | noremap d$ 196 | " Alt-Delete in foot, wezterm and others 197 | inoremap [3;3~ d$ 198 | noremap [3;3~ d$ 199 | 200 | " ## CTRL-DELETE 201 | " Make Ctrl-Delete delete next word 202 | inoremap [3;5~ dw 203 | " outside insert mode, delete the entire word 204 | "noremap [3;5~ daw 205 | " or delete from the cursor position 206 | noremap [3;5~ dw 207 | " Same for the variant for tmux and urxvt 208 | inoremap [3M dw 209 | "noremap [3M daw 210 | noremap [3M dw 211 | inoremap [3^ dw 212 | "noremap [3^ daw 213 | noremap [3^ dw 214 | 215 | " ### BACKSPACE 216 | " Make backspace work by approximating the right sequence even without terminfo 217 | set t_kb= 218 | if &term =~ "vt100" 219 | " ...except in VT100 mode where it's Ctrl-H 220 | set t_kb= 221 | "else 222 | "" but otherwise Ctrl-H is Ctrl-Backspace 223 | "inoremap db 224 | "noremap bdw 225 | endif 226 | 227 | " Allow backspacing over everything in insert mode 228 | " When backspacing, do not stop at \n: go to previous line if necessary 229 | set backspace=indent,eol,start 230 | 231 | " ## SHIFT-BACKSPACE 232 | " Shift-Backspace deletes to the beginning of line like Ctrl-U 233 | inoremap d0 234 | noremap d0 235 | 236 | " ## ALT-BACKSPACE 237 | " TODO: currently the same for Alt-Backspace, change it? 238 | inoremap d0 239 | noremap d0 240 | " Alt-Backspace for wezterm 241 | inoremap d0 242 | noremap d0 243 | 244 | " ## CTRL-BACKSPACE 245 | " Ctrl-Backspace deletes previous word in insert mode. 246 | " Outside a VT100, gives either Ctrl-_ or Ctrl-H 247 | " To remain generic map both and + test for vt100 above to also cover 248 | inoremap db 249 | inoremap db 250 | " and in edit mode too 251 | noremap bdw 252 | noremap bdw 253 | " If this test doesn't work, see the modifyOtherKeys section below 254 | "nnoremap echomsg 'C-BS was hit' 255 | 256 | " #### MOKS, CONTROL KEYS AND SHORTCUTS 257 | 258 | " ### MOKS SEQUENCES 259 | " modifyOtherKeys allows to separate from , from è etc 260 | " and map shortcuts beyond C0 ie Ctrl-symbol with symbol outside @[\]^_space 261 | "cf https://invisible-island.net/xterm/modified-keys.html 262 | "cf https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyCursorKeys 263 | " can see the exact mok sequence with a log file like 264 | "rm /tmp/logfile && vim --cmd "call ch_logfile('/tmp/logfile', 'w')" && vim /tmp/logfile 265 | " cf https://groups.google.com/g/vim_dev/c/OwIDwziTHQ8 266 | 267 | " ## CTRL-BACKSPACE NEEDS A SPECIAL CASE TO BACKWARD WORD DELETE 268 | " Ctrl-Backspace with wezterm in vim: with Ctrl-Q Ctrl-Backspace vim sees ^H 269 | " but in the logfile, Ctrl-BS really generates the MOK: ^[[27;5;8~ 270 | " So this doesn't works: 271 | "nnoremap echomsg 'C-BS was hit' 272 | " While this works: 273 | "nnoremap [27;5;8~ echomsg 'C-BS was hit' 274 | " Not clear why C-BS doesn't work when C-; doesn't need the MOK: 275 | " This works even if Ctrl-; ^[[27;5;59~ on my wezterm: 276 | "nnoremap echomsg 'C-; was hit' 277 | " So start by a special case for remapping Ctrl-Backspace 278 | nnoremap [27;5;8~ bdw 279 | inoremap [27;5;8~ db 280 | " And don't fully trust the map of other shortcuts: test and document each MOK 281 | 282 | " ## CTRL-SLASH NEEDS A SPECIAL CASE TO DO COMPOSE LIKE CTRL-K 283 | 284 | " Remap the MOK for Ctrl-K to the Emacs-like kill to the EOL 285 | " Ctrl-k is [27;5;107~ 286 | "nnoremap [27;5;107~ D 287 | inoremap [27;5;107~ D 288 | " Can then map some other MOK to achieve Ctrl-K compose function: here Ctrl-/ 289 | " Ctrl-/ is [27;5;47~ 290 | "nnoremap [27;5;47~ 291 | inoremap [27;5;47~ 292 | 293 | " ## OTHERS ON A CASE-BY-CASE 294 | 295 | " Left available in C0: Ctrl-\, Ctrl-; 296 | " Ctrl-_ (maps to Ctrl-/), Ctrl-` (maps to Ctrl-@) 297 | " Ctrl-` mok is [27;5;96~ 298 | nnoremap [27;5;96~ echomsg 'C-@ was hit' 299 | " Ctrl-; mok is [27;5;59~ 300 | nnoremap [27;5;59~ echomsg 'C-; was hit' 301 | " Ctrl-' mok is [27;5;39~ but doesn't work 302 | nnoremap [27;5;39~ echomsg 'C-apostrophe was hit' 303 | " Ctrl-\ mok is [27;5;92~ 304 | nnoremap [27;5;92~ echomsg 'C-\ was hit' 305 | " Ctrl-/ mok is [27;5;47~ 306 | "nnoremap [27;5;47~ echomsg 'C-/ was hit' 307 | " Ctrl-/ was mapped to compose 308 | 309 | " ## SAVE CTRL- ORIGINAL FUNCTIONS BEFORE DEDUPED MAPPINGS 310 | 311 | " Keep Ctrl-I/Ctrl-O to jump between previous edit positions (:change ) 312 | " Ctrl-I is confused with Tab, while Tab in normal mode is helpful for indent 313 | "nnoremap [27;5;105~ echomsg 'C-I was hit' 314 | " This "saves" the function of C-I before adding a separate mapping to Tab 315 | "cf https://vi.stackexchange.com/questions/16161/how-to-map-c-i-separate-from-tab 316 | nnoremap 317 | 318 | " Ctrl-O is working normally 319 | "nnoremap [27;5;111~ echomsg 'C-O was hit' 320 | 321 | " ### SHORTCUTS 322 | 323 | " Allow cursor keys within insert mode by timeout, cf timeoutlen ttimeoutlen 324 | set esckeys 325 | 326 | " ## BASH/READLINE LIKE HOME/END WORD/LINE DELETE LEFT/RIGHT CTRL-AESWUK 327 | 328 | " Make Ctrl-A go to the beginning of the line (instead of default: increment) 329 | inoremap 330 | noremap 331 | 332 | " Make Ctrl-E go to the end of the line 333 | inoremap 334 | noremap 335 | 336 | " Make Ctrl-S delete the next word, typically Esc-D equivalent to Alt-D in bash 337 | inoremap dw 338 | noremap daw 339 | 340 | " Make Ctrl-W delete the previous work 341 | inoremap dB 342 | noremap bdw 343 | 344 | " Make Ctrl-K delete to the end of the line: D is a synonym of d$ 345 | " Vim default C-K was compose: remapping compose may need some MOK magic 346 | " Add the following to have Ctrl-K work in edit mode even without MOK support 347 | "inoremap D 348 | noremap D 349 | " Could also use backspace as a compose key for accents/8 bits chars/unicode 350 | "set digraph 351 | 352 | " Make Ctrl-U delete to the beginning of the line 353 | inoremap d0 354 | noremap d0 355 | 356 | " For Ctrl-K Ctrl-U killing a whole like, Ctrl-U should remove the cursor too 357 | "noremap ld0 358 | 359 | " Alternative to make Ctrl-K Ctrl-U clear the whole line 360 | "set virtualedit=onemore 361 | " FIXME: onemore worst 'side effect": x won't delete past EOL to merge lines 362 | " TODO: should have a remap of the whole sequence like 363 | "remap D d0 x 364 | " but timings break the magic: the intermediate state of C-K will not be seen 365 | 366 | " WONTFIX: In Ctrl-K Ctrl-U, after Ctrl-K the cursor will end on (the left of) 367 | " the current character so the current character won't be deleted, unlike bash 368 | " This might be fixable by using c$ or C to go into insert mode but such a rare 369 | " case could disrupt normal function that is more often needed 370 | 371 | " ## WINDOWS-LIKE UNDO, REDO WITH CTRL-Z CTRL-Y 372 | 373 | " CTRL-Z is Undo; not in cmdline though 374 | noremap u 375 | inoremap u 376 | 377 | " CTRL-Y tries to be Redo (although not repeat); not in cmdline though 378 | " TODO: see how Ctrl-R does it to do the same (Ctrl-R is a better redo) 379 | noremap 380 | inoremap 381 | 382 | " ## WINDOWS-LIKE MOVE WITH CTRL+ARROWS 383 | 384 | " Ctrl-Left|Right are mapped by default 385 | " Ctrl-Home [1;5H is already defined by default 386 | " Likewise Ctrl-End [1;5F is already defined by default 387 | " If going to EOL instead of EOF is wanted, need settings like: 388 | "inoremap [1;5F 389 | "nnoremap [1;5F 390 | ""vnoremap [1;5F 391 | 392 | " On MacOS, when Terminal.app has Option key being a Meta key 393 | " Option-Left and Option-Right are mapped to the Emacs equivalents 394 | inoremap f 395 | nnoremap f 396 | inoremap b 397 | nnoremap b 398 | " Option-Up and Option-Down are not mapped 399 | 400 | " Ctrl-Up|Down jump to the beginning or end of the paragraph: 401 | " non repeatable version: 402 | "inoremap [1;5A {i 403 | "nnoremap [1;5A { 404 | "inoremap [1;5B }i 405 | "nnoremap [1;5B } 406 | " repeatable version: needs h to go back one char 407 | inoremap [1;5A {hi 408 | nnoremap [1;5A { 409 | inoremap [1;5B }i 410 | nnoremap [1;5B } 411 | 412 | " ## WINDOWS-LIKE SELECT WITH SHIFT+ARROWS 413 | 414 | inoremap vw 415 | nnoremap vw 416 | vnoremap w 417 | inoremap vb 418 | nnoremap vb 419 | vnoremap b 420 | inoremap v 421 | nnoremap v 422 | vnoremap 423 | inoremap v 424 | nnoremap v 425 | vnoremap 426 | 427 | " ## ECLIPSE-LIKE ALT+ARROW MOVES THE SELECTED LINES OR THE CURRENT LINE 428 | " in insert mode, just the current line, indented with == 429 | " gi moves to the last position and reenters insert mode 430 | inoremap :m .-2==gi 431 | inoremap :m .+1==gi 432 | " otherwise move full lines of the selection even if not extends to begin/EOL 433 | " "==" can be used to "fix" identation, then gv for reselect in visual 434 | nnoremap :m .-2== 435 | nnoremap :m .+1== 436 | vnoremap :m .-2==gv 437 | vnoremap :m '>+1==gv 438 | " this will move the whole word left and right 439 | " # FIXME: should includes commas (etc) and only consider spaces boundaries 440 | nnoremap bdwbP`[l 441 | nnoremap bdwwP`[l 442 | " eb instead of b necessary for right to repeat more than once 443 | inoremap ebdwbP`[li 444 | inoremap ebdwwP`[li 445 | " this will move just the selection if it exists 446 | "vnoremap dhPgvhoho 447 | "vnoremap dpgvlolo 448 | " # FIXME: trims following the selection, instead of rounding up to whole words 449 | vnoremap dbP`[v`] 450 | vnoremap dwhp`[v`] 451 | 452 | " ## NOTEPAD++ LIKE CTRL+SHIFT+ARROW MOVES THE SELECTED BLOCK 453 | " insert mode is useless: done by vnoremap 454 | " so just "duplicate" alt functionality if no selection 455 | inoremap :m .+1==gi 456 | inoremap :m .-2==gi 457 | " WARNING: wezterm remaps Ctrl+Shift+Up/Down for ActivatePaneDirection="Up|Down" 458 | "cf https://wezfurlong.org/wezterm/config/default-keys.html 459 | " Can avoid the errors on the first and last lines with MoveLineAndInsert() 460 | "cf https://superuser.com/questions/1434741/vim-move-selection-up-down-with-ctrlshiftarrow 461 | " if want to do only the full lines 462 | "nnoremap :m '<,'>-2== 463 | "nnoremap :m '<,'>+1== 464 | " here different from the above: cuts the selection out of the line 465 | " # FIXME: should keep the horizontal coordinate in case a line up or down is empty 466 | nnoremap :m '<-2== 467 | nnoremap :m '>+1== 468 | 469 | "" this UP works alone + in repetitions 470 | "vnoremap dkPV`] 471 | "" but this DOWN only works if prefixed by UP the 1st time 472 | "vnoremap dpV`] 473 | " better: 474 | " this will move the selection if it exists 475 | vnoremap dkP`[v`] 476 | vnoremap djP`[v`] 477 | " this will move the selection left and right if it exists 478 | vnoremap dhPgvhoho 479 | vnoremap dpgvlolo 480 | 481 | " ## SUSE METHOD TO MAP EDIT AND KEYMAP KEYS 482 | " Should keep it: wezterm home=OH end=OF as in the old xterm/kvt section 483 | 484 | " Defaults from suse to try and get the correct main terminal type and edit keyss 485 | if &term =~ "xterm" 486 | let myterm = "xterm" 487 | else 488 | let myterm = &term 489 | endif 490 | let myterm = substitute(myterm, "cons[0-9][0-9].*$", "linux", "") 491 | let myterm = substitute(myterm, "vt1[0-9][0-9].*$", "vt100", "") 492 | let myterm = substitute(myterm, "vt2[0-9][0-9].*$", "vt220", "") 493 | let myterm = substitute(myterm, "\\([^-]*\\)[_-].*$", "\\1", "") 494 | 495 | " Here we define the keys of the NumLock in keyboard transmit mode of xterm 496 | " which misses or hasn't activated Alt/NumLock Modifiers. Often not defined 497 | " within termcap/terminfo and we should map the character printed on the keys. 498 | if myterm == "xterm" || myterm == "kvt" || myterm == "gnome" 499 | " keys in insert/command mode. 500 | map! Oo : 501 | map! Oj * 502 | map! Om - 503 | map! Ok + 504 | map! Ol , 505 | map! OM 506 | map! Ow 7 507 | map! Ox 8 508 | map! Oy 9 509 | map! Ot 4 510 | map! Ou 5 511 | map! Ov 6 512 | map! Oq 1 513 | map! Or 2 514 | map! Os 3 515 | map! Op 0 516 | map! On . 517 | " keys in normal mode 518 | map Oo : 519 | map Oj * 520 | map Om - 521 | map Ok + 522 | map Ol , 523 | map OM 524 | map Ow 7 525 | map Ox 8 526 | map Oy 9 527 | map Ot 4 528 | map Ou 5 529 | map Ov 6 530 | map Oq 1 531 | map Or 2 532 | map Os 3 533 | map Op 0 534 | map On . 535 | endif 536 | 537 | " xterm but without activated keyboard transmit mode 538 | " and therefore not defined in termcap/terminfo. 539 | if myterm == "xterm" || myterm == "kvt" || myterm == "gnome" 540 | " keys in insert/command mode. 541 | map! [H 542 | map! [F 543 | " Home/End: older xterms 544 | map! [1~ 545 | map! [4~ 546 | " Up/Down/Right/Left 547 | map! [A 548 | map! [B 549 | map! [C 550 | map! [D 551 | " KP_5 (NumLock off) to Backspace 552 | "map! [E 553 | " KP_5 (NumLock off) to Insert 554 | map! [E 555 | " PageUp/PageDown 556 | map [5~ 557 | map [6~ 558 | map [5;2~ 559 | map [6;2~ 560 | map [5;5~ 561 | map [6;5~ 562 | " keys in normal mode 563 | map [H 0 564 | map [F $ 565 | " Home/End: older xterms 566 | map [1~ 0 567 | map [4~ $ 568 | " Up/Down/Right/Left 569 | map [A k 570 | map [B j 571 | map [C l 572 | map [D h 573 | " KP_5 (NumLock off) to Backspace 574 | "map [E d 575 | " KP_5 (NumLock off) to Insert 576 | map [E i 577 | " PageUp/PageDown 578 | map [5~  579 | map [6~  580 | map [5;2~  581 | map [6;2~  582 | map [5;5~  583 | map [6;5~  584 | endif 585 | 586 | " xterm/kvt but with activated keyboard transmit mode. 587 | " Sometimes not (or wronglr) defined within termcap/terminfo. 588 | if myterm == "xterm" || myterm == "kvt" || myterm == "gnome" 589 | " keys in insert/command mode. 590 | map! OH 591 | map! OF 592 | map! O2H 593 | map! O2F 594 | map! O5H 595 | map! O5F 596 | " Cursor keys which mostly work by default 597 | " map! OA 598 | " map! OB 599 | " map! OC 600 | " map! OD 601 | map! [2;2~ 602 | map! [2;5~ 603 | map! O2A 604 | map! O2B 605 | map! O2C 606 | map! O2D 607 | map! O5A 608 | map! O5B 609 | map! O5C 610 | map! O5D 611 | " KP_5 (NumLock off) to Backspace 612 | "map! OE 613 | " KP_5 (NumLock off) to Insert 614 | map! OE 615 | " keys in normal mode 616 | map OH 0 617 | map OF $ 618 | map O2H 0 619 | map O2F $ 620 | map O5H 0 621 | map O5F $ 622 | " Cursor keys which mostly work by default 623 | " map OA k 624 | " map OB j 625 | " map OD h 626 | " map OC l 627 | map [2;2~ i 628 | map [2;5~ i 629 | map O2A ^B 630 | map O2B ^F 631 | map O2D b 632 | map O2C w 633 | map O5A ^B 634 | map O5B ^F 635 | map O5D b 636 | map O5C w 637 | " KP_5 (with NumLock off) to Backspace 638 | " map OE d 639 | " KP_5 (with NumLock off) to Insert 640 | map OE i 641 | endif 642 | 643 | if myterm == "linux" 644 | " keys in insert/command mode. 645 | map! [G 646 | " KP_5 (NumLock off) 647 | " keys in normal mode 648 | " KP_5 (NumLock off) 649 | map [G i 650 | endif 651 | 652 | " ## MAKE Y, V, C AND D CONSISTENT IN COMMAND MODE 653 | 654 | " D and C delete and change from the cursor to EOL 655 | " so make Y do non recursively yank from the cursor to EOL 656 | nnoremap Y y$ 657 | 658 | " V does select the whole line: likewies, not very consistent 659 | " this make V do a selection until the EOL 660 | nnoremap V v$ 661 | " while vv preserves the original function of selecting the whole lin 662 | nnoremap vv V 663 | 664 | " ### FUNCTIONS 665 | 666 | " ## MOUSE-ENABLED VISUAL MODE 667 | " For terminal emulators with mouse support 668 | behave xterm 669 | set selectmode=mouse 670 | " Disable vim automatic visual mode on mouse select 671 | "set mouse-=a 672 | " or keep visual mode but copy without the line numbers 673 | set mouse=a 674 | " Shift-Insert works like in Xterm 675 | map 676 | map! 677 | " Hide the mouse pointer while typing 678 | set mousehide 679 | 680 | " ## SEARCH & REPLACE 681 | 682 | " Show matches while incrementially searching 683 | set incsearch 684 | " Hilight search strings 685 | set hlsearch 686 | " Ignore the case in search patterns, required for smartcase 687 | set ignorecase 688 | " Default to ignore case, can restore with /searchsomething\c 689 | set smartcase 690 | 691 | " ## TAB INDENTS, SHIFT-TAB UNINDENTS 692 | 693 | " Replace tab with softtabstop spaces for indentation (problematic for python) 694 | "set expandtab 695 | " Instead, do better: 696 | " Number of spaces added when indenting using >>, <<, == (etc): 697 | set shiftwidth=4 698 | " Number of spaces pressing on will add: 699 | set softtabstop=8 700 | " Number of columns a tab fills on the screen: 701 | "set tabstop=8 702 | " In insert mode, the Tab key function depends on the above: 703 | " at the beginning of the line, 1 tab=4 spaces, 2 tabs=1 tab char 704 | set smarttab 705 | "Keep indentation from previous line 706 | "set autoindent 707 | " Off since I usually prefer perltidy 708 | set noautoindent 709 | "Automatically indents new lines based on old lines 710 | set smartindent 711 | "Like smartindent, but stricter and more customisable yet breaks on urls 712 | "set cindent 713 | 714 | " Tab to indent and Shit-Tab to unindent 715 | nmap >>k 716 | nmap <<k 717 | vmap :'<,'>>> 718 | vmap :'<,'><< 719 | 720 | " ## COPY/CUT AND PASTE 721 | 722 | " Due to remap of Ctrl-c and Ctrl-v to copy/paste 723 | " can make Ctrl-q input chars like Ctrl-v did with: 724 | "noremap! 725 | " (but already setup by default, no need to redo it) 726 | 727 | " Use system clipboard to yank from other applications in gvim 728 | "set clipboard=unnamedplus 729 | set clipboard=unnamed 730 | 731 | " Paste from xterm by definining F28 and F29 732 | function! XTermPasteBegin(ret) 733 | set pastetoggle= 734 | set paste 735 | return a:ret 736 | endfunction 737 | 738 | execute "set =\[200~" 739 | execute "set =\[201~" 740 | map XTermPasteBegin("i") 741 | imap XTermPasteBegin("") 742 | vmap XTermPasteBegin("c") 743 | cmap 744 | cmap 745 | 746 | " # FIXME: add copy-paste for Xorg 747 | 748 | " CTRL-C does copy in visual mode only (can also do xnoremap) 749 | "vnoremap "+y 750 | " CTRL-X does cut in visual mode only 751 | ""vnoremap "+x 752 | " cut not to the default y/p buffer but to wl-copy 753 | "vnoremap :w !wl-copy 754 | " this can't work in range mode as :w doesn't support it 755 | "vnoremap :'<,'> w !wl-copy 756 | " silent version in line mode, without flashing enter 757 | "vnoremap :silent w !wl-copy 758 | " this requires pressing y first 759 | "vnoremap :call system("wl-copy", @") 760 | " so declare a function 761 | function! WLCopy() 762 | " Save the unnamed register and its type. 763 | let last_yank = getreg() 764 | " Copy the selection. 765 | execute "normal! y" 766 | " Send it as-is, without --trim-newline 767 | call system("wl-copy", @") 768 | endfunction 769 | function! WLCut() 770 | " Save the unnamed register and its type. 771 | let last_yank = getreg() 772 | " Copy the selection. 773 | execute "normal! d" 774 | call system("wl-copy", @") 775 | endfunction 776 | 777 | " Make Ctrl-C copy what's currently selected 778 | vnoremap call WLCopy() 779 | " Make Ctrl-X cut what's currently selected (instead of default decrement) 780 | vnoremap call WLCut() 781 | 782 | " CTRL-V does Paste from wl-paste automatically 783 | "nnoremap :r !wl-paste 784 | " so keep that for the console 785 | nnoremap P 786 | 787 | " Separate the terminal copy-paste from vim own 788 | "map "+gP 789 | "cmap + 790 | 791 | " Separate wayland cut-paste from vim: Ctrl-Insert paste and Shift-Delete cut 792 | vnoremap "+y 793 | "vnoremap call WLCut() 794 | vnoremap "+x 795 | 796 | " #### APPEARANCE AND INTERACTION 797 | 798 | " ## MAIN WINDOW LOOKS 799 | 800 | " Redraw the whole screen as needed, helps on android when not displaying 801 | "if match ($LD_PRELOAD, "com.termux") != 0 802 | set ttyfast 803 | "endif 804 | 805 | " No beeps 806 | set noerrorbells 807 | set visualbell 808 | set t_vb= 809 | 810 | " Show line numbers, disable with :se nu! 811 | set number 812 | 813 | " Show relative number for inactive lines 814 | set relativenumber 815 | 816 | " Hilight the current line (and the line numbers) 817 | set cursorline 818 | 819 | " Show matching parenthesis 820 | set showmatch 821 | 822 | " always keep 2 lines of context at the bottom of screen 823 | set scrolloff=2 824 | 825 | " Disable line warping 826 | set nowrapscan 827 | 828 | " Make the text wrap to the next line when it is X letters from the end 829 | "set wrapmargin=8 830 | 831 | " Always limit the width of text 832 | "set tw=72 833 | 834 | " ## EDITION 835 | 836 | " Insert two spaces after a period with every joining of lines 837 | "set joinspaces 838 | 839 | " Do not jump to first character with page commands 840 | set nostartofline 841 | 842 | " Moving left/right ignores the beginning/end of line to continue 843 | set whichwrap=<,>,h,l,[,] 844 | 845 | " Add the dash ('-'), the dot ('.'), and the '@' as "letters" to "words". 846 | set iskeyword=@,48-57,_,192-255,-,.,@-@ 847 | 848 | " Options for the "text format" command ("gq") 849 | " Adding j will remove the comment leader when merging lines 850 | set formatoptions=cqrtoj 851 | 852 | " ## SHOW COMMENTS IN ITALICS 853 | 854 | " If Vim doesn't know the escape codes to switch to italic 855 | let &t_ZH="\e[3m" 856 | let &t_ZR="\e[23m" 857 | " Italics pseudo-auto toggle: force italics if we recognize it's supported from TERM 858 | if match($TERM, "xterm-256color-italic")==0 859 | highlight Comment cterm=italic 860 | " For Windows-Terminal which supports italic, nothing is needed anymore even if not in TERM 861 | "elseif match($TERM, "xterm-256color")==0 862 | " highlight Comment cterm=italic gui=italic 863 | elseif match($TERM, "tmux-sixel")==0 864 | highlight Comment cterm=italic 865 | elseif match($TERM, "mintty")==0 866 | highlight Comment cterm=italic 867 | endif 868 | 869 | " ### AT THE TOP OF THE SCREEN: TABLINE 870 | 871 | " Show on the left the timestamp + encoding, on the right the positions and format 872 | "%{len(getbufinfo({'buflisted': 1}))}:%a 873 | if &columns > 80 874 | set tabline=%{g:gitbranch}%t%a\ %{FileData()}\ \%{&fenc==\"\"?&enc:&fenc}(%{&bomb})\ %{&ff==\"dos\"?\"CRLF\":\"LF\"}%=%{mode()}\ @(x:%03c/%03{virtcol('$')},y:%04l/%0L)\ =0x%02B\ @%08O\ %P 875 | else 876 | " Reduce the tabline width when using a standard screen 877 | set tabline=%{g:gitbranch}%t%a\ %{FileData()}\ \%{&fenc==\"\"?&enc:&fenc}(%{&bomb})\ %{&ff==\"dos\"?\"CRLF\":\"LF\"}%=%{mode()}\ @(x:%03c/%03{virtcol('$')},y:%04l/%0L)\ =0x%02B\ @%O\ %P 878 | endif 879 | " Show the tabline; can hide it with: :set showtabline=0 880 | set showtabline=2 881 | " The tabline need an autocommand to be dynamic 882 | if has("autocmd") 883 | autocmd CursorMoved * :redrawtabline 884 | " redraw it in insert mode too 885 | autocmd CursorMovedI * redrawtabline 886 | endif 887 | 888 | " ## GET INFORMATION ABOUT THE FILE FOR THE TABLINE 889 | " Function to show the file name, creation date and git branch 890 | function! FileData() 891 | " get the epoch 892 | let ftime=getftime(expand("%")) 893 | if ftime>0 894 | if &columns > 80 895 | " Reduce the tabline width when using a standard screen 896 | let msg=strftime("@%Y-%m-%d %H:%M:%S",ftime) 897 | else 898 | let msg=strftime("@%Y%m%d",ftime) 899 | endif 900 | else " if ftime 901 | " epoch<0 means the file doesn't exist, so say it 902 | let msg="(NEW)" 903 | endif " if ftime 904 | return msg 905 | endfunction 906 | 907 | " ## READ THE GIT DATA MANUALLY 908 | " Function to read git data manually directly (not recursive like gitbranch) 909 | " TODO: consider making it recursive? 910 | function! GetGitBranch() 911 | let fpath=expand("%:p:h") 912 | if filereadable(fpath . '/.git/HEAD') 913 | " silent! 914 | let branch = get(readfile(fpath . '/.git/HEAD'), 0, '') 915 | if branch =~# '^ref: ' 916 | let branchname= substitute(branch, '^ref: \%(refs/\%(heads/\|remotes/\|tags/\)\=\)\=', '', '') 917 | elseif branch =~# '^\x\{20\}' 918 | let branchname= branch[:6] 919 | endif " if branch 920 | if (strlen(branchname)>0) 921 | return "⎇ " . branchname . ":" 922 | endif " if strlen 923 | endif " if filereadable 924 | " Default to an empty string instead of the integer 0 925 | return "" 926 | endfunction 927 | 928 | " ## BUT READ THE GIT INFO JUST ONCE WHEN ENTERING THE BUFFER 929 | " Call this function when entering a buffer to set a global variable 930 | if has("autocmd") 931 | autocmd BufEnter * let g:gitbranch=GetGitBranch() 932 | endif 933 | 934 | " ### AT THE BOTTOM OF THE SCREEN: MINIMAL COMMANDLINE (NO STATUSLINE) 935 | 936 | " Statusline with colors and display of options 937 | " at the bottom of the screen? 938 | "set statusline=%{FileData()}\ %{&fenc==\"\"?&enc:&fenc},%{&bomb}\%a%=\ %8l,%c%V/%L\ %{&ff==\"dos\"?\"CRLF\":\"LF\"}\ %P\ %08O:%02B 939 | 940 | " Make command line two lines high 941 | " set ch=2 942 | " Always show status line, even for only one buffer. 943 | "set laststatus=2 944 | " Don't show anything and hide the line too 945 | set laststatus=0 946 | " Don't show the position of the cursor already show in the tabline 947 | set noruler 948 | "set ruler 949 | " Don't show the mode either 950 | set noshowmode 951 | "set showmode 952 | " Don't show the current uncompleted command either 953 | set noshowcmd 954 | "set showcmd 955 | 956 | " Don't use the included file as a source of autocomplete 957 | set complete-=i 958 | " can still use k for 1 or more dictionary files 959 | "set complete+=k 960 | " Manually curated list of plain text words that are considered valid 961 | set dictionary=$HOME."/.vim/words" 962 | " Completed by a hash file: use zg to add a word, zw to remove a word 963 | " Should install aspell, can specify en_US or en_GB instead of en.multi 964 | "set spellfile=/usr/lib/aspell-0.60/en.multi,/usr/lib/aspell-0.60/es.multi 965 | 966 | " Can still use t for tags generated by cscope or exuberant ctags 967 | "set complete+=t 968 | 969 | " Don't suppose numbers starting with 0 are octal: treat them as decimal 970 | " otherwise 07 Ctrl-A (if mapped to increment) because 10 971 | set nrformats-=octal 972 | 973 | " Show commandline completion 974 | set wildmenu 975 | 976 | " Complete longest common string, then each full match like bash 977 | "set wildmode=longest,full 978 | 979 | " Hilight : 8b,db,es,hs,mb,Mn,nu,rs,sr,tb,vr,ws 980 | "set highlight=8r,db,es,hs,mb,Mr,nu,rs,sr,tb,vr,ws 981 | 982 | " Use magic patterns (extended regular expressions) 983 | set magic 984 | 985 | " The char used for "expansion" on the command line 986 | set wildchar= 987 | 988 | " ### LIGHT OR DARK MODE 989 | 990 | " ## CHOSE THE DEFAULT MODE BASED ON $TERM 991 | " Leave the background and style autodetects on 992 | if has('gui_running') 993 | set background=dark 994 | let g:solarized_style="dark" 995 | " set guifont=Menlo\ Regular:h24 996 | set guifont=Monospace\ 13 997 | else 998 | " for solarized, 256 color is better than nothing (ex: xterm-256color) 999 | " and avoids tweaking with the standard colors assignations 1000 | " but worse than replacing the palette + can kill italics/bold/underline 1001 | if match($TERM, "rxvt-unicode-256color")==0 1002 | set background=dark 1003 | " set background=light 1004 | " let g:solarized_style="light" 1005 | " Tweakings are required on Linux, but are better than 256 color fallback 1006 | " let g:solarized_termcolors=256 1007 | let g:solarized_termtrans = 1 1008 | let g:solarized_termcolors=16 1009 | elseif match($TERM, "rxvt-unicode")==0 1010 | " set background=light 1011 | set background=dark 1012 | " let g:solarized_style="light" 1013 | let g:solarized_termcolors=16 1014 | elseif match($TERM, "xterm-256color-italic")==0 1015 | " if used with mintty, need tweaking as the 256 colors fallback looks better 1016 | set background=light 1017 | let g:solarized_style="light" 1018 | let g:solarized_termcolors=256 1019 | " Using 256 colors kills italics without that 1020 | let g:solarized_italic=1 1021 | let g:solarized_bold=1 1022 | let g:solarized_underline=1 1023 | " when showing EOL with :set list 1024 | let g:solarized_visibility="low" 1025 | let g:solarized_hitrail=0 1026 | elseif match($TERM, "xterm-256color")==0 1027 | " This is the new TERM for Windows-Terminal 1028 | " No tweakings required except the 256 color fallback to looks better: 1029 | " it now answers to xterm send sequence attributes (send secondary DA) 1030 | " https://github.com/microsoft/terminal/issues/5836 1031 | " May also extend to vt240 extras with sixel support, cf current status 1032 | " https://terminalnuget.blob.core.windows.net/packages/TerminalSequences.html 1033 | " FIXME: should read current theme 1034 | " ideally from a variable like https://github.com/microsoft/terminal/issues/4566 1035 | " or using Get-WTTheme with PSWinTerminal.psd1 1036 | set background=dark 1037 | let g:solarized_style="dark" 1038 | " set background=dark 1039 | " let g:solarized_style="dark" 1040 | let g:solarized_termcolors=256 1041 | " when showing EOL with :set list 1042 | let g:solarized_visibility="low" 1043 | let g:solarized_hitrail=1 1044 | elseif match($TERM, "xterm")==0 1045 | " This is a wildcard match for xterm* 1046 | set background=dark 1047 | let g:solarized_style="dark" 1048 | let g:solarized_termtrans = 1 1049 | let g:solarized_termcolors=16 1050 | elseif match($TERM, "screen")==0 1051 | " This is for GNU screen 1052 | let g:solarized_termtrans = 1 1053 | let g:solarized_termcolors=16 1054 | set background=dark 1055 | elseif match($TERM, "sixel-tmux")==0 1056 | " This is for sixel-tmux (with sixel derasterize) 1057 | set background=light 1058 | let g:solarized_style="light" 1059 | let g:solarized_termcolors=256 1060 | let g:solarized_italic=1 1061 | let g:solarized_underline=1 1062 | let g:solarized_visibility="low" 1063 | let g:solarized_hitrail=1 1064 | elseif match($TERM, "mintty")==0 1065 | " This is mintty default 1066 | set background=light 1067 | let g:solarized_style="light" 1068 | let g:solarized_termcolors=256 1069 | let g:solarized_bold=1 1070 | let g:solarized_underline=1 1071 | let g:solarized_visibility="low" 1072 | let g:solarized_hitrail=1 1073 | elseif match($TERM, "cygwin")==0 1074 | " This was the old TERM for Windows-Terminal 1075 | set background=dark 1076 | let g:solarized_style="dark" 1077 | let g:solarized_termcolors=16 1078 | let g:solarized_bold=1 1079 | let g:solarized_underline=1 1080 | let g:solarized_visibility="low" 1081 | let g:solarized_hitrail=1 1082 | elseif match($TERM, "foot")==0 1083 | " This is for the foot terminal 1084 | set background=light 1085 | let g:solarized_style="lightdark" 1086 | let g:solarized_termcolors=256 1087 | let g:solarized_bold=1 1088 | let g:solarized_underline=1 1089 | let g:solarized_visibility="low" 1090 | let g:solarized_hitrail=1 1091 | endif " if match $TERM 1092 | endif " if has('guirunning 1093 | 1094 | " ## OVERRIDE THE DEFAULT MODE WITH OTHER ENVIRONMENT VARIABLES 1095 | "if match ($WEZTERM_CONFIG_FILE, "/home/$USER/.config/wezterm/wezterm.lua")==0 1096 | " set background=dark 1097 | " let g:solarized_style="dark" 1098 | " let g:solarized_termcolors=256 1099 | " " when showing EOL with :set list 1100 | " let g:solarized_visibility="low" 1101 | " let g:solarized_hitrail=1 1102 | " set t_ti= 1103 | " set t_te= 1104 | "endif 1105 | " Can override the default color by WT profile UUID 1106 | if match ($WT_PROFILE_ID, "{b9261ded-f302-4538-889e-665aef724946}")==0 1107 | set background=light 1108 | let g:solarized_style="light" 1109 | let g:solarized_termcolors=256 1110 | " when showing EOL with :set list 1111 | let g:solarized_visibility="low" 1112 | let g:solarized_hitrail=1 1113 | set t_ti= 1114 | set t_te= 1115 | endif 1116 | if match ($WT_PROFILE_ID, "{2c4de342-38b7-51cf-b940-2309a097f518}")==0 1117 | set background=dark 1118 | let g:solarized_style="dark" 1119 | let g:solarized_termcolors=256 1120 | " when showing EOL with :set list 1121 | let g:solarized_visibility="low" 1122 | let g:solarized_hitrail=1 1123 | "set t_ti= 1124 | "set t_te= 1125 | endif 1126 | 1127 | " ### COLOR SETTINGS AND FUNCTIONS 1128 | 1129 | if has("terminfo") 1130 | " set t_Co=8 1131 | set t_Sf=[3%p1%dm 1132 | set t_Sb=[4%p1%dm 1133 | else 1134 | " set t_Co=8 1135 | set t_Sf=[3%dm 1136 | set t_Sb=[4%dm 1137 | endif 1138 | 1139 | " Color interacts with set nolist matching below 1140 | if &t_Co > 1 1141 | syntax on 1142 | endif 1143 | 1144 | " ## FUNCTION TO HIGHLIGHT CSV FILES 1145 | 1146 | " Hilight the nths column in csv text, 0=switch off 1147 | function! CSVHighlight(colnr) 1148 | if a:colnr > 1 1149 | let n = a:colnr - 1 1150 | execute 'match Keyword /^\([^,]*,\)\{'.n.'}\zs[^,]*/' 1151 | execute 'normal! 0'.n.'f,' 1152 | elseif a:colnr == 1 1153 | match Keyword /^[^,]*/ 1154 | normal! 0 1155 | else 1156 | match 1157 | endif " if a:colnr 1158 | endfunction 1159 | command! -nargs=1 CsvHighlight :call CSVHighlight() 1160 | 1161 | " ## FUNCTION TO CREATE A 'RAINBOW' INDENT (COLORED ONLY IN LIGHT MODE) 1162 | 1163 | " use 256-colors.sh to pick, here we have shades of black + the usual rainbow 1164 | if !exists("g:rainbow_colors_black") 1165 | let g:rainbow_colors_black= [ 234, 235, 236, 237, 238, 239 ] 1166 | endif 1167 | if !exists("g:rainbow_colors_color") 1168 | let g:rainbow_colors_color= [226, 192, 195, 189, 225, 221] 1169 | endif 1170 | 1171 | " use one of these unless specified otherwise 1172 | function! Rainbow_Enable() abort 1173 | if !exists("w:ms") 1174 | let w:ms=[] 1175 | endif 1176 | let g:rainbow_colors = ( &background == "dark"? g:rainbow_colors_black : g:rainbow_colors_color ) 1177 | if len(w:ms) == 0 1178 | let groups = [] 1179 | for color in g:rainbow_colors 1180 | let group = "colorgroup_".color 1181 | execute "hi ".group." ctermbg=".color 1182 | call add(groups, group) 1183 | endfor 1184 | let level = 0 1185 | let maxlevel = 40 1186 | let tab_pat = "\\zs\t\\ze" 1187 | let tab_seq = "" 1188 | let spc_in_tab = "" 1189 | let spc_left = &tabstop 1190 | while spc_left > 0 1191 | let spc_in_tab = spc_in_tab . " " 1192 | let spc_left = spc_left - 1 1193 | endwhile 1194 | let spc_pat = "\\zs" . spc_in_tab . "\\ze" 1195 | let spc_seq = "" 1196 | while level <= maxlevel 1197 | let gridx = level % len(groups) 1198 | " echom s:grs[gridx] . " ^" . tabseq . pat 1199 | let mtab = matchadd( groups[gridx] , "^" . tab_seq . tab_pat ) 1200 | call add(w:ms, mtab) 1201 | let mspc = matchadd( groups[gridx] , "^" . spc_seq . spc_pat ) 1202 | call add(w:ms, mspc) 1203 | let tab_seq = tab_seq . "\t" 1204 | let spc_seq = spc_seq . spc_in_tab 1205 | let level = level + 1 1206 | endwhile 1207 | endif 1208 | endfunction 1209 | 1210 | function! Rainbow_Disable() abort 1211 | if !exists("w:ms") 1212 | let w:ms=[] 1213 | endif 1214 | if len(w:ms) != 0 1215 | for m in w:ms 1216 | call matchdelete(m) 1217 | endfor 1218 | let w:ms = [] 1219 | endif 1220 | endfunction 1221 | 1222 | function! Rainbow_Toggle() abort 1223 | if !exists("w:ms") 1224 | let w:ms=[] 1225 | endif 1226 | if len(w:ms) == 0 1227 | call Rainbow_Enable() 1228 | else 1229 | call Rainbow_Disable() 1230 | endif 1231 | endfunction 1232 | 1233 | " ## FUNCTIONS TO ALTER THE COLOR SCHEME 1234 | 1235 | " on OLED screens, replace the ugly darkgrey with pitchblack 1236 | function! OLED_Black() 1237 | " override the grey of solarized dark to OLED black with: 1238 | if match (&background, "dark")==0 1239 | hi Normal ctermbg=16 1240 | hi LineNr ctermbg=16 1241 | hi CursorLine ctermbg=16 1242 | hi TabLineFill ctermbg=16 ctermfg=244 1243 | " and use a very visible color for mouse selection 1244 | hi Visual ctermbg=9 1245 | else 1246 | set background=light 1247 | let g:solarized_style="light" 1248 | " let g:solarized_termcolors=256 1249 | " Using 256 colors kills italics without the following: 1250 | let g:solarized_italic=1 1251 | let g:solarized_bold=1 1252 | let g:solarized_underline=1 1253 | " let g:solarized_visibility="high" 1254 | let g:solarized_hitrail=1 1255 | endif " if match (&background 1256 | endfunction 1257 | 1258 | " Start with the rainbow and OLED black 1259 | if has("autocmd") 1260 | autocmd ColorScheme * call OLED_Black() 1261 | autocmd ColorScheme * call Rainbow_Enable() 1262 | endif 1263 | 1264 | " ## FUNCTIONS TO HILIGHTS CHARACTERS 1265 | 1266 | " Show space errors and hilight invisible characters 1267 | function! Hilight_HiddenChars_Syntax() 1268 | " supports: ada, c, chill, csc, forth, groovy, icon, java, lpc, mel, nqc, nroff, ora, pascal, plm, plsql, python and ruby 1269 | let c_space_errors = 1 1270 | let python_space_errors = 1 1271 | 1272 | " WARNING: SpecialKey highlighting overrules syntax highlighting 1273 | " So if not using syntax, can better show hidden characters using different colors: 1274 | " this is a tab a space a tab then h: h 1275 | " this is a tab a space a tab: 1276 | " this is a tab: 1277 | " this is a trailing space: 1278 | " this is a control-F:  1279 | " this is a control-F then space an control-M:  1280 | 1281 | syn match TabChar /\t/ containedin=ALL 1282 | syn match TrailingSpaceChar " *$" containedin=ALL 1283 | syn match NonBreakingSpaceChar "\%u00a0" containedin=ALL 1284 | syn match ExtraWhitespace / \+\ze\t/ containedin=ALL 1285 | " syn match NonPrintableASCII /[^\x00-\x7F]/ containedin=ALL 1286 | syn match NonPrintableASCII /[\x0C\x0E-\x1F\x7F-\x9F]/ containedin=ALL 1287 | syn match ControlChars /[\x00-\x08]/ containedin=ALL 1288 | syn match ControlChars /[\x00-\x08]/ containedin=ALL 1289 | endfunction 1290 | 1291 | function! Hilight_HiddenChars_Color() 1292 | if match(&background,"light") ==0 1293 | highlight TabChar ctermbg=grey guibg=grey 1294 | highlight TrailingSpaceChar ctermbg=grey guibg=grey 1295 | else 1296 | highlight TabChar ctermbg=8 guibg=grey 1297 | highlight TrailingSpaceChar ctermbg=8 guibg=grey 1298 | endif 1299 | highlight NonBreakingSpaceChar ctermbg=red guibg=red 1300 | highlight ExtraWhitespace ctermbg=red guibg=red 1301 | highlight NonPrintableASCII ctermbg=red guibg=red 1302 | highlight ControlChars ctermbg=blue guibg=blue 1303 | highlight ControlChars ctermbg=blue guibg=blue 1304 | endfunction 1305 | 1306 | " Automatically call these functions with autocmd 1307 | " (when toggling syntax with `:syntax off` or changing colors with :colorscheme) 1308 | if has("autocmd") 1309 | autocmd Syntax * call Hilight_HiddenChars_Syntax() 1310 | autocmd ColorScheme * call Hilight_HiddenChars_Color() 1311 | endif 1312 | 1313 | " Avoid performance issue due to memory leaks as BufWinEnter commands are executed every time a buffer is displayed 1314 | " ie whenever loading files 1315 | if version >= 702 1316 | autocmd BufWinLeave * call clearmatches() 1317 | endif 1318 | 1319 | " ## F8 SHORTCUT TO TOGGLE LISTCHARS 1320 | 1321 | " Default is off, `se list` to turn on and `se nolist` to turn off 1322 | " Traditional: 1323 | "set listchars=tab:»·space:_,trail:·,eol:¶ 1324 | " Or cute with unicodes: 1325 | set listchars=tab:↹⇥,space:_,nbsp:␣,trail:•,extends:⟩,precedes:⟨,eol:↲ 1326 | set showbreak=↪ 1327 | inoremap :set list! 1328 | noremap :set list! 1329 | 1330 | " ## F9 SHORTCUT TO TOGGLE COLOR SCHEME 1331 | 1332 | " Apply one of the packed default colorschemes at startup 1333 | "colorscheme slate 1334 | "colorscheme desert 1335 | "colorscheme wildcharm 1336 | "colorscheme habamax 1337 | " Or use the packed solarized color scheme 1338 | colorscheme solarized 1339 | 1340 | function! Cycle_Colorscheme() 1341 | if (strlen(g:colors_name)>0) 1342 | if g:colors_name== "habamax" 1343 | " set background=light 1344 | " let g:solarized_style="light" 1345 | set background=dark 1346 | let g:solarized_style="dark" 1347 | " let g:solarized_termcolors=256 1348 | " Using 256 colors kills italics without the following: 1349 | let g:solarized_italic=1 1350 | let g:solarized_bold=1 1351 | let g:solarized_underline=1 1352 | " let g:solarized_visibility="high" 1353 | " let g:solarized_visibility="low" 1354 | " let g:solarized_hitrail=1 1355 | colorscheme solarized 1356 | elseif g:colors_name== "solarized" 1357 | set background=light 1358 | colorscheme quiet 1359 | syntax on 1360 | call Hilight_HiddenChars_Syntax() 1361 | call Hilight_HiddenChars_Color() 1362 | " elseif g:colors_name== "solarized" 1363 | else 1364 | set background=dark 1365 | colorscheme habamax 1366 | syntax on 1367 | call Hilight_HiddenChars_Syntax() 1368 | call Hilight_HiddenChars_Color() 1369 | endif " if g:colors_name 1370 | endif " if strlen 1371 | endfunction 1372 | 1373 | " Hotkey to cycle through themes 1374 | inoremap :call Cycle_Colorscheme() 1375 | noremap :call Cycle_Colorscheme() 1376 | 1377 | " ## F10 SHORTCUT TO TOGGLE RAINBOW INDENT 1378 | inoremap :call Rainbow_Toggle() 1379 | noremap :call Rainbow_Toggle() 1380 | 1381 | " #### INSERT MODE SHORTCUTS 1382 | 1383 | " ### ABBREVIATIONS AS Y 1384 | 1385 | " Yruler : A "ruler" - nice for counting the length of words 1386 | iab Yruler 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 1387 | 1388 | " Date 1389 | iab Ydate =strftime("%Y-%m-%d %H:%M") 1390 | 1391 | " ### FUNCTIONS AS , 1392 | 1393 | " ,cel = "clear empty lines", but don't delete the lines 1394 | " delete the *contents* of all lines which contain only whitespace. 1395 | map ,cel :%s/^\s\+$// 1396 | 1397 | " ,del = "delete 'empty' lines", don't don't delete empty lines 1398 | " delete all lines which contain only whitespace 1399 | map ,del :g/^\s\+$/d 1400 | 1401 | " ,ksr = "kill space runs" to substitute >2 spaces by just 1 space 1402 | nmap ,ksr :%s/ \+/ /g 1403 | vmap ,ksr :s/ \+/ /g 1404 | 1405 | " ,Sel = "squeeze empty lines" to merge multiple purely empty lines in just 1 1406 | map ,Sel :g/^$/,/./-j 1407 | 1408 | " ,Sbl = "squeeze blank lines" to merge empty lines (with spaces) into just 1 1409 | map ,Sbl :g/^\s*$/,/\S/-j 1410 | 1411 | 1412 | " ## DEFAULTS BY FILETYPE 1413 | 1414 | if has("autocmd") 1415 | augroup python 1416 | au! 1417 | autocmd BufNewFile,BufReadPre,FileReadPre *.py set tabstop=4 1418 | autocmd BufNewFile,BufReadPre,FileReadPre *.py set softtabstop=4 1419 | autocmd BufNewFile,BufReadPre,FileReadPre *.py set shiftwidth=4 1420 | autocmd BufNewFile,BufReadPre,FileReadPre *.py set expandtab 1421 | autocmd BufNewFile,BufReadPre,FileReadPre *.py set autoindent 1422 | autocmd BufNewFile,BufReadPre,FileReadPre *.py set autoindent 1423 | autocmd BufNewFile,BufReadPre,FileReadPre *.py set fileformat=unix 1424 | " Not doing set textwidth=79 1425 | " autocmd WinEnter,VimEnter *.py :call rainbow#enable() 1426 | augroup END 1427 | 1428 | augroup gzip 1429 | au! 1430 | autocmd BufReadPre,FileReadPre *.gz set bin 1431 | autocmd BufReadPost,FileReadPost *.gz '[,']!gunzip 1432 | autocmd BufReadPost,FileReadPost *.gz set nobin 1433 | autocmd BufReadPost,FileReadPost *.gz execute ":doautocmd BufReadPost " . expand("%:r") 1434 | " autocmd BufWritePost,FileWritePost *.gz !mv :r 1435 | " autocmd BufWritePost,FileWritePost *.gz !gzip :r 1436 | autocmd FileAppendPre *.gz !gunzip 1437 | autocmd FileAppendPre *.gz !mv :r 1438 | autocmd FileAppendPost *.gz !mv :r 1439 | autocmd FileAppendPost *.gz !gzip :r 1440 | augroup END 1441 | 1442 | augroup bzip 1443 | au! 1444 | autocmd BufReadPre,FileReadPre *.bz2 set bin 1445 | autocmd BufReadPost,FileReadPost *.bz2 '[,']!bunzip2 1446 | autocmd BufReadPost,FileReadPost *.bz2 set nobin 1447 | autocmd BufReadPost,FileReadPost *.bz2 execute ":doautocmd BufReadPost " . expand("%:r") 1448 | autocmd BufWritePost,FileWritePost *.bz2 !mv :r 1449 | autocmd BufWritePost,FileWritePost *.bz2 !bzip2 :r 1450 | autocmd FileAppendPre *.bz2 !bunzip2 1451 | autocmd FileAppendPre *.bz2 !mv :r 1452 | autocmd FileAppendPost *.bz2 !mv :r 1453 | autocmd FileAppendPost *.bz2 !bzip2 :r 1454 | augroup END 1455 | 1456 | augroup html 1457 | " autocmd BufWritePost *.html :!firefox -remote "reload()" 1458 | autocmd BufEnter *.html :noremap :!firefox -remote "openURL(file:%)"^M^M 1459 | autocmd BufEnter *.html :inoremap ^[^[:!firefox -remote "openURL(file:%)"^M^Ma 1460 | " autocmd BufWritePost *.css :!firefox -remote "reload()" 1461 | autocmd BufEnter *.css :noremap :!firefox -remote "reload()"^M^M 1462 | autocmd BufEnter *.css :inoremap ^[^[:!firefox -remote "reload()"^M^Ma 1463 | 1464 | augroup END 1465 | 1466 | augroup cprog 1467 | au! 1468 | " autocmd BufRead * set formatoptions=tcql nocindent comments& 1469 | autocmd BufRead *.c,*.h set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,:// 1470 | augroup END 1471 | 1472 | endif " has("autocmd") 1473 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CuteVim in pictures 2 | 3 | There's both a light and dark mode: 4 | ![screenshot of vim in dark mode inside wezterm over vim in light mode inside foot](screenshots/cute-vim.png) 5 | 6 | You can move the current line by holding the Alt key, and quickly change the appearance with the F8/F9/F10 keys: 7 | ![recording of vim in light mode using alt arrows to move the current line, then f8 f9 f10 to change the appearance](recordings/alt-keys-f8-f9-10.gif) 8 | 9 | You can also move blocks of text by selecting a range (first hold the Shift key then use the arrows) which can then be moved around by holding both Control and Shift and using the arrow keys: 10 | ![recording of vim in light mode using ctrl shift arrows to move a block of text](recordings/shift-arrows_then_ctrl-shift.gif) 11 | 12 | # TLDR; love the pics, love the concept, I want to test it, how can I quickly do that? 13 | 14 | Just ![download the Christmas release](https://raw.githubusercontent.com/csdvrx/CuteVim/main/release/cutevim-20231225.com) rename it vim.com and run it: 15 | 16 | - `wget https://raw.githubusercontent.com/csdvrx/CuteVim/main/release/cutevim-20231229.com` 17 | 18 | - `cp cutevim-20231229.com vim.com` 19 | 20 | - `chmod +x ./vim.com` 21 | 22 | - `./vim.com -u /zip/usr/share/vim/vimrc` 23 | 24 | The last line is important: without it, if you already have a .vimrc, it would be read. 25 | 26 | # What is CuteVim? 27 | 28 | CuteVim is a minimal configuration file (TODO: it's not all included in .vimrc yet) to give sensible defaults to Vim, like: 29 | 30 | - a tabline on top, showing the filename and ISO timestamp, the encoding (with the unicode byte-order-mark if applicable), the position in a (x=column, y=row) space with the hexadecimal value of the character you see and the position within the file in box hexadecimal and percentage 31 | 32 | - a line counter on the left, with both the current line number (hilighted and underlined to quickly see it) and the relative line numbers (dimmer) to type vim commands that apply to a length in lines (like `:d5` to delete the next 5 lines) 33 | 34 | - saving backups of files in ~/.vim/backup every time you save, and keeping an undo-per file 35 | 36 | - restoring the cursor position to where you last edited the file 37 | 38 | - selecting lines with the shift keys and the arrows 39 | 40 | - moving lines, blocks of lines or words with Alt and the arrows, and text or blocks of text with Ctrl-Shift and the arrows 41 | 42 | - having separate functions for Control keys and their results, for example to separate Tab (which indent the current line) and Ctrl-I (which jumps the cursor position following the edit history, best used with Ctrl-O) thanks to [xterm 'modifyotherkeys' (MOK)](https://invisible-island.net/xterm/modified-keys.html) 43 | 44 | - showing otherwise invisible characters (like tabs and control codes, or spaces on empty lines) using colors to avoid breaking copy-paste 45 | 46 | - playing ball with Wayland by having one shared copy-paste buffer 47 | 48 | - overriding dark themes to replace the uggly muddy darkgreys by a pure #000000 black: this is ideal on OLED screens which can do pitchblack and give you a higher contrast 49 | 50 | # Are these defaults really sensible? 51 | 52 | If you don't like readline or Windows shortcuts, some of my choices may be questionable. 53 | 54 | Fortunately, the .vimrc should be easy to understand thanks to all the comments, and you should be able to adjust it to match your preferences. 55 | 56 | PS: If you don't have an OLED screen, don't comment out `autocmd ColorScheme * call OLED_Black()` around line 1162. Instead, go buy an OLED screen! It's really worth it!! 57 | 58 | # How can I quickly change the apperance? 59 | 60 | Press F8 to show hidden characters, F9 to cycle through the themes, F10 to toggle the rainbow indent 61 | 62 | The .vimrc is made to recognize which terminal you are using, and start in either a light or dark profile: I use both foot (light) and wezterm (dark). 63 | 64 | If you use Windows Terminal, you can also configure UUIDs to recognize the profile 65 | 66 | # Why are the Control keys mapped to emacs-like readline commands? 67 | 68 | Because I feel bad when Ctrl-A doesn't get me to the beginning of the line, and Ctrl-E to the End. 69 | 70 | I like it better when Ctrl-K also cuts from the cursor to the end of the line, and Ctrl-U to the beginning. 71 | 72 | I'm fully happy when all the Ctrl keys "work as they should", like: 73 | 74 | - if Control-Arrows can jump around words and lines, 75 | 76 | - while both Ctrl-W and Ctrl-Backspace removes the previous word, 77 | 78 | - and both Ctrl-S and Ctrl-Delete remove the next word 79 | 80 | I often have different shortcuts to do the same thing because I'm whimsical and I like to use one or the other depending on the mood :) 81 | 82 | # Why can't I do copy-paste in Xorg? 83 | 84 | I use Wayland (to be precise, [the best composer of all for a keyboard centric workflow: hyprland](https://github.com/hyprwm/Hyprland)) so Xorg is not well tested. 85 | 86 | I will try add other functions for Xorg if the defaults don't work. 87 | 88 | # Why make CuteVim? 89 | 90 | I wanted to have a cute editor for [☪ ☮$m✡✝🍏linux](http://github.com/csdvrx/cosmopolinux) without having to carry too many files around, because I sometimes forget to take them in a tarball or a zip file. 91 | 92 | So CuteVim configuration mostly fit within .vimrc, the one file I will not forget to take! 93 | 94 | It's also much easier to make a release: it only takes `./zip -r vim.com usr/share/vim/vimrc` to refresh it. 95 | 96 | # How can I make my own CuteVim APE? 97 | 98 | Use `refresh.sh` which does the following: 99 | 100 | ## Get clean binaries 101 | 102 | rm -f vim.com zip.com unzip.com 103 | wget https://cosmo.zip/pub/cosmos/bin/vim -O vim.com 104 | wget https://cosmo.zip/pub/cosmos/bin/zip -O zip.com 105 | wget https://cosmo.zip/pub/cosmos/bin/unzip -O unzip.com 106 | 107 | ## Add vimrc in the right place 108 | 109 | ./zip -r vim.com usr/share/vim/vimrc 110 | 111 | ## How do we know it's the right place? 112 | 113 | First, check what's the default path for this version 114 | 115 | ./vim.com --version | grep usr/share 116 | 117 | You'll see `fall-back for $VIM: "/zip/usr/share/vim"` 118 | 119 | Now, check with `--strace` what's happening: 120 | 121 | vim.com --strace 2> vim.strace.txt 122 | # (then type :q!) 123 | 124 | Use grep on the strace file to skip to the important parts: 125 | 126 | grep zip.usr.share.vim vim.strace.txt |grep defaults.vim | less 127 | 128 | grep zip.usr.share.vim vim.vanilla.strace.txt |grep vimrc 129 | 130 | You'll see: 131 | 132 | grep zip.usr.share.vim vim.vanilla.strace.txt |grep vimrc 133 | 134 | SYS 1646170 1646170 12'999'983 fstatat(AT_FDCWD, "/zip/usr/share/vim/vim90/defaults.vim", [{.st_size=4'952, .st_blocks=2'560/512, .st_mode=0100644, .st_dev=0x172120, .st_ino=0x1097916, .st_blksize=65'536}], 0) → 0 ENOTSUP 135 | SYS 1646170 1646170 13'032'512 openat(AT_FDCWD, "/zip/usr/share/vim/vim90/defaults.vim", O_RDONLY) → 3 ENOTSUP 136 | 137 | And earlier than this: 138 | 139 | SYS 1646170 1646170 12'917'060 fstatat(AT_FDCWD, "/zip/usr/share/vim/vimrc", [n/a], 0) → -1 ENOENT 140 | SYS 1646170 1646170 12'920'202 openat(AT_FDCWD, "/zip/usr/share/vim/vimrc", O_RDONLY) → -1 ENOENT 141 | 142 | This is why we do `./zip -r vim.com usr/share/vim/vimrc`, to embed a vimrc from `./usr/share/vim/vimrc` inside the zip part of the APE, which maps to the path `/zip/usr/share/vim/vimrc` 143 | 144 | Running vim.com again with strace, the file is seen: 145 | 146 | SYS 1650340 1650340 114'662'106 fstatat(AT_FDCWD, "/zip/usr/share/vim/vimrc", [{.st_size=42'484, .st_blocks=14'848/512, .st_mode=0100644, .st_dev=0x7c98aa, .st_ino=0x10b712f, .st_blksize=65'536}], 0) → 0 ENOTSUP 147 | 148 | 42484 is the size, ENOTSUP is just because of O_RDONLY 149 | 150 | # Italics are missing, and the APE is not using Solarized 151 | 152 | This means you are using the old version (Xmas release, 2023-12-25) which didn't include ./usr/share/vim/vimfiles/after and ./usr/share/vim/vimfiles/colors, and only included the .vimrc 153 | 154 | CuteVim depends on after/syntax/ for italics within .vim files, and colors/ for the [default Solarized theme](https://en.wikipedia.org/wiki/Solarized) 155 | 156 | Instead of fitting everything inside a single .vimrc, the `refresh.sh` now includes a few extra assets from usr/share/vim/vimfiles: 157 | 158 | - usr/share/vim/vimfiles/colors/solarized8_low.vim 159 | 160 | - usr/share/vim/vimfiles/colors/solarized8_high.vim 161 | 162 | - usr/share/vim/vimfiles/colors/solarized8.vim 163 | 164 | - usr/share/vim/vimfiles/colors/solarized.vim 165 | 166 | - usr/share/vim/vimfiles/colors/solarized8_flat.vim 167 | 168 | - usr/share/vim/vimfiles/after/syntax/python.vim 169 | 170 | - usr/share/vim/vimfiles/after/syntax/vim.vim 171 | 172 | This unifies the APE and the non-APE experience 173 | 174 | # On Windows, do I need WSL to use CuteVim? 175 | 176 | No you don't. CuteVim will work with or without WSL: just double-click on cutevim binary to start it. 177 | 178 | Note that drag-and-drop to files into the window is not supported yet (TODO: open a new tab withim Vim), so if you use Vim a lot, it may be easier to have CuteVim as a keyboard shortcut. 179 | 180 | # How can I add a direct access to CuteVim as a Windows Terminal profile? 181 | 182 | Copy cutevim-20231229.com to C:\ using the File Explorer: you will need administrative permissions. If you don't have them, use another folder like `%UserProfile%` which usually goes to your folder in C:\Users\ (personally, I prefer to have basic utilities in the root of the C: drive) 183 | 184 | Open Windows Terminal settings in the drowndown, or use the default shortcut (press Ctrl+,) 185 | 186 | Inside the settings, select Profiles on the left, go to "+ Add a new profile" 187 | 188 | Click on "Duplicate" to duplicate the Windows Powershell profile 189 | 190 | Click on "Name" to rename it to "Cute Vim" 191 | 192 | Click on "Command line" to replace it by "%SystemDrive%\cutevim-20231229.com" 193 | 194 | ![Filling in CuteVim details](screenshots/Windows-Terminal-Duplicate.png) 195 | 196 | The end results should look like the following 197 | ![CuteVim profile ](screenshots/Windows-Terminal-New-Profile.png) 198 | 199 | Click on "Save": you can now call CuteVim directly from the dropdown with a shortcut: Ctrl+Shift+6 200 | 201 | ![Example of the new profile](screenshots/Windows-Terminal-Result.png) 202 | 203 | If you prefer the light theme, type `set background=light` or edit `./usr/share/vim/vimrc` then refresh the assets with `./refresh.sh` 204 | 205 | Note that some shortcuts are not supported yet: 206 | 207 | - the appearance shortcuts F8/F9/F10 (F8 generates ^[[19~, F9 generates ^[[20~, F10 generates ^[[21~) 208 | 209 | - the Alt, Shift and Control selections (Windows Terminal remaps Ctrl-Shift-Up to the buffer scroll) 210 | 211 | Contributions are welcome, ideally as patches to the vimrc: this is to avoid changing Windows Terminal defaults unless it's absolutely required (such as to override defaults like the Ctrl-Shift-Up) 212 | 213 | # TODO 214 | 215 | Coming next, in no specific order: 216 | 217 | - make the function looking for .git/HEAD recursive 218 | 219 | - improve Windows Terminal support 220 | 221 | - suggest some sensible Windows Terminal config options as a .json patch 222 | -------------------------------------------------------------------------------- /recordings/alt-keys-f8-f9-10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csdvrx/CuteVim/5c7cc799e7ae5e24ca858a96b1b67d13fa50c65c/recordings/alt-keys-f8-f9-10.gif -------------------------------------------------------------------------------- /recordings/alt-keys-f8-f9-10.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csdvrx/CuteVim/5c7cc799e7ae5e24ca858a96b1b67d13fa50c65c/recordings/alt-keys-f8-f9-10.mp4 -------------------------------------------------------------------------------- /recordings/shift-arrows_then_ctrl-shift.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csdvrx/CuteVim/5c7cc799e7ae5e24ca858a96b1b67d13fa50c65c/recordings/shift-arrows_then_ctrl-shift.gif -------------------------------------------------------------------------------- /recordings/shift-arrows_then_ctrl-shift.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csdvrx/CuteVim/5c7cc799e7ae5e24ca858a96b1b67d13fa50c65c/recordings/shift-arrows_then_ctrl-shift.mp4 -------------------------------------------------------------------------------- /refresh.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/sh 2 | 3 | # clean up 4 | rm -f vim.com 5 | # start from a clean vim ape name vim.com like with: 6 | wget https://cosmo.zip/pub/cosmos/bin/vim -O vim.com 7 | wget https://cosmo.zip/pub/cosmos/bin/zip -O zip.com 8 | wget https://cosmo.zip/pub/cosmos/bin/unzip -O unzip.com 9 | # make it executable 10 | chmod +x vim.com 11 | # .com is needed otherwise zip -r will create a vim.zip 12 | 13 | # check the defaults 14 | ./vim.com --version | grep usr/share 15 | # fall-back for $VIM: "/zip/usr/share/vim" 16 | 17 | # Therefore add the vimrc in usr/share/vim 18 | mkdir -o ./usr/share/vim 19 | cp .vimrc ./usr/share/vim/vimrc 20 | ./zip -r vim.com usr/share/vim/vimrc 21 | 22 | # Check 23 | ./unzip -l vim.com |grep usr/share/vim/vimrc 24 | 25 | # To explain the above, use strace to check: 26 | #vim.com --strace 2> vim.strace.txt 27 | #grep zip.usr.share.vim vim.strace.txt |grep defaults.vim | less 28 | #SYS 1646170 1646170 12'999'983 fstatat(AT_FDCWD, "/zip/usr/share/vim/vim90/defaults.vim", [{.st_size=4'952, .st_blocks=2'560/512, .st_mode=0100644, .st_dev=0x172120, .st_ino=0x1097916, .st_blksize=65'536}], 0) → 0 ENOTSUP 29 | #SYS 1646170 1646170 13'032'512 openat(AT_FDCWD, "/zip/usr/share/vim/vim90/defaults.vim", O_RDONLY) → 3 ENOTSUP 30 | # Earlier: 31 | #grep zip.usr.share.vim vim.vanilla.strace.txt |grep vimrc 32 | #SYS 1646170 1646170 12'917'060 fstatat(AT_FDCWD, "/zip/usr/share/vim/vimrc", [n/a], 0) → -1 ENOENT 33 | #SYS 1646170 1646170 12'920'202 openat(AT_FDCWD, "/zip/usr/share/vim/vimrc", O_RDONLY) → -1 ENOENT 34 | # Therefore: 35 | # ./zip -r vim.com usr/share/vim/vimrc 36 | # Running it again, it's seen: 37 | #SYS 1650340 1650340 114'662'106 fstatat(AT_FDCWD, "/zip/usr/share/vim/vimrc", [{.st_size=42'484, .st_blocks=14'848/512, .st_mode=0100644, .st_dev=0x7c98aa, .st_ino=0x10b712f, .st_blksize=65'536}], 0) → 0 ENOTSUP 38 | # 42484 is the filesize, ENOTSUP is because of O_RDONLY 39 | 40 | ## Prepare other assets: 41 | # italics for comments (python, vimrc) 42 | cp .vim/after/syntax/python.vim usr/share/vim/vimfiles/after/syntax 43 | cp .vim/after/syntax/vim.vim usr/share/vim/vimfiles/after/syntax 44 | # solarized theme 45 | cp .vim/colors/solarized.vim usr/share/vim/vimfiles/colors/ 46 | cp .vim/colors/solarized8.vim usr/share/vim/vimfiles/colors/ 47 | cp .vim/colors/solarized8_flat.vim usr/share/vim/vimfiles/colors/ 48 | cp .vim/colors/solarized8_high.vim usr/share/vim/vimfiles/colors/ 49 | cp .vim/colors/solarized8_low.vim usr/share/vim/vimfiles/colors/ 50 | 51 | # then add them too 52 | ./zip -r vim.com usr/share/vim/vimfiles 53 | -------------------------------------------------------------------------------- /release/cutevim-20231225.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csdvrx/CuteVim/5c7cc799e7ae5e24ca858a96b1b67d13fa50c65c/release/cutevim-20231225.com -------------------------------------------------------------------------------- /release/cutevim-20231229.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csdvrx/CuteVim/5c7cc799e7ae5e24ca858a96b1b67d13fa50c65c/release/cutevim-20231229.com -------------------------------------------------------------------------------- /screenshots/Windows-Terminal-Duplicate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csdvrx/CuteVim/5c7cc799e7ae5e24ca858a96b1b67d13fa50c65c/screenshots/Windows-Terminal-Duplicate.png -------------------------------------------------------------------------------- /screenshots/Windows-Terminal-New-Profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csdvrx/CuteVim/5c7cc799e7ae5e24ca858a96b1b67d13fa50c65c/screenshots/Windows-Terminal-New-Profile.png -------------------------------------------------------------------------------- /screenshots/Windows-Terminal-Result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csdvrx/CuteVim/5c7cc799e7ae5e24ca858a96b1b67d13fa50c65c/screenshots/Windows-Terminal-Result.png -------------------------------------------------------------------------------- /screenshots/cute-vim.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csdvrx/CuteVim/5c7cc799e7ae5e24ca858a96b1b67d13fa50c65c/screenshots/cute-vim.png -------------------------------------------------------------------------------- /usr/share/vim/vimfiles/after/syntax/python.vim: -------------------------------------------------------------------------------- 1 | " a valid comment in italics 2 | "" another valid comment 3 | " also a valid comment 4 | syn match Comment '^\s*\#\s\+.*$' 5 | hi Comment term=NONE,italic cterm=NONE,italic gui=NONE,italic 6 | 7 | "# a valid comment adding bold to italics for emphasis 8 | "" ## another valid comment with emphasis 9 | "" ###### also a valid comment with emphasis 10 | syn match BoldComment '^\s*##\+.*$' 11 | hi BoldComment term=bold,italic cterm=bold,italic gui=bold,italic 12 | 13 | "_ for comment titles with underline added for emphasis 14 | ""_ another comment title with emphasis 15 | "" __ also a valid comment title with emphasis 16 | syn match UnderlineComment '^\s*\#\s*_.*$' 17 | hi UnderlineComment term=NONE,italic,underline cterm=NONE,italic,underline gui=NONE,italic,underline 18 | 19 | "#_ a valid comment adding bold + underline to italics for titles 20 | "" ## __ another valid comment title 21 | "" __ ## another valid comment title 22 | syn match BoldUnderlineComment '^\s*##\+\s*_\+.*$' 23 | hi BoldUnderlineComment term=bold,italic,underline cterm=bold,italic,underline gui=bold,italic,underline 24 | -------------------------------------------------------------------------------- /usr/share/vim/vimfiles/after/syntax/vim.vim: -------------------------------------------------------------------------------- 1 | " a valid comment in italics 2 | "" another valid comment 3 | " also a valid comment 4 | syn match Comment '^\s*".*$' 5 | hi Comment term=NONE,italic cterm=NONE,italic gui=NONE,italic 6 | 7 | "# a valid comment adding bold to italics for emphasis 8 | "" ## another valid comment with emphasis 9 | "" ###### also a valid comment with emphasis 10 | syn match BoldComment '^\s*"\+\s*\#.*$' 11 | hi BoldComment term=bold,italic cterm=bold,italic gui=bold,italic 12 | 13 | "# not a valid comment if the double quote is removed so use bold and red instead of italics 14 | syn match InvalidComment '^#.*$' 15 | hi InvalidComment term=bold cterm=bold gui=bold ctermfg=red guifg=red 16 | 17 | "_ for comment titles with underline added for emphasis 18 | ""_ another comment title with emphasis 19 | "" __ also a valid comment title with emphasis 20 | syn match UnderlineComment '^\s*"\+\s*_.*$' 21 | hi UnderlineComment term=NONE,italic,underline cterm=NONE,italic,underline gui=NONE,italic,underline 22 | 23 | "#_ a valid comment adding bold + underline to italics for titles 24 | "" ## __ another valid comment title 25 | "" __ ## another valid comment title 26 | syn match BoldUnderlineComment '^\s*"\+\s*\#\+\s*_\+.*$' 27 | syn match UnderlineBoldComment '^\s*"\+\s*_\+\s*\#\+.*$' 28 | hi link BoldUnderlineComment UnderlineBoldComment 29 | hi UnderlineBoldComment term=bold,italic,underline cterm=bold,italic,underline gui=bold,italic,underline 30 | -------------------------------------------------------------------------------- /usr/share/vim/vimfiles/colors/solarized.vim: -------------------------------------------------------------------------------- 1 | " Name: Solarized vim colorscheme 2 | " Author: Ethan Schoonover 3 | " URL: http://ethanschoonover.com/solarized 4 | " (see this url for latest release & screenshots) 5 | " License: OSI approved MIT license (see end of this file) 6 | " Created: In the middle of the night 7 | " Modified: 2011 Apr 14 8 | " 9 | " Usage "{{{ 10 | " 11 | " --------------------------------------------------------------------- 12 | " ABOUT: 13 | " --------------------------------------------------------------------- 14 | " Solarized is a carefully designed selective contrast colorscheme with dual 15 | " light and dark modes that runs in both GUI, 256 and 16 color modes. 16 | " 17 | " See the homepage above for screenshots and details. 18 | " 19 | " --------------------------------------------------------------------- 20 | " INSTALLATION: 21 | " --------------------------------------------------------------------- 22 | " 23 | " Two options for installation: manual or pathogen 24 | " 25 | " MANUAL INSTALLATION OPTION: 26 | " --------------------------------------------------------------------- 27 | " 28 | " 1. Put the files in the right place! 29 | " 2. Move `solarized.vim` to your `.vim/colors` directory. 30 | " 31 | " RECOMMENDED PATHOGEN INSTALLATION OPTION: 32 | " --------------------------------------------------------------------- 33 | " 34 | " 1. Download and install Tim Pope's Pathogen from: 35 | " https://github.com/tpope/vim-pathogen 36 | " 37 | " 2. Next, move or clone the `vim-colors-solarized` directory so that it is 38 | " a subdirectory of the `.vim/bundle` directory. 39 | " 40 | " a. **clone with git:** 41 | " 42 | " $ cd ~/.vim/bundle 43 | " $ git clone git://github.com/altercation/vim-colors-solarized.git 44 | " 45 | " b. **or move manually into the pathogen bundle directory:** 46 | " In the parent directory of vim-colors-solarized: 47 | " 48 | " $ mv vim-colors-solarized ~/.vim/bundle/ 49 | " 50 | " MODIFY VIMRC: 51 | " 52 | " After either Option 1 or Option 2 above, put the following two lines in your 53 | " .vimrc: 54 | " 55 | " syntax enable 56 | " set background=dark 57 | " colorscheme solarized 58 | " 59 | " or, for the light background mode of Solarized: 60 | " 61 | " syntax enable 62 | " set background=light 63 | " colorscheme solarized 64 | " 65 | " I like to have a different background in GUI and terminal modes, so I can use 66 | " the following if-then. However, I find vim's background autodetection to be 67 | " pretty good and, at least with MacVim, I can leave this background value 68 | " assignment out entirely and get the same results. 69 | " 70 | " if has('gui_running') 71 | " set background=light 72 | " else 73 | " set background=dark 74 | " endif 75 | " 76 | " See the Solarized homepage at http://ethanschoonover.com/solarized for 77 | " screenshots which will help you select either the light or dark background. 78 | " 79 | " Other options are detailed below. 80 | " 81 | " IMPORTANT NOTE FOR TERMINAL USERS: 82 | " 83 | " If you are going to use Solarized in Terminal mode (i.e. not in a GUI version 84 | " like gvim or macvim), **please please please** consider setting your terminal 85 | " emulator's colorscheme to used the Solarized palette. I've included palettes 86 | " for some popular terminal emulator as well as Xdefaults in the official 87 | " Solarized download available from [Solarized homepage]. If you use 88 | " Solarized *without* these colors, Solarized will need to be told to degrade 89 | " its colorscheme to a set compatible with the limited 256 terminal palette 90 | " (whereas by using the terminal's 16 ansi color values, you can set the 91 | " correct, specific values for the Solarized palette). 92 | " 93 | " If you do use the custom terminal colors, solarized.vim should work out of 94 | " the box for you. If you are using a terminal emulator that supports 256 95 | " colors and don't want to use the custom Solarized terminal colors, you will 96 | " need to use the degraded 256 colorscheme. To do so, simply add the following 97 | " line *before* the `colorschem solarized` line: 98 | " 99 | " let g:solarized_termcolors=256 100 | " 101 | " Again, I recommend just changing your terminal colors to Solarized values 102 | " either manually or via one of the many terminal schemes available for import. 103 | " 104 | " --------------------------------------------------------------------- 105 | " TOGGLE BACKGROUND FUNCTION: 106 | " --------------------------------------------------------------------- 107 | " 108 | " Solarized comes with a Toggle Background plugin that by default will map to 109 | " if that mapping is available. If it is not available you will need to 110 | " either map the function manually or change your current mapping to 111 | " something else. If you wish to map the function manually, enter the following 112 | " lines in your .vimrc: 113 | " 114 | " nmap ToggleBackground 115 | " imap ToggleBackground 116 | " vmap ToggleBackground 117 | " 118 | " Note that it is important to *not* use the noremap map variants. The plugin 119 | " uses noremap internally. You may run `:help togglebg` for more information. 120 | " 121 | " --------------------------------------------------------------------- 122 | " OPTIONS 123 | " --------------------------------------------------------------------- 124 | " 125 | " Set these in your vimrc file prior to calling the colorscheme. 126 | " 127 | " option name default optional 128 | " ------------------------------------------------ 129 | " g:solarized_termcolors= 16 | 256 130 | " g:solarized_termtrans = 0 | 1 131 | " g:solarized_degrade = 0 | 1 132 | " g:solarized_bold = 1 | 0 133 | " g:solarized_underline = 1 | 0 134 | " g:solarized_italic = 1 | 0 135 | " g:solarized_contrast = "normal"| "high" or "low" 136 | " g:solarized_visibility= "normal"| "high" or "low" 137 | " ------------------------------------------------ 138 | " 139 | " OPTION DETAILS 140 | " 141 | " ------------------------------------------------ 142 | " g:solarized_termcolors= 256 | 16 143 | " ------------------------------------------------ 144 | " The most important option if you are using vim in terminal (non gui) mode! 145 | " This tells Solarized to use the 256 degraded color mode if running in a 256 146 | " color capable terminal. Otherwise, if set to `16` it will use the terminal 147 | " emulators colorscheme (best option as long as you've set the emulators colors 148 | " to the Solarized palette). 149 | " 150 | " If you are going to use Solarized in Terminal mode (i.e. not in a GUI 151 | " version like gvim or macvim), **please please please** consider setting your 152 | " terminal emulator's colorscheme to used the Solarized palette. I've included 153 | " palettes for some popular terminal emulator as well as Xdefaults in the 154 | " official Solarized download available from: 155 | " http://ethanschoonover.com/solarized . If you use Solarized without these 156 | " colors, Solarized will by default use an approximate set of 256 colors. It 157 | " isn't bad looking and has been extensively tweaked, but it's still not quite 158 | " the real thing. 159 | " 160 | " ------------------------------------------------ 161 | " g:solarized_termtrans = 0 | 1 162 | " ------------------------------------------------ 163 | " If you use a terminal emulator with a transparent background and Solarized 164 | " isn't displaying the background color transparently, set this to 1 and 165 | " Solarized will use the default (transparent) background of the terminal 166 | " emulator. *urxvt* required this in my testing; iTerm2 did not. 167 | " 168 | " Note that on Mac OS X Terminal.app, solarized_termtrans is set to 1 by 169 | " default as this is almost always the best option. The only exception to this 170 | " is if the working terminfo file supports 256 colors (xterm-256color). 171 | " 172 | " ------------------------------------------------ 173 | " g:solarized_degrade = 0 | 1 174 | " ------------------------------------------------ 175 | " For test purposes only; forces Solarized to use the 256 degraded color mode 176 | " to test the approximate color values for accuracy. 177 | " 178 | " ------------------------------------------------ 179 | " g:solarized_bold = 1 | 0 180 | " ------------------------------------------------ 181 | " ------------------------------------------------ 182 | " g:solarized_underline = 1 | 0 183 | " ------------------------------------------------ 184 | " ------------------------------------------------ 185 | " g:solarized_italic = 1 | 0 186 | " ------------------------------------------------ 187 | " If you wish to stop Solarized from displaying bold, underlined or 188 | " italicized typefaces, simply assign a zero value to the appropriate 189 | " variable, for example: `let g:solarized_italic=0` 190 | " 191 | " ------------------------------------------------ 192 | " g:solarized_contrast = "normal"| "high" or "low" 193 | " ------------------------------------------------ 194 | " Stick with normal! It's been carefully tested. Setting this option to high 195 | " or low does use the same Solarized palette but simply shifts some values up 196 | " or down in order to expand or compress the tonal range displayed. 197 | " 198 | " ------------------------------------------------ 199 | " g:solarized_visibility = "normal"| "high" or "low" 200 | " ------------------------------------------------ 201 | " Special characters such as trailing whitespace, tabs, newlines, when 202 | " displayed using ":set list" can be set to one of three levels depending on 203 | " your needs. 204 | " 205 | " --------------------------------------------------------------------- 206 | " COLOR VALUES 207 | " --------------------------------------------------------------------- 208 | " Download palettes and files from: http://ethanschoonover.com/solarized 209 | " 210 | " L\*a\*b values are canonical (White D65, Reference D50), other values are 211 | " matched in sRGB space. 212 | " 213 | " SOLARIZED HEX 16/8 TERMCOL XTERM/HEX L*A*B sRGB HSB 214 | " --------- ------- ---- ------- ----------- ---------- ----------- ----------- 215 | " base03 #002b36 8/4 brblack 234 #1c1c1c 15 -12 -12 0 43 54 193 100 21 216 | " base02 #073642 0/4 black 235 #262626 20 -12 -12 7 54 66 192 90 26 217 | " base01 #586e75 10/7 brgreen 240 #4e4e4e 45 -07 -07 88 110 117 194 25 46 218 | " base00 #657b83 11/7 bryellow 241 #585858 50 -07 -07 101 123 131 195 23 51 219 | " base0 #839496 12/6 brblue 244 #808080 60 -06 -03 131 148 150 186 13 59 220 | " base1 #93a1a1 14/4 brcyan 245 #8a8a8a 65 -05 -02 147 161 161 180 9 63 221 | " base2 #eee8d5 7/7 white 254 #d7d7af 92 -00 10 238 232 213 44 11 93 222 | " base3 #fdf6e3 15/7 brwhite 230 #ffffd7 97 00 10 253 246 227 44 10 99 223 | " yellow #b58900 3/3 yellow 136 #af8700 60 10 65 181 137 0 45 100 71 224 | " orange #cb4b16 9/3 brred 166 #d75f00 50 50 55 203 75 22 18 89 80 225 | " red #dc322f 1/1 red 160 #d70000 50 65 45 220 50 47 1 79 86 226 | " magenta #d33682 5/5 magenta 125 #af005f 50 65 -05 211 54 130 331 74 83 227 | " violet #6c71c4 13/5 brmagenta 61 #5f5faf 50 15 -45 108 113 196 237 45 77 228 | " blue #268bd2 4/4 blue 33 #0087ff 55 -10 -45 38 139 210 205 82 82 229 | " cyan #2aa198 6/6 cyan 37 #00afaf 60 -35 -05 42 161 152 175 74 63 230 | " green #859900 2/2 green 64 #5f8700 60 -20 65 133 153 0 68 100 60 231 | " 232 | " --------------------------------------------------------------------- 233 | " COLORSCHEME HACKING 234 | " --------------------------------------------------------------------- 235 | " 236 | " Useful commands for testing colorschemes: 237 | " :source $VIMRUNTIME/syntax/hitest.vim 238 | " :help highlight-groups 239 | " :help cterm-colors 240 | " :help group-name 241 | " 242 | " Useful links for developing colorschemes: 243 | " http://www.vim.org/scripts/script.php?script_id=2937 244 | " http://vimcasts.org/episodes/creating-colorschemes-for-vim/ 245 | " http://www.frexx.de/xterm-256-notes/" 246 | " 247 | " 248 | " }}} 249 | " Default option values"{{{ 250 | " --------------------------------------------------------------------- 251 | if !exists("g:solarized_termtrans") 252 | if ($TERM_PROGRAM ==? "apple_terminal" && &t_Co < 256) 253 | let g:solarized_termtrans = 1 254 | else 255 | let g:solarized_termtrans = 0 256 | endif 257 | endif 258 | if !exists("g:solarized_degrade") 259 | let g:solarized_degrade = 0 260 | endif 261 | if !exists("g:solarized_bold") 262 | let g:solarized_bold = 1 263 | endif 264 | if !exists("g:solarized_underline") 265 | let g:solarized_underline = 1 266 | endif 267 | if !exists("g:solarized_italic") 268 | let g:solarized_italic = 1 269 | endif 270 | if !exists("g:solarized_termcolors") 271 | let g:solarized_termcolors = 16 272 | endif 273 | if !exists("g:solarized_contrast") 274 | let g:solarized_contrast = "normal" 275 | endif 276 | if !exists("g:solarized_visibility") 277 | let g:solarized_visibility = "normal" 278 | endif 279 | "}}} 280 | " Colorscheme initialization "{{{ 281 | " --------------------------------------------------------------------- 282 | hi clear 283 | if exists("syntax_on") 284 | syntax reset 285 | endif 286 | let colors_name = "solarized" 287 | 288 | "}}} 289 | " GUI & CSApprox hexadecimal palettes"{{{ 290 | " --------------------------------------------------------------------- 291 | " 292 | " Set both gui and terminal color values in separate conditional statements 293 | " Due to possibility that CSApprox is running (though I suppose we could just 294 | " leave the hex values out entirely in that case and include only cterm colors) 295 | " We also check to see if user has set solarized (force use of the 296 | " neutral gray monotone palette component) 297 | if (has("gui_running") && g:solarized_degrade == 0) 298 | let s:vmode = "gui" 299 | let s:base03 = "#002b36" 300 | let s:base02 = "#073642" 301 | let s:base01 = "#586e75" 302 | let s:base00 = "#657b83" 303 | let s:base0 = "#839496" 304 | let s:base1 = "#93a1a1" 305 | let s:base2 = "#eee8d5" 306 | let s:base3 = "#fdf6e3" 307 | let s:yellow = "#b58900" 308 | let s:orange = "#cb4b16" 309 | let s:red = "#dc322f" 310 | let s:magenta = "#d33682" 311 | let s:violet = "#6c71c4" 312 | let s:blue = "#268bd2" 313 | let s:cyan = "#2aa198" 314 | let s:green = "#859900" 315 | elseif (has("gui_running") && g:solarized_degrade == 1) 316 | " These colors are identical to the 256 color mode. They may be viewed 317 | " while in gui mode via "let g:solarized_degrade=1", though this is not 318 | " recommened and is for testing only. 319 | let s:vmode = "gui" 320 | let s:base03 = "#1c1c1c" 321 | let s:base02 = "#262626" 322 | let s:base01 = "#4e4e4e" 323 | let s:base00 = "#585858" 324 | let s:base0 = "#808080" 325 | let s:base1 = "#8a8a8a" 326 | let s:base2 = "#d7d7af" 327 | let s:base3 = "#ffffd7" 328 | let s:yellow = "#af8700" 329 | let s:orange = "#d75f00" 330 | let s:red = "#af0000" 331 | let s:magenta = "#af005f" 332 | let s:violet = "#5f5faf" 333 | let s:blue = "#0087ff" 334 | let s:cyan = "#00afaf" 335 | let s:green = "#5f8700" 336 | elseif g:solarized_termcolors != 256 && &t_Co >= 16 337 | let s:vmode = "cterm" 338 | let s:base03 = "8" 339 | let s:base02 = "0" 340 | let s:base01 = "10" 341 | let s:base00 = "11" 342 | let s:base0 = "12" 343 | let s:base1 = "14" 344 | let s:base2 = "7" 345 | let s:base3 = "15" 346 | let s:yellow = "3" 347 | let s:orange = "9" 348 | let s:red = "1" 349 | let s:magenta = "5" 350 | let s:violet = "13" 351 | let s:blue = "4" 352 | let s:cyan = "6" 353 | let s:green = "2" 354 | elseif g:solarized_termcolors == 256 355 | let s:vmode = "cterm" 356 | let s:base03 = "234" 357 | let s:base02 = "235" 358 | let s:base01 = "239" 359 | let s:base00 = "240" 360 | let s:base0 = "244" 361 | let s:base1 = "245" 362 | let s:base2 = "187" 363 | let s:base3 = "230" 364 | let s:yellow = "136" 365 | let s:orange = "166" 366 | let s:red = "124" 367 | let s:magenta = "125" 368 | let s:violet = "61" 369 | let s:blue = "33" 370 | let s:cyan = "37" 371 | let s:green = "64" 372 | else 373 | let s:vmode = "cterm" 374 | let s:bright = "* term=bold cterm=bold" 375 | let s:base03 = "0".s:bright 376 | let s:base02 = "0" 377 | let s:base01 = "2".s:bright 378 | let s:base00 = "3".s:bright 379 | let s:base0 = "4".s:bright 380 | let s:base1 = "6".s:bright 381 | let s:base2 = "7" 382 | let s:base3 = "7".s:bright 383 | let s:yellow = "3" 384 | let s:orange = "1".s:bright 385 | let s:red = "1" 386 | let s:magenta = "5" 387 | let s:violet = "13" 388 | let s:blue = "4" 389 | let s:cyan = "6" 390 | let s:green = "2" 391 | endif 392 | "}}} 393 | " Formatting options and null values for passthrough effect "{{{ 394 | " --------------------------------------------------------------------- 395 | let s:none = "NONE" 396 | let s:none = "NONE" 397 | let s:t_none = "NONE" 398 | let s:n = "NONE" 399 | let s:c = ",undercurl" 400 | let s:r = ",reverse" 401 | let s:s = ",standout" 402 | let s:ou = "" 403 | let s:ob = "" 404 | "}}} 405 | " Background value based on termtrans setting "{{{ 406 | " --------------------------------------------------------------------- 407 | if (has("gui_running") || g:solarized_termtrans == 0) 408 | let s:back = s:base03 409 | else 410 | let s:back = "NONE" 411 | endif 412 | "}}} 413 | " Alternate light scheme "{{{ 414 | " --------------------------------------------------------------------- 415 | if &background == "light" 416 | let s:temp03 = s:base03 417 | let s:temp02 = s:base02 418 | let s:temp01 = s:base01 419 | let s:temp00 = s:base00 420 | let s:base03 = s:base3 421 | let s:base02 = s:base2 422 | let s:base01 = s:base1 423 | let s:base00 = s:base0 424 | let s:base0 = s:temp00 425 | let s:base1 = s:temp01 426 | let s:base2 = s:temp02 427 | let s:base3 = s:temp03 428 | if (s:back != "NONE") 429 | let s:back = s:base03 430 | endif 431 | endif 432 | "}}} 433 | " Optional contrast schemes "{{{ 434 | " --------------------------------------------------------------------- 435 | if g:solarized_contrast == "high" 436 | let s:base01 = s:base00 437 | let s:base00 = s:base0 438 | let s:base0 = s:base1 439 | let s:base1 = s:base2 440 | let s:base2 = s:base3 441 | let s:back = s:back 442 | endif 443 | if g:solarized_contrast == "low" 444 | let s:back = s:base02 445 | let s:ou = ",underline" 446 | endif 447 | "}}} 448 | " Overrides dependent on user specified values"{{{ 449 | " --------------------------------------------------------------------- 450 | if g:solarized_bold == 1 451 | let s:b = ",bold" 452 | else 453 | let s:b = "" 454 | endif 455 | 456 | if g:solarized_underline == 1 457 | let s:u = ",underline" 458 | else 459 | let s:u = "" 460 | endif 461 | 462 | if g:solarized_italic == 1 463 | let s:i = ",italic" 464 | else 465 | let s:i = "" 466 | endif 467 | "}}} 468 | " Highlighting primitives"{{{ 469 | " --------------------------------------------------------------------- 470 | 471 | exe "let s:bg_none = ' ".s:vmode."bg=".s:none ."'" 472 | exe "let s:bg_back = ' ".s:vmode."bg=".s:back ."'" 473 | exe "let s:bg_base03 = ' ".s:vmode."bg=".s:base03 ."'" 474 | exe "let s:bg_base02 = ' ".s:vmode."bg=".s:base02 ."'" 475 | exe "let s:bg_base01 = ' ".s:vmode."bg=".s:base01 ."'" 476 | exe "let s:bg_base00 = ' ".s:vmode."bg=".s:base00 ."'" 477 | exe "let s:bg_base0 = ' ".s:vmode."bg=".s:base0 ."'" 478 | exe "let s:bg_base1 = ' ".s:vmode."bg=".s:base1 ."'" 479 | exe "let s:bg_base2 = ' ".s:vmode."bg=".s:base2 ."'" 480 | exe "let s:bg_base3 = ' ".s:vmode."bg=".s:base3 ."'" 481 | exe "let s:bg_green = ' ".s:vmode."bg=".s:green ."'" 482 | exe "let s:bg_yellow = ' ".s:vmode."bg=".s:yellow ."'" 483 | exe "let s:bg_orange = ' ".s:vmode."bg=".s:orange ."'" 484 | exe "let s:bg_red = ' ".s:vmode."bg=".s:red ."'" 485 | exe "let s:bg_magenta = ' ".s:vmode."bg=".s:magenta."'" 486 | exe "let s:bg_violet = ' ".s:vmode."bg=".s:violet ."'" 487 | exe "let s:bg_blue = ' ".s:vmode."bg=".s:blue ."'" 488 | exe "let s:bg_cyan = ' ".s:vmode."bg=".s:cyan ."'" 489 | 490 | exe "let s:fg_none = ' ".s:vmode."fg=".s:none ."'" 491 | exe "let s:fg_back = ' ".s:vmode."fg=".s:back ."'" 492 | exe "let s:fg_base03 = ' ".s:vmode."fg=".s:base03 ."'" 493 | exe "let s:fg_base02 = ' ".s:vmode."fg=".s:base02 ."'" 494 | exe "let s:fg_base01 = ' ".s:vmode."fg=".s:base01 ."'" 495 | exe "let s:fg_base00 = ' ".s:vmode."fg=".s:base00 ."'" 496 | exe "let s:fg_base0 = ' ".s:vmode."fg=".s:base0 ."'" 497 | exe "let s:fg_base1 = ' ".s:vmode."fg=".s:base1 ."'" 498 | exe "let s:fg_base2 = ' ".s:vmode."fg=".s:base2 ."'" 499 | exe "let s:fg_base3 = ' ".s:vmode."fg=".s:base3 ."'" 500 | exe "let s:fg_green = ' ".s:vmode."fg=".s:green ."'" 501 | exe "let s:fg_yellow = ' ".s:vmode."fg=".s:yellow ."'" 502 | exe "let s:fg_orange = ' ".s:vmode."fg=".s:orange ."'" 503 | exe "let s:fg_red = ' ".s:vmode."fg=".s:red ."'" 504 | exe "let s:fg_magenta = ' ".s:vmode."fg=".s:magenta."'" 505 | exe "let s:fg_violet = ' ".s:vmode."fg=".s:violet ."'" 506 | exe "let s:fg_blue = ' ".s:vmode."fg=".s:blue ."'" 507 | exe "let s:fg_cyan = ' ".s:vmode."fg=".s:cyan ."'" 508 | 509 | exe "let s:fmt_none = ' ".s:vmode."=NONE". " term=NONE". "'" 510 | exe "let s:fmt_bold = ' ".s:vmode."=NONE".s:b. " term=NONE".s:b."'" 511 | exe "let s:fmt_bldi = ' ".s:vmode."=NONE".s:b. " term=NONE".s:b."'" 512 | exe "let s:fmt_undr = ' ".s:vmode."=NONE".s:u. " term=NONE".s:u."'" 513 | exe "let s:fmt_undb = ' ".s:vmode."=NONE".s:u.s:b. " term=NONE".s:u.s:b."'" 514 | exe "let s:fmt_undi = ' ".s:vmode."=NONE".s:u. " term=NONE".s:u."'" 515 | exe "let s:fmt_uopt = ' ".s:vmode."=NONE".s:ou. " term=NONE".s:ou."'" 516 | exe "let s:fmt_curl = ' ".s:vmode."=NONE".s:c. " term=NONE".s:c."'" 517 | exe "let s:fmt_ital = ' ".s:vmode."=NONE". " term=NONE". "'" 518 | exe "let s:fmt_revr = ' ".s:vmode."=NONE".s:r. " term=NONE".s:r."'" 519 | exe "let s:fmt_stnd = ' ".s:vmode."=NONE".s:s. " term=NONE".s:s."'" 520 | 521 | if has("gui_running") 522 | exe "let s:sp_none = ' guisp=".s:none ."'" 523 | exe "let s:sp_back = ' guisp=".s:back ."'" 524 | exe "let s:sp_base03 = ' guisp=".s:base03 ."'" 525 | exe "let s:sp_base02 = ' guisp=".s:base02 ."'" 526 | exe "let s:sp_base01 = ' guisp=".s:base01 ."'" 527 | exe "let s:sp_base00 = ' guisp=".s:base00 ."'" 528 | exe "let s:sp_base0 = ' guisp=".s:base0 ."'" 529 | exe "let s:sp_base1 = ' guisp=".s:base1 ."'" 530 | exe "let s:sp_base2 = ' guisp=".s:base2 ."'" 531 | exe "let s:sp_base3 = ' guisp=".s:base3 ."'" 532 | exe "let s:sp_green = ' guisp=".s:green ."'" 533 | exe "let s:sp_yellow = ' guisp=".s:yellow ."'" 534 | exe "let s:sp_orange = ' guisp=".s:orange ."'" 535 | exe "let s:sp_red = ' guisp=".s:red ."'" 536 | exe "let s:sp_magenta = ' guisp=".s:magenta."'" 537 | exe "let s:sp_violet = ' guisp=".s:violet ."'" 538 | exe "let s:sp_blue = ' guisp=".s:blue ."'" 539 | exe "let s:sp_cyan = ' guisp=".s:cyan ."'" 540 | else 541 | let s:sp_none = "" 542 | let s:sp_back = "" 543 | let s:sp_base03 = "" 544 | let s:sp_base02 = "" 545 | let s:sp_base01 = "" 546 | let s:sp_base00 = "" 547 | let s:sp_base0 = "" 548 | let s:sp_base1 = "" 549 | let s:sp_base2 = "" 550 | let s:sp_base3 = "" 551 | let s:sp_green = "" 552 | let s:sp_yellow = "" 553 | let s:sp_orange = "" 554 | let s:sp_red = "" 555 | let s:sp_magenta = "" 556 | let s:sp_violet = "" 557 | let s:sp_blue = "" 558 | let s:sp_cyan = "" 559 | endif 560 | 561 | "}}} 562 | " Basic highlighting"{{{ 563 | " --------------------------------------------------------------------- 564 | " note that link syntax to avoid duplicate configuration doesn't work with the 565 | " exe compiled formats 566 | 567 | exe "hi! Normal" .s:fmt_none .s:fg_base0 .s:bg_back 568 | 569 | exe "hi! Comment" .s:fmt_ital .s:fg_base01 .s:bg_none 570 | " *Comment any comment 571 | 572 | exe "hi! Constant" .s:fmt_none .s:fg_cyan .s:bg_none 573 | " *Constant any constant 574 | " String a string constant: "this is a string" 575 | " Character a character constant: 'c', '\n' 576 | " Number a number constant: 234, 0xff 577 | " Boolean a boolean constant: TRUE, false 578 | " Float a floating point constant: 2.3e10 579 | 580 | exe "hi! Identifier" .s:fmt_none .s:fg_blue .s:bg_none 581 | " *Identifier any variable name 582 | " Function function name (also: methods for classes) 583 | " 584 | exe "hi! Statement" .s:fmt_none .s:fg_green .s:bg_none 585 | " *Statement any statement 586 | " Conditional if, then, else, endif, switch, etc. 587 | " Repeat for, do, while, etc. 588 | " Label case, default, etc. 589 | " Operator "sizeof", "+", "*", etc. 590 | " Keyword any other keyword 591 | " Exception try, catch, throw 592 | 593 | exe "hi! PreProc" .s:fmt_none .s:fg_orange .s:bg_none 594 | " *PreProc generic Preprocessor 595 | " Include preprocessor #include 596 | " Define preprocessor #define 597 | " Macro same as Define 598 | " PreCondit preprocessor #if, #else, #endif, etc. 599 | 600 | exe "hi! Type" .s:fmt_none .s:fg_yellow .s:bg_none 601 | " *Type int, long, char, etc. 602 | " StorageClass static, register, volatile, etc. 603 | " Structure struct, union, enum, etc. 604 | " Typedef A typedef 605 | 606 | exe "hi! Special" .s:fmt_none .s:fg_red .s:bg_none 607 | " *Special any special symbol 608 | " SpecialChar special character in a constant 609 | " Tag you can use CTRL-] on this 610 | " Delimiter character that needs attention 611 | " SpecialComment special things inside a comment 612 | " Debug debugging statements 613 | 614 | exe "hi! Underlined" .s:fmt_none .s:fg_violet .s:bg_none 615 | " *Underlined text that stands out, HTML links 616 | 617 | exe "hi! Ignore" .s:fmt_none .s:fg_none .s:bg_none 618 | " *Ignore left blank, hidden |hl-Ignore| 619 | 620 | exe "hi! Error" .s:fmt_bold .s:fg_red .s:bg_none 621 | " *Error any erroneous construct 622 | 623 | exe "hi! Todo" .s:fmt_bold .s:fg_magenta.s:bg_none 624 | " *Todo anything that needs extra attention; mostly the 625 | " keywords TODO FIXME and XXX 626 | " 627 | "}}} 628 | " Extended highlighting "{{{ 629 | " --------------------------------------------------------------------- 630 | if (g:solarized_visibility=="high") 631 | exe "hi! SpecialKey" .s:fmt_revr .s:fg_red .s:bg_none 632 | exe "hi! NonText" .s:fmt_bold .s:fg_base1 .s:bg_none 633 | elseif (g:solarized_visibility=="low") 634 | exe "hi! SpecialKey" .s:fmt_bold .s:fg_base02 .s:bg_none 635 | exe "hi! NonText" .s:fmt_bold .s:fg_base02 .s:bg_none 636 | else 637 | exe "hi! SpecialKey" .s:fmt_bold .s:fg_red .s:bg_none 638 | exe "hi! NonText" .s:fmt_bold .s:fg_base01 .s:bg_none 639 | endif 640 | if (has("gui_running")) || &t_Co > 8 641 | exe "hi! StatusLine" .s:fmt_none .s:fg_base02 .s:bg_base1 642 | exe "hi! StatusLineNC" .s:fmt_none .s:fg_base02 .s:bg_base00 643 | "exe "hi! Visual" .s:fmt_stnd .s:fg_none .s:bg_base02 644 | exe "hi! Visual" .s:fmt_none .s:fg_base03 .s:bg_base01 645 | else 646 | exe "hi! StatusLine" .s:fmt_none .s:fg_base02 .s:bg_base2 647 | exe "hi! StatusLineNC" .s:fmt_none .s:fg_base02 .s:bg_base2 648 | exe "hi! Visual" .s:fmt_none .s:fg_none .s:bg_base2 649 | endif 650 | exe "hi! Directory" .s:fmt_none .s:fg_blue .s:bg_none 651 | exe "hi! ErrorMsg" .s:fmt_revr .s:fg_red .s:bg_none 652 | exe "hi! IncSearch" .s:fmt_stnd .s:fg_orange .s:bg_none 653 | exe "hi! Search" .s:fmt_revr .s:fg_yellow .s:bg_none 654 | exe "hi! MoreMsg" .s:fmt_none .s:fg_blue .s:bg_none 655 | exe "hi! ModeMsg" .s:fmt_none .s:fg_blue .s:bg_none 656 | exe "hi! LineNr" .s:fmt_none .s:fg_base01 .s:bg_base02 657 | exe "hi! Question" .s:fmt_bold .s:fg_cyan .s:bg_none 658 | exe "hi! VertSplit" .s:fmt_bold .s:fg_base00 .s:bg_base00 659 | exe "hi! Title" .s:fmt_bold .s:fg_orange .s:bg_none 660 | exe "hi! VisualNOS" .s:fmt_stnd .s:fg_none .s:bg_base02 661 | exe "hi! WarningMsg" .s:fmt_bold .s:fg_red .s:bg_none 662 | exe "hi! WildMenu" .s:fmt_none .s:fg_base2 .s:bg_base02 663 | exe "hi! Folded" .s:fmt_undb .s:fg_base0 .s:bg_base02 .s:sp_base03 664 | exe "hi! FoldColumn" .s:fmt_bold .s:fg_base0 .s:bg_base02 665 | exe "hi! DiffAdd" .s:fmt_revr .s:fg_green .s:bg_none 666 | exe "hi! DiffChange" .s:fmt_revr .s:fg_yellow .s:bg_none 667 | exe "hi! DiffDelete" .s:fmt_revr .s:fg_red .s:bg_none 668 | exe "hi! DiffText" .s:fmt_revr .s:fg_blue .s:bg_none 669 | exe "hi! SignColumn" .s:fmt_none .s:fg_base0 .s:bg_base02 670 | exe "hi! Conceal" .s:fmt_none .s:fg_blue .s:bg_none 671 | exe "hi! SpellBad" .s:fmt_curl .s:fg_none .s:bg_none .s:sp_red 672 | exe "hi! SpellCap" .s:fmt_curl .s:fg_none .s:bg_none .s:sp_violet 673 | exe "hi! SpellRare" .s:fmt_curl .s:fg_none .s:bg_none .s:sp_cyan 674 | exe "hi! SpellLocal" .s:fmt_curl .s:fg_none .s:bg_none .s:sp_yellow 675 | exe "hi! Pmenu" .s:fmt_none .s:fg_base0 .s:bg_base02 676 | exe "hi! PmenuSel" .s:fmt_none .s:fg_base2 .s:bg_base01 677 | exe "hi! PmenuSbar" .s:fmt_none .s:fg_base0 .s:bg_base2 678 | exe "hi! PmenuThumb" .s:fmt_none .s:fg_base03 .s:bg_base0 679 | exe "hi! TabLine" .s:fmt_undr .s:fg_base0 .s:bg_base02 .s:sp_base0 680 | exe "hi! TabLineSel" .s:fmt_undr .s:fg_base2 .s:bg_base01 .s:sp_base0 681 | exe "hi! TabLineFill" .s:fmt_undr .s:fg_base0 .s:bg_base02 .s:sp_base0 682 | exe "hi! CursorColumn" .s:fmt_none .s:fg_none .s:bg_base02 683 | exe "hi! CursorLine" .s:fmt_uopt .s:fg_none .s:bg_base02 .s:sp_base1 684 | exe "hi! ColorColumn" .s:fmt_none .s:fg_none .s:bg_base02 685 | exe "hi! Cursor" .s:fmt_none .s:fg_base03 .s:bg_base0 686 | hi! link lCursor Cursor 687 | exe "hi! MatchParen" .s:fmt_bold .s:fg_red .s:bg_base01 688 | 689 | "}}} 690 | " vim syntax highlighting "{{{ 691 | " --------------------------------------------------------------------- 692 | exe "hi! vimLineComment" . s:fg_base01 .s:bg_none .s:fmt_ital 693 | exe "hi! vimCommentString".s:fg_violet .s:bg_none .s:fmt_none 694 | hi! link vimVar Identifier 695 | hi! link vimFunc Function 696 | hi! link vimUserFunc Function 697 | exe "hi! vimCommand" . s:fg_yellow .s:bg_none .s:fmt_none 698 | exe "hi! vimCmdSep" . s:fg_blue .s:bg_none .s:fmt_bold 699 | exe "hi! helpExample" . s:fg_base1 .s:bg_none .s:fmt_none 700 | hi! link helpSpecial Special 701 | exe "hi! helpOption" . s:fg_cyan .s:bg_none .s:fmt_none 702 | exe "hi! helpNote" . s:fg_magenta.s:bg_none .s:fmt_none 703 | exe "hi! helpVim" . s:fg_magenta.s:bg_none .s:fmt_none 704 | exe "hi! helpHyperTextJump" .s:fg_blue .s:bg_none .s:fmt_undr 705 | exe "hi! helpHyperTextEntry".s:fg_green .s:bg_none .s:fmt_none 706 | exe "hi! vimIsCommand" . s:fg_base00 .s:bg_none .s:fmt_none 707 | exe "hi! vimSynMtchOpt" . s:fg_yellow .s:bg_none .s:fmt_none 708 | exe "hi! vimSynType" . s:fg_cyan .s:bg_none .s:fmt_none 709 | exe "hi! vimHiLink" . s:fg_blue .s:bg_none .s:fmt_none 710 | exe "hi! vimHiGroup" . s:fg_blue .s:bg_none .s:fmt_none 711 | exe "hi! vimGroup" . s:fg_blue .s:bg_none .s:fmt_undb 712 | "}}} 713 | " html highlighting "{{{ 714 | " --------------------------------------------------------------------- 715 | exe "hi! htmlTag" . s:fg_base01 .s:bg_none .s:fmt_none 716 | exe "hi! htmlEndTag" . s:fg_base01 .s:bg_none .s:fmt_none 717 | exe "hi! htmlTagN" . s:fg_base1 .s:bg_none .s:fmt_bold 718 | exe "hi! htmlTagName" . s:fg_blue .s:bg_none .s:fmt_bold 719 | exe "hi! htmlSpecialTagName". s:fg_blue .s:bg_none .s:fmt_ital 720 | exe "hi! htmlArg" . s:fg_base00 .s:bg_none .s:fmt_none 721 | exe "hi! javaScript" . s:fg_yellow .s:bg_none .s:fmt_none 722 | "}}} 723 | " perl highlighting "{{{ 724 | " --------------------------------------------------------------------- 725 | exe "hi! perlHereDoc" . s:fg_base1 .s:bg_back .s:fmt_none 726 | exe "hi! perlVarPlain" . s:fg_yellow .s:bg_back .s:fmt_none 727 | exe "hi! perlStatementFileDesc". s:fg_cyan.s:bg_back.s:fmt_none 728 | 729 | "}}} 730 | " tex highlighting "{{{ 731 | " --------------------------------------------------------------------- 732 | exe "hi! texStatement" . s:fg_cyan .s:bg_back .s:fmt_none 733 | exe "hi! texMathZoneX" . s:fg_yellow .s:bg_back .s:fmt_none 734 | exe "hi! texMathMatcher" . s:fg_yellow .s:bg_back .s:fmt_none 735 | exe "hi! texMathMatcher" . s:fg_yellow .s:bg_back .s:fmt_none 736 | exe "hi! texRefLabel" . s:fg_yellow .s:bg_back .s:fmt_none 737 | "}}} 738 | " ruby highlighting "{{{ 739 | " --------------------------------------------------------------------- 740 | exe "hi! rubyDefine" . s:fg_base1 .s:bg_back .s:fmt_bold 741 | "rubyInclude 742 | "rubySharpBang 743 | "rubyAccess 744 | "rubyPredefinedVariable 745 | "rubyBoolean 746 | "rubyClassVariable 747 | "rubyBeginEnd 748 | "rubyRepeatModifier 749 | "hi! link rubyArrayDelimiter Special " [ , , ] 750 | "rubyCurlyBlock { , , } 751 | 752 | "hi! link rubyClass Keyword 753 | "hi! link rubyModule Keyword 754 | "hi! link rubyKeyword Keyword 755 | "hi! link rubyOperator Operator 756 | "hi! link rubyIdentifier Identifier 757 | "hi! link rubyInstanceVariable Identifier 758 | "hi! link rubyGlobalVariable Identifier 759 | "hi! link rubyClassVariable Identifier 760 | "hi! link rubyConstant Type 761 | "}}} 762 | " haskell syntax highlighting"{{{ 763 | " --------------------------------------------------------------------- 764 | " For use with syntax/haskell.vim : Haskell Syntax File 765 | " http://www.vim.org/scripts/script.php?script_id=3034 766 | " See also Steffen Siering's github repository: 767 | " http://github.com/urso/dotrc/blob/master/vim/syntax/haskell.vim 768 | " --------------------------------------------------------------------- 769 | " 770 | " Treat True and False specially, see the plugin referenced above 771 | let hs_highlight_boolean=1 772 | " highlight delims, see the plugin referenced above 773 | let hs_highlight_delimiters=1 774 | 775 | exe "hi! cPreCondit". s:fg_orange.s:bg_none .s:fmt_none 776 | 777 | exe "hi! VarId" . s:fg_blue .s:bg_none .s:fmt_none 778 | exe "hi! ConId" . s:fg_yellow .s:bg_none .s:fmt_none 779 | exe "hi! hsImport" . s:fg_magenta.s:bg_none .s:fmt_none 780 | exe "hi! hsString" . s:fg_base00 .s:bg_none .s:fmt_none 781 | 782 | exe "hi! hsStructure" . s:fg_cyan .s:bg_none .s:fmt_none 783 | exe "hi! hs_hlFunctionName" . s:fg_blue .s:bg_none 784 | exe "hi! hsStatement" . s:fg_cyan .s:bg_none .s:fmt_none 785 | exe "hi! hsImportLabel" . s:fg_cyan .s:bg_none .s:fmt_none 786 | exe "hi! hs_OpFunctionName" . s:fg_yellow .s:bg_none .s:fmt_none 787 | exe "hi! hs_DeclareFunction" . s:fg_orange .s:bg_none .s:fmt_none 788 | exe "hi! hsVarSym" . s:fg_cyan .s:bg_none .s:fmt_none 789 | exe "hi! hsType" . s:fg_yellow .s:bg_none .s:fmt_none 790 | exe "hi! hsTypedef" . s:fg_cyan .s:bg_none .s:fmt_none 791 | exe "hi! hsModuleName" . s:fg_green .s:bg_none .s:fmt_undr 792 | exe "hi! hsModuleStartLabel" . s:fg_magenta.s:bg_none .s:fmt_none 793 | hi! link hsImportParams Delimiter 794 | hi! link hsDelimTypeExport Delimiter 795 | hi! link hsModuleStartLabel hsStructure 796 | hi! link hsModuleWhereLabel hsModuleStartLabel 797 | 798 | " following is for the haskell-conceal plugin 799 | " the first two items don't have an impact, but better safe 800 | exe "hi! hsNiceOperator" . s:fg_cyan .s:bg_none .s:fmt_none 801 | exe "hi! hsniceoperator" . s:fg_cyan .s:bg_none .s:fmt_none 802 | 803 | "}}} 804 | " pandoc markdown syntax highlighting "{{{ 805 | " --------------------------------------------------------------------- 806 | 807 | "PandocHiLink pandocNormalBlock 808 | exe "hi! pandocTitleBlock" .s:fg_blue .s:bg_none .s:fmt_none 809 | exe "hi! pandocTitleBlockTitle" .s:fg_blue .s:bg_none .s:fmt_bold 810 | exe "hi! pandocTitleComment" .s:fg_blue .s:bg_none .s:fmt_bold 811 | exe "hi! pandocComment" .s:fg_base01 .s:bg_none .s:fmt_ital 812 | exe "hi! pandocVerbatimBlock" .s:fg_yellow .s:bg_none .s:fmt_none 813 | hi! link pandocVerbatimBlockDeep pandocVerbatimBlock 814 | hi! link pandocCodeBlock pandocVerbatimBlock 815 | hi! link pandocCodeBlockDelim pandocVerbatimBlock 816 | exe "hi! pandocBlockQuote" .s:fg_blue .s:bg_none .s:fmt_none 817 | exe "hi! pandocBlockQuoteLeader1" .s:fg_blue .s:bg_none .s:fmt_none 818 | exe "hi! pandocBlockQuoteLeader2" .s:fg_cyan .s:bg_none .s:fmt_none 819 | exe "hi! pandocBlockQuoteLeader3" .s:fg_yellow .s:bg_none .s:fmt_none 820 | exe "hi! pandocBlockQuoteLeader4" .s:fg_red .s:bg_none .s:fmt_none 821 | exe "hi! pandocBlockQuoteLeader5" .s:fg_base0 .s:bg_none .s:fmt_none 822 | exe "hi! pandocBlockQuoteLeader6" .s:fg_base01 .s:bg_none .s:fmt_none 823 | exe "hi! pandocListMarker" .s:fg_magenta.s:bg_none .s:fmt_none 824 | exe "hi! pandocListReference" .s:fg_magenta.s:bg_none .s:fmt_undr 825 | 826 | " Definitions 827 | " --------------------------------------------------------------------- 828 | let s:fg_pdef = s:fg_violet 829 | exe "hi! pandocDefinitionBlock" .s:fg_pdef .s:bg_none .s:fmt_none 830 | exe "hi! pandocDefinitionTerm" .s:fg_pdef .s:bg_none .s:fmt_stnd 831 | exe "hi! pandocDefinitionIndctr" .s:fg_pdef .s:bg_none .s:fmt_bold 832 | exe "hi! pandocEmphasisDefinition" .s:fg_pdef .s:bg_none .s:fmt_ital 833 | exe "hi! pandocEmphasisNestedDefinition" .s:fg_pdef .s:bg_none .s:fmt_bldi 834 | exe "hi! pandocStrongEmphasisDefinition" .s:fg_pdef .s:bg_none .s:fmt_bold 835 | exe "hi! pandocStrongEmphasisNestedDefinition" .s:fg_pdef.s:bg_none.s:fmt_bldi 836 | exe "hi! pandocStrongEmphasisEmphasisDefinition" .s:fg_pdef.s:bg_none.s:fmt_bldi 837 | exe "hi! pandocStrikeoutDefinition" .s:fg_pdef .s:bg_none .s:fmt_revr 838 | exe "hi! pandocVerbatimInlineDefinition" .s:fg_pdef .s:bg_none .s:fmt_none 839 | exe "hi! pandocSuperscriptDefinition" .s:fg_pdef .s:bg_none .s:fmt_none 840 | exe "hi! pandocSubscriptDefinition" .s:fg_pdef .s:bg_none .s:fmt_none 841 | 842 | " Tables 843 | " --------------------------------------------------------------------- 844 | let s:fg_ptable = s:fg_blue 845 | exe "hi! pandocTable" .s:fg_ptable.s:bg_none .s:fmt_none 846 | exe "hi! pandocTableStructure" .s:fg_ptable.s:bg_none .s:fmt_none 847 | hi! link pandocTableStructureTop pandocTableStructre 848 | hi! link pandocTableStructureEnd pandocTableStructre 849 | exe "hi! pandocTableZebraLight" .s:fg_ptable.s:bg_base03.s:fmt_none 850 | exe "hi! pandocTableZebraDark" .s:fg_ptable.s:bg_base02.s:fmt_none 851 | exe "hi! pandocEmphasisTable" .s:fg_ptable.s:bg_none .s:fmt_ital 852 | exe "hi! pandocEmphasisNestedTable" .s:fg_ptable.s:bg_none .s:fmt_bldi 853 | exe "hi! pandocStrongEmphasisTable" .s:fg_ptable.s:bg_none .s:fmt_bold 854 | exe "hi! pandocStrongEmphasisNestedTable" .s:fg_ptable.s:bg_none .s:fmt_bldi 855 | exe "hi! pandocStrongEmphasisEmphasisTable" .s:fg_ptable.s:bg_none .s:fmt_bldi 856 | exe "hi! pandocStrikeoutTable" .s:fg_ptable.s:bg_none .s:fmt_revr 857 | exe "hi! pandocVerbatimInlineTable" .s:fg_ptable.s:bg_none .s:fmt_none 858 | exe "hi! pandocSuperscriptTable" .s:fg_ptable.s:bg_none .s:fmt_none 859 | exe "hi! pandocSubscriptTable" .s:fg_ptable.s:bg_none .s:fmt_none 860 | 861 | " Headings 862 | " --------------------------------------------------------------------- 863 | let s:fg_phead = s:fg_orange 864 | exe "hi! pandocHeading" .s:fg_phead .s:bg_none.s:fmt_bold 865 | exe "hi! pandocHeadingMarker" .s:fg_yellow.s:bg_none.s:fmt_bold 866 | exe "hi! pandocEmphasisHeading" .s:fg_phead .s:bg_none.s:fmt_bldi 867 | exe "hi! pandocEmphasisNestedHeading" .s:fg_phead .s:bg_none.s:fmt_bldi 868 | exe "hi! pandocStrongEmphasisHeading" .s:fg_phead .s:bg_none.s:fmt_bold 869 | exe "hi! pandocStrongEmphasisNestedHeading" .s:fg_phead .s:bg_none.s:fmt_bldi 870 | exe "hi! pandocStrongEmphasisEmphasisHeading".s:fg_phead .s:bg_none.s:fmt_bldi 871 | exe "hi! pandocStrikeoutHeading" .s:fg_phead .s:bg_none.s:fmt_revr 872 | exe "hi! pandocVerbatimInlineHeading" .s:fg_phead .s:bg_none.s:fmt_bold 873 | exe "hi! pandocSuperscriptHeading" .s:fg_phead .s:bg_none.s:fmt_bold 874 | exe "hi! pandocSubscriptHeading" .s:fg_phead .s:bg_none.s:fmt_bold 875 | 876 | " Links 877 | " --------------------------------------------------------------------- 878 | exe "hi! pandocLinkDelim" .s:fg_base01 .s:bg_none .s:fmt_none 879 | exe "hi! pandocLinkLabel" .s:fg_blue .s:bg_none .s:fmt_undr 880 | exe "hi! pandocLinkText" .s:fg_blue .s:bg_none .s:fmt_undb 881 | exe "hi! pandocLinkURL" .s:fg_base00 .s:bg_none .s:fmt_undr 882 | exe "hi! pandocLinkTitle" .s:fg_base00 .s:bg_none .s:fmt_undi 883 | exe "hi! pandocLinkTitleDelim" .s:fg_base01 .s:bg_none .s:fmt_undi .s:sp_base00 884 | exe "hi! pandocLinkDefinition" .s:fg_cyan .s:bg_none .s:fmt_undr .s:sp_base00 885 | exe "hi! pandocLinkDefinitionID" .s:fg_blue .s:bg_none .s:fmt_bold 886 | exe "hi! pandocImageCaption" .s:fg_violet .s:bg_none .s:fmt_undb 887 | exe "hi! pandocFootnoteLink" .s:fg_green .s:bg_none .s:fmt_undr 888 | exe "hi! pandocFootnoteDefLink" .s:fg_green .s:bg_none .s:fmt_bold 889 | exe "hi! pandocFootnoteInline" .s:fg_green .s:bg_none .s:fmt_undb 890 | exe "hi! pandocFootnote" .s:fg_green .s:bg_none .s:fmt_none 891 | exe "hi! pandocCitationDelim" .s:fg_magenta.s:bg_none .s:fmt_none 892 | exe "hi! pandocCitation" .s:fg_magenta.s:bg_none .s:fmt_none 893 | exe "hi! pandocCitationID" .s:fg_magenta.s:bg_none .s:fmt_undr 894 | exe "hi! pandocCitationRef" .s:fg_magenta.s:bg_none .s:fmt_none 895 | 896 | " Main Styles 897 | " --------------------------------------------------------------------- 898 | exe "hi! pandocStyleDelim" .s:fg_base01 .s:bg_none .s:fmt_none 899 | exe "hi! pandocEmphasis" .s:fg_base0 .s:bg_none .s:fmt_ital 900 | exe "hi! pandocEmphasisNested" .s:fg_base0 .s:bg_none .s:fmt_bldi 901 | exe "hi! pandocStrongEmphasis" .s:fg_base0 .s:bg_none .s:fmt_bold 902 | exe "hi! pandocStrongEmphasisNested" .s:fg_base0 .s:bg_none .s:fmt_bldi 903 | exe "hi! pandocStrongEmphasisEmphasis" .s:fg_base0 .s:bg_none .s:fmt_bldi 904 | exe "hi! pandocStrikeout" .s:fg_base01 .s:bg_none .s:fmt_revr 905 | exe "hi! pandocVerbatimInline" .s:fg_yellow .s:bg_none .s:fmt_none 906 | exe "hi! pandocSuperscript" .s:fg_violet .s:bg_none .s:fmt_none 907 | exe "hi! pandocSubscript" .s:fg_violet .s:bg_none .s:fmt_none 908 | 909 | exe "hi! pandocRule" .s:fg_blue .s:bg_none .s:fmt_bold 910 | exe "hi! pandocRuleLine" .s:fg_blue .s:bg_none .s:fmt_bold 911 | exe "hi! pandocEscapePair" .s:fg_red .s:bg_none .s:fmt_bold 912 | exe "hi! pandocCitationRef" .s:fg_magenta.s:bg_none .s:fmt_none 913 | exe "hi! pandocNonBreakingSpace" . s:fg_red .s:bg_none .s:fmt_revr 914 | hi! link pandocEscapedCharacter pandocEscapePair 915 | hi! link pandocLineBreak pandocEscapePair 916 | 917 | " Embedded Code 918 | " --------------------------------------------------------------------- 919 | exe "hi! pandocMetadataDelim" .s:fg_base01 .s:bg_none .s:fmt_none 920 | exe "hi! pandocMetadata" .s:fg_blue .s:bg_none .s:fmt_none 921 | exe "hi! pandocMetadataKey" .s:fg_blue .s:bg_none .s:fmt_none 922 | exe "hi! pandocMetadata" .s:fg_blue .s:bg_none .s:fmt_bold 923 | hi! link pandocMetadataTitle pandocMetadata 924 | 925 | "}}} 926 | " Utility autocommand "{{{ 927 | " --------------------------------------------------------------------- 928 | " In cases where Solarized is initialized inside a terminal vim session and 929 | " then transferred to a gui session via the command `:gui`, the gui vim process 930 | " does not re-read the colorscheme (or .vimrc for that matter) so any `has_gui` 931 | " related code that sets gui specific values isn't executed. 932 | " 933 | " Currently, Solarized sets only the cterm or gui values for the colorscheme 934 | " depending on gui or terminal mode. It's possible that, if the following 935 | " autocommand method is deemed excessively poor form, that approach will be 936 | " used again and the autocommand below will be dropped. 937 | " 938 | " However it seems relatively benign in this case to include the autocommand 939 | " here. It fires only in cases where vim is transferring from terminal to gui 940 | " mode (detected with the script scope s:vmode variable). It also allows for 941 | " other potential terminal customizations that might make gui mode suboptimal. 942 | " 943 | autocmd GUIEnter * if (s:vmode != "gui") | exe "colorscheme " . g:colors_name | endif 944 | "}}} 945 | " License "{{{ 946 | " --------------------------------------------------------------------- 947 | " 948 | " Copyright (c) 2011 Ethan Schoonover 949 | " 950 | " Permission is hereby granted, free of charge, to any person obtaining a copy 951 | " of this software and associated documentation files (the "Software"), to deal 952 | " in the Software without restriction, including without limitation the rights 953 | " to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 954 | " copies of the Software, and to permit persons to whom the Software is 955 | " furnished to do so, subject to the following conditions: 956 | " 957 | " The above copyright notice and this permission notice shall be included in 958 | " all copies or substantial portions of the Software. 959 | " 960 | " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 961 | " IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 962 | " FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 963 | " AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 964 | " LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 965 | " OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 966 | " THE SOFTWARE. 967 | " 968 | " vim:foldmethod=marker:foldlevel=0 969 | "}}} 970 | -------------------------------------------------------------------------------- /usr/share/vim/vimrc: -------------------------------------------------------------------------------- 1 | " .vimrc version 20231229 - Romjul 2023 version! 2 | 3 | " #### WHEN STARTING/STOPPING 4 | 5 | " ### FILES 6 | 7 | " ## LOAD PLUGINS AUTOMATICALLY 8 | " Use vim defaults (much better!) to load plugins by default 9 | set nocompatible 10 | 11 | " ## IGNORE MODELINES INSIDE OPENED FILES 12 | " Prevent potential malicious modelines evaluations (default=5) 13 | set modelines=0 14 | 15 | " ## OPENING AND CLOSING FILES (:e, :n) 16 | 17 | " When using :edit autocomplete, deprioritize files named with these extensions: 18 | set suffixes=.aux,.bak,.dvi,.idx,.ps,.swp,.swo,.tar 19 | 20 | " Automatically save modifications to files on :next 21 | set autowrite 22 | 23 | " ## KEEP BACKUPS AND UNDO ON A PER FILE BASIS 24 | " # ACCOMODATE WINDOWS BAREMETAL WHERE THERE'S NO $HOME 25 | if (!exists('$HOME') && exists('$HOMEDRIVE') && exists('$HOMEPATH')) 26 | let $HOME=$HOMEDRIVE.$HOMEPATH 27 | endif " $HOME 28 | 29 | " In ~/.vim/ : backup swap undo .netrwhist 30 | if !isdirectory($HOME."/.vim") 31 | call mkdir($HOME."/.vim", "", 0770) 32 | endif 33 | 34 | " In case of a crash, save a swapfile 35 | if !isdirectory($HOME."/.vim/swap") 36 | call mkdir($HOME."/.vim/swap", "", 0700) 37 | endif 38 | set directory=~/.vim/swap 39 | 40 | " In regular use, keep a per file undo history 41 | if !isdirectory($HOME."/.vim/undo") 42 | call mkdir($HOME."/.vim/undo", "", 0700) 43 | endif 44 | set undodir=~/.vim/undo 45 | set undofile 46 | 47 | " After saving, backup the old file as file~ 48 | if !isdirectory($HOME."/.vim/backup") 49 | call mkdir($HOME."/.vim/backup", "", 0700) 50 | endif 51 | set backupdir=~/.vim/backup 52 | set backup 53 | 54 | " ## JUMP TO THE LAST KNOWN CURSOR POSITION 55 | if has("autocmd") 56 | " Not done if the position is invalid or when inside an event handler 57 | " (happens when dropping a file on gvim). 58 | autocmd BufReadPost * 59 | \ if line("'\"") > 0 && line("'\"") <= line("$") | 60 | \ exe "normal g`\"" | 61 | \ endif " if line 62 | 63 | " ## KEEP PREVIOUS VERSIONS OF FILES 64 | " # FIXME: should check an exclusion list to avoid saving sensitive files 65 | " WARNING: autocmd can confuse to busybox vi, always make it conditional 66 | if has("autocmd") 67 | " Can limit max files per day with .strftime("%F") or if per hour: %F.%H etc 68 | " Use an extension to the buffer filename on open 69 | "autocmd BufWritePre * let &bex = '~' . strftime("%F") 70 | " On better, do that on write with the full recoded path 71 | if ! expand("%:p") =~ "^/var/tmp/" 72 | " # FIXME: only 1 exclusion so far: /var/tmp where sudoedit saves files 73 | autocmd BufWritePost * :silent! execute ':w! ' . &backupdir . "/" . substitute(escape(substitute(expand('%:p'), "/", "%", "g"), "%"), ' ', '\\ ', 'g') . '~' . strftime("%F.%H") 74 | endif 75 | endif 76 | 77 | " ### TERMINAL 78 | 79 | " ## USE ALTERNATE SCREEN TO LEAVE A CLEAR SCREEN ON EXIT 80 | 81 | " Either don't clear the screen upon exit 82 | "set t_ti= 83 | "set t_te= 84 | 85 | " Or do not damage scrollback using the alternative screen buffer 86 | "set t_ti=^[[?1049h 87 | "set t_te=^[[?1049l 88 | 89 | " Or by default, leave it to terminfo based on $TERM: check if the test fails: 90 | " printf "Hello, \e[?1049h ABCDEFG \e[?1049l World\n" 91 | " as it can also be a (deprecated) variant of: 92 | " printf "Hello, \e[[?47h ABCDEFG \e[2J\e[[?47l World\n" 93 | 94 | " This is because ti clears memory before switching to the alternate screen. 95 | " The older and deprecated \E[?47h did not do this, requiring applications to embed 96 | " a \E[2J in the ti string which is called rmcup by terminfo. 97 | " It's seen with $TERM=xterm-old where rmcup=\E[2J\E[?47l\E8, smcup=\E7\E[?47h 98 | " set t_ti=^[7^[[r^[[?47h t_te=^[[?47l^[8 99 | 100 | " ## SAVE POWER BY CHANGING THE CURSOR TO NOT BLINK 101 | 102 | " When starting vi, based on the above, use a block curson 103 | "let &t_ti.="\e[1 q" " blinking 104 | let &t_ti.="\e[2 q" " not blinking 105 | "let &t_ti .= "\e[?2004h" 106 | " When leaving vim likewise: 107 | "let &t_te.="\e[0 q" " reset the cursor 108 | let &t_te.="\e[2 q" " block not blinking 109 | "let &t_te = "\e[?2004l" . &t_te 110 | 111 | " Then change cursor depending on mode: 112 | " (can also use colors ex blinking orange) 113 | " let &t_SI = "\e[5 q\e]12;orange\x7" 114 | 115 | " Insert mode 116 | let &t_SI.="\e[6 q" " bar unblinking 117 | "let &t_SI.="\e[5 q" " bar blinking 118 | " Replace mode 119 | let &t_SR.="\e[4 q" " underline unblinking 120 | "let &t_SR.="\e[3 q" " underline blinking 121 | " Otherwise 122 | let &t_EI.="\e[2 q" " block unblinking 123 | "let &t_EI.="\e[1 q" " unblinking 124 | 125 | " vim supports modifyOtherKeys (dedicated section below) 126 | "cf https://vi.stackexchange.com/questions/27399/whats-t-te-and-t-ti-added-by-vim-8 127 | " but foot needs a workaround for a vim bug to jump between prompts 128 | "cf https://github.com/vim/vim/issues/9014 129 | "cf https://codeberg.org/dnkl/foot/wiki#vim 130 | " Vim thinks modifyOtherKeys level 2 is enabled, even when it's not 131 | " The snippets below ensure modifyOtherKeys=2 is enabled. 132 | if &term =~ "foot" 133 | let &t_TI = "\e[>4;2m" 134 | let &t_TE = "\e[>4;m" 135 | endif 136 | 137 | " ## SET THE TITLEBAR 138 | " Filename associated with the current edit buffer in the xterm title 139 | set title 140 | let &titlestring = expand("%:t") 141 | 142 | " #### BACKSPACE AND DELETE KEYS 143 | 144 | " ### DELETE 145 | " Make delete work by approximating the right sequence even without terminfo 146 | set t_kD=^[[3~ 147 | " ...except in VT100 mode where it's Ctrl-? 148 | if &term =~ "vt100" 149 | set t_kD= 150 | endif 151 | 152 | " ## SHIFT-DELETE 153 | " Shift-Delete deletes to the end of the line like Ctrl-K 154 | inoremap d$ 155 | noremap d$ 156 | " Shift-Delete in foot, wezterm and others 157 | inoremap [3;2~ d$ 158 | noremap [3;2~ d$ 159 | 160 | " ## ALT-DELETE 161 | " TODO: currently the same for Alt-Delete, change it? 162 | inoremap d$ 163 | noremap d$ 164 | " Alt-Delete in foot, wezterm and others 165 | inoremap [3;3~ d$ 166 | noremap [3;3~ d$ 167 | 168 | " ## CTRL-DELETE 169 | " Make Ctrl-Delete delete next word 170 | inoremap [3;5~ dw 171 | " outside insert mode, delete the entire word 172 | "noremap [3;5~ daw 173 | " or delete from the cursor position 174 | noremap [3;5~ dw 175 | " Same for the variant for tmux and urxvt 176 | inoremap [3M dw 177 | "noremap [3M daw 178 | noremap [3M dw 179 | inoremap [3^ dw 180 | "noremap [3^ daw 181 | noremap [3^ dw 182 | 183 | " ### BACKSPACE 184 | " Make backspace work by approximating the right sequence even without terminfo 185 | set t_kb= 186 | if &term =~ "vt100" 187 | " ...except in VT100 mode where it's Ctrl-H 188 | set t_kb= 189 | "else 190 | "" but otherwise Ctrl-H is Ctrl-Backspace 191 | "inoremap db 192 | "noremap bdw 193 | endif 194 | 195 | " Allow backspacing over everything in insert mode 196 | " When backspacing, do not stop at \n: go to previous line if necessary 197 | set backspace=indent,eol,start 198 | 199 | " ## SHIFT-BACKSPACE 200 | " Shift-Backspace deletes to the beginning of line like Ctrl-U 201 | inoremap d0 202 | noremap d0 203 | 204 | " ## ALT-BACKSPACE 205 | " TODO: currently the same for Alt-Backspace, change it? 206 | inoremap d0 207 | noremap d0 208 | " Alt-Backspace for wezterm 209 | inoremap d0 210 | noremap d0 211 | 212 | " ## CTRL-BACKSPACE 213 | " Ctrl-Backspace deletes previous word in insert mode. 214 | " Outside a VT100, gives either Ctrl-_ or Ctrl-H 215 | " To remain generic map both and + test for vt100 above to also cover 216 | inoremap db 217 | inoremap db 218 | " and in edit mode too 219 | noremap bdw 220 | noremap bdw 221 | " If this test doesn't work, see the modifyOtherKeys section below 222 | "nnoremap echomsg 'C-BS was hit' 223 | 224 | " #### MOKS, CONTROL KEYS AND SHORTCUTS 225 | 226 | " ### MOKS SEQUENCES 227 | " modifyOtherKeys allows to separate from , from è etc 228 | " and map shortcuts beyond C0 ie Ctrl-symbol with symbol outside @[\]^_space 229 | "cf https://invisible-island.net/xterm/modified-keys.html 230 | "cf https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyCursorKeys 231 | " can see the exact mok sequence with a log file like 232 | "rm /tmp/logfile && vim --cmd "call ch_logfile('/tmp/logfile', 'w')" && vim /tmp/logfile 233 | " cf https://groups.google.com/g/vim_dev/c/OwIDwziTHQ8 234 | 235 | " ## CTRL-BACKSPACE NEEDS A SPECIAL CASE TO BACKWARD WORD DELETE 236 | " Ctrl-Backspace with wezterm in vim: with Ctrl-Q Ctrl-Backspace vim sees ^H 237 | " but in the logfile, Ctrl-BS really generates the MOK: ^[[27;5;8~ 238 | " So this doesn't works: 239 | "nnoremap echomsg 'C-BS was hit' 240 | " While this works: 241 | "nnoremap [27;5;8~ echomsg 'C-BS was hit' 242 | " Not clear why C-BS doesn't work when C-; doesn't need the MOK: 243 | " This works even if Ctrl-; ^[[27;5;59~ on my wezterm: 244 | "nnoremap echomsg 'C-; was hit' 245 | " So start by a special case for remapping Ctrl-Backspace 246 | nnoremap [27;5;8~ bdw 247 | inoremap [27;5;8~ db 248 | " And don't fully trust the map of other shortcuts: test and document each MOK 249 | 250 | " ## CTRL-SLASH NEEDS A SPECIAL CASE TO DO COMPOSE LIKE CTRL-K 251 | 252 | " Remap the MOK for Ctrl-K to the Emacs-like kill to the EOL 253 | " Ctrl-k is [27;5;107~ 254 | "nnoremap [27;5;107~ D 255 | inoremap [27;5;107~ D 256 | " Can then map some other MOK to achieve Ctrl-K compose function: here Ctrl-/ 257 | " Ctrl-/ is [27;5;47~ 258 | "nnoremap [27;5;47~ 259 | inoremap [27;5;47~ 260 | 261 | " ## OTHERS ON A CASE-BY-CASE 262 | 263 | " Left available in C0: Ctrl-\, Ctrl-; 264 | " Ctrl-_ (maps to Ctrl-/), Ctrl-` (maps to Ctrl-@) 265 | " Ctrl-` mok is [27;5;96~ 266 | nnoremap [27;5;96~ echomsg 'C-@ was hit' 267 | " Ctrl-; mok is [27;5;59~ 268 | nnoremap [27;5;59~ echomsg 'C-; was hit' 269 | " Ctrl-' mok is [27;5;39~ but doesn't work 270 | nnoremap [27;5;39~ echomsg 'C-apostrophe was hit' 271 | " Ctrl-\ mok is [27;5;92~ 272 | nnoremap [27;5;92~ echomsg 'C-\ was hit' 273 | " Ctrl-/ mok is [27;5;47~ 274 | "nnoremap [27;5;47~ echomsg 'C-/ was hit' 275 | " Ctrl-/ was mapped to compose 276 | 277 | " ## SAVE CTRL- ORIGINAL FUNCTIONS BEFORE DEDUPED MAPPINGS 278 | 279 | " Keep Ctrl-I/Ctrl-O to jump between previous edit positions (:change ) 280 | " Ctrl-I is confused with Tab, while Tab in normal mode is helpful for indent 281 | "nnoremap [27;5;105~ echomsg 'C-I was hit' 282 | " This "saves" the function of C-I before adding a separate mapping to Tab 283 | "cf https://vi.stackexchange.com/questions/16161/how-to-map-c-i-separate-from-tab 284 | nnoremap 285 | 286 | " Ctrl-O is working normally 287 | "nnoremap [27;5;111~ echomsg 'C-O was hit' 288 | 289 | " ### SHORTCUTS 290 | 291 | " Allow cursor keys within insert mode by timeout, cf timeoutlen ttimeoutlen 292 | set esckeys 293 | 294 | " ## BASH/READLINE LIKE HOME/END WORD/LINE DELETE LEFT/RIGHT CTRL-AESWUK 295 | 296 | " Make Ctrl-A go to the beginning of the line (instead of default: increment) 297 | inoremap 298 | noremap 299 | 300 | " Make Ctrl-E go to the end of the line 301 | inoremap 302 | noremap 303 | 304 | " Make Ctrl-S delete the next word, typically Esc-D equivalent to Alt-D in bash 305 | inoremap dw 306 | noremap daw 307 | 308 | " Make Ctrl-W delete the previous work 309 | inoremap dB 310 | noremap bdw 311 | 312 | " Make Ctrl-K delete to the end of the line: D is a synonym of d$ 313 | " Vim default C-K was compose: remapping compose may need some MOK magic 314 | " Add the following to have Ctrl-K work in edit mode even without MOK support 315 | "inoremap D 316 | noremap D 317 | " Could also use backspace as a compose key for accents/8 bits chars/unicode 318 | "set digraph 319 | 320 | " Make Ctrl-U delete to the beginning of the line 321 | inoremap d0 322 | noremap d0 323 | " For Ctrl-K Ctrl-U killing a whole like, Ctrl-U should remove the cursor too 324 | "noremap ld0 325 | 326 | " Alternative to make Ctrl-K Ctrl-U clear the whole line 327 | set virtualedit=onemore 328 | " But may have a worse 'side effect": x won't delete past EOL to merge lines 329 | " TODO: should have a remap of the whole sequence like 330 | "remap D d0 x 331 | " but timings break the magic: the intermediate state of C-K will not be seen 332 | 333 | " WONTFIX: In Ctrl-K Ctrl-U, after Ctrl-K the cursor will end on (the left of) 334 | " the current character so the current character won't be deleted, unlike bash 335 | " This might be fixable by using c$ or C to go into insert mode but such a rare 336 | " case could disrupt normal function that is more often needed 337 | 338 | " ## WINDOWS-LIKE UNDO, REDO WITH CTRL-Z CTRL-Y 339 | 340 | " CTRL-Z is Undo; not in cmdline though 341 | noremap u 342 | inoremap u 343 | 344 | " CTRL-Y tries to be Redo (although not repeat); not in cmdline though 345 | " TODO: see how Ctrl-R does it to do the same (Ctrl-R is a better redo) 346 | noremap 347 | inoremap 348 | 349 | " ## WINDOWS-LIKE MOVE WITH CTRL+ARROWS 350 | 351 | " Ctrl-Left|Right are mapped by default 352 | " Ctrl-Home [1;5H is already defined by default 353 | " Likewise Ctrl-End [1;5F is already defined by default 354 | " If going to EOL instead of EOF is wanted, need settings like: 355 | "inoremap [1;5F 356 | "nnoremap [1;5F 357 | ""vnoremap [1;5F 358 | 359 | " On MacOS, when Terminal.app has Option key being a Meta key 360 | " Option-Left and Option-Right are mapped to the Emacs equivalents 361 | inoremap f 362 | nnoremap f 363 | inoremap b 364 | nnoremap b 365 | " Option-Up and Option-Down are not mapped 366 | 367 | " Ctrl-Up|Down jump to the beginning or end of the paragraph: 368 | " non repeatable version: 369 | "inoremap [1;5A {i 370 | "nnoremap [1;5A { 371 | "inoremap [1;5B }i 372 | "nnoremap [1;5B } 373 | " repeatable version: needs h to go back one char 374 | inoremap [1;5A {hi 375 | nnoremap [1;5A { 376 | inoremap [1;5B }i 377 | nnoremap [1;5B } 378 | 379 | " ## WINDOWS-LIKE SELECT WITH SHIFT+ARROWS 380 | 381 | inoremap vw 382 | nnoremap vw 383 | vnoremap w 384 | inoremap vb 385 | nnoremap vb 386 | vnoremap b 387 | inoremap v 388 | nnoremap v 389 | vnoremap 390 | inoremap v 391 | nnoremap v 392 | vnoremap 393 | 394 | " ## ECLIPSE-LIKE ALT+ARROW MOVES THE SELECTED LINES OR THE CURRENT LINE 395 | " in insert mode, just the current line, indented with == 396 | " gi moves to the last position and reenters insert mode 397 | inoremap :m .-2==gi 398 | inoremap :m .+1==gi 399 | " otherwise move full lines of the selection even if not extends to begin/EOL 400 | " "==" can be used to "fix" identation, then gv for reselect in visual 401 | nnoremap :m .-2== 402 | nnoremap :m .+1== 403 | vnoremap :m .-2==gv 404 | vnoremap :m '>+1==gv 405 | " this will move the whole word left and right 406 | " # FIXME: should includes commas (etc) and only consider spaces boundaries 407 | nnoremap bdwbP`[l 408 | nnoremap bdwwP`[l 409 | " eb instead of b necessary for right to repeat more than once 410 | inoremap ebdwbP`[li 411 | inoremap ebdwwP`[li 412 | " this will move just the selection if it exists 413 | "vnoremap dhPgvhoho 414 | "vnoremap dpgvlolo 415 | " # FIXME: trims following the selection, instead of rounding up to whole words 416 | vnoremap dbP`[v`] 417 | vnoremap dwhp`[v`] 418 | 419 | " ## NOTEPAD++ LIKE CTRL+SHIFT+ARROW MOVES THE SELECTED BLOCK 420 | " insert mode is useless: done by vnoremap 421 | " so just "duplicate" alt functionality if no selection 422 | inoremap :m .+1==gi 423 | inoremap :m .-2==gi 424 | " WARNING: wezterm remaps Ctrl+Shift+Up/Down for ActivatePaneDirection="Up|Down" 425 | "cf https://wezfurlong.org/wezterm/config/default-keys.html 426 | " Can avoid the errors on the first and last lines with MoveLineAndInsert() 427 | "cf https://superuser.com/questions/1434741/vim-move-selection-up-down-with-ctrlshiftarrow 428 | " if want to do only the full lines 429 | "nnoremap :m '<,'>-2== 430 | "nnoremap :m '<,'>+1== 431 | " here different from the above: cuts the selection out of the line 432 | " # FIXME: should keep the horizontal coordinate in case a line up or down is empty 433 | nnoremap :m '<-2== 434 | nnoremap :m '>+1== 435 | 436 | "" this UP works alone + in repetitions 437 | "vnoremap dkPV`] 438 | "" but this DOWN only works if prefixed by UP the 1st time 439 | "vnoremap dpV`] 440 | " better: 441 | " this will move the selection if it exists 442 | vnoremap dkP`[v`] 443 | vnoremap djP`[v`] 444 | " this will move the selection left and right if it exists 445 | vnoremap dhPgvhoho 446 | vnoremap dpgvlolo 447 | 448 | " ## SUSE METHOD TO MAP EDIT AND KEYMAP KEYS 449 | " Should keep it: wezterm home=OH end=OF as in the old xterm/kvt section 450 | 451 | " Defaults from suse to try and get the correct main terminal type and edit keyss 452 | if &term =~ "xterm" 453 | let myterm = "xterm" 454 | else 455 | let myterm = &term 456 | endif 457 | let myterm = substitute(myterm, "cons[0-9][0-9].*$", "linux", "") 458 | let myterm = substitute(myterm, "vt1[0-9][0-9].*$", "vt100", "") 459 | let myterm = substitute(myterm, "vt2[0-9][0-9].*$", "vt220", "") 460 | let myterm = substitute(myterm, "\\([^-]*\\)[_-].*$", "\\1", "") 461 | 462 | " Here we define the keys of the NumLock in keyboard transmit mode of xterm 463 | " which misses or hasn't activated Alt/NumLock Modifiers. Often not defined 464 | " within termcap/terminfo and we should map the character printed on the keys. 465 | if myterm == "xterm" || myterm == "kvt" || myterm == "gnome" 466 | " keys in insert/command mode. 467 | map! Oo : 468 | map! Oj * 469 | map! Om - 470 | map! Ok + 471 | map! Ol , 472 | map! OM 473 | map! Ow 7 474 | map! Ox 8 475 | map! Oy 9 476 | map! Ot 4 477 | map! Ou 5 478 | map! Ov 6 479 | map! Oq 1 480 | map! Or 2 481 | map! Os 3 482 | map! Op 0 483 | map! On . 484 | " keys in normal mode 485 | map Oo : 486 | map Oj * 487 | map Om - 488 | map Ok + 489 | map Ol , 490 | map OM 491 | map Ow 7 492 | map Ox 8 493 | map Oy 9 494 | map Ot 4 495 | map Ou 5 496 | map Ov 6 497 | map Oq 1 498 | map Or 2 499 | map Os 3 500 | map Op 0 501 | map On . 502 | endif 503 | 504 | " xterm but without activated keyboard transmit mode 505 | " and therefore not defined in termcap/terminfo. 506 | if myterm == "xterm" || myterm == "kvt" || myterm == "gnome" 507 | " keys in insert/command mode. 508 | map! [H 509 | map! [F 510 | " Home/End: older xterms 511 | map! [1~ 512 | map! [4~ 513 | " Up/Down/Right/Left 514 | map! [A 515 | map! [B 516 | map! [C 517 | map! [D 518 | " KP_5 (NumLock off) to Backspace 519 | "map! [E 520 | " KP_5 (NumLock off) to Insert 521 | map! [E 522 | " PageUp/PageDown 523 | map [5~ 524 | map [6~ 525 | map [5;2~ 526 | map [6;2~ 527 | map [5;5~ 528 | map [6;5~ 529 | " keys in normal mode 530 | map [H 0 531 | map [F $ 532 | " Home/End: older xterms 533 | map [1~ 0 534 | map [4~ $ 535 | " Up/Down/Right/Left 536 | map [A k 537 | map [B j 538 | map [C l 539 | map [D h 540 | " KP_5 (NumLock off) to Backspace 541 | "map [E d 542 | " KP_5 (NumLock off) to Insert 543 | map [E i 544 | " PageUp/PageDown 545 | map [5~  546 | map [6~  547 | map [5;2~  548 | map [6;2~  549 | map [5;5~  550 | map [6;5~  551 | endif 552 | 553 | " xterm/kvt but with activated keyboard transmit mode. 554 | " Sometimes not (or wronglr) defined within termcap/terminfo. 555 | if myterm == "xterm" || myterm == "kvt" || myterm == "gnome" 556 | " keys in insert/command mode. 557 | map! OH 558 | map! OF 559 | map! O2H 560 | map! O2F 561 | map! O5H 562 | map! O5F 563 | " Cursor keys which mostly work by default 564 | " map! OA 565 | " map! OB 566 | " map! OC 567 | " map! OD 568 | map! [2;2~ 569 | map! [2;5~ 570 | map! O2A 571 | map! O2B 572 | map! O2C 573 | map! O2D 574 | map! O5A 575 | map! O5B 576 | map! O5C 577 | map! O5D 578 | " KP_5 (NumLock off) to Backspace 579 | "map! OE 580 | " KP_5 (NumLock off) to Insert 581 | map! OE 582 | " keys in normal mode 583 | map OH 0 584 | map OF $ 585 | map O2H 0 586 | map O2F $ 587 | map O5H 0 588 | map O5F $ 589 | " Cursor keys which mostly work by default 590 | " map OA k 591 | " map OB j 592 | " map OD h 593 | " map OC l 594 | map [2;2~ i 595 | map [2;5~ i 596 | map O2A ^B 597 | map O2B ^F 598 | map O2D b 599 | map O2C w 600 | map O5A ^B 601 | map O5B ^F 602 | map O5D b 603 | map O5C w 604 | " KP_5 (with NumLock off) to Backspace 605 | " map OE d 606 | " KP_5 (with NumLock off) to Insert 607 | map OE i 608 | endif 609 | 610 | if myterm == "linux" 611 | " keys in insert/command mode. 612 | map! [G 613 | " KP_5 (NumLock off) 614 | " keys in normal mode 615 | " KP_5 (NumLock off) 616 | map [G i 617 | endif 618 | 619 | " ## MAKE Y, V, C AND D CONSISTENT IN COMMAND MODE 620 | 621 | " D and C delete and change from the cursor to EOL 622 | " so make Y do non recursively yank from the cursor to EOL 623 | nnoremap Y y$ 624 | 625 | " V does select the whole line: likewies, not very consistent 626 | " this make V do a selection until the EOL 627 | nnoremap V v$ 628 | " while vv preserves the original function of selecting the whole lin 629 | nnoremap vv V 630 | 631 | " ### FUNCTIONS 632 | 633 | " ## MOUSE-ENABLED VISUAL MODE 634 | " For terminal emulators with mouse support 635 | behave xterm 636 | set selectmode=mouse 637 | " Disable vim automatic visual mode on mouse select 638 | "set mouse-=a 639 | " or keep visual mode but copy without the line numbers 640 | set mouse=a 641 | " Shift-Insert works like in Xterm 642 | map 643 | map! 644 | " Hide the mouse pointer while typing 645 | set mousehide 646 | 647 | " ## SEARCH & REPLACE 648 | 649 | " Show matches while incrementially searching 650 | set incsearch 651 | " Hilight search strings 652 | set hlsearch 653 | " Ignore the case in search patterns, required for smartcase 654 | set ignorecase 655 | " Default to ignore case, can restore with /searchsomething\c 656 | set smartcase 657 | 658 | " ## TAB INDENTS, SHIFT-TAB UNINDENTS 659 | 660 | " Replace tab with softtabstop spaces for indentation (problematic for python) 661 | "set expandtab 662 | " Instead, do better: 663 | " Number of spaces added when indenting using >>, <<, == (etc): 664 | set shiftwidth=4 665 | " Number of spaces pressing on will add: 666 | set softtabstop=8 667 | " Number of columns a tab fills on the screen: 668 | "set tabstop=8 669 | " In insert mode, the Tab key function depends on the above: 670 | " at the beginning of the line, 1 tab=4 spaces, 2 tabs=1 tab char 671 | set smarttab 672 | "Keep indentation from previous line 673 | "set autoindent 674 | " Off since I usually prefer perltidy 675 | set noautoindent 676 | "Automatically indents new lines based on old lines 677 | set smartindent 678 | "Like smartindent, but stricter and more customisable yet breaks on urls 679 | "set cindent 680 | 681 | " Tab to indent and Shit-Tab to unindent 682 | nmap >>k 683 | nmap <<k 684 | vmap :'<,'>>> 685 | vmap :'<,'><< 686 | 687 | " ## COPY/CUT AND PASTE 688 | 689 | " Due to remap of Ctrl-c and Ctrl-v to copy/paste 690 | " can make Ctrl-q input chars like Ctrl-v did with: 691 | "noremap! 692 | " (but already setup by default, no need to redo it) 693 | 694 | " Use system clipboard to yank from other applications in gvim 695 | "set clipboard=unnamedplus 696 | set clipboard=unnamed 697 | 698 | " Paste from xterm by definining F28 and F29 699 | function! XTermPasteBegin(ret) 700 | set pastetoggle= 701 | set paste 702 | return a:ret 703 | endfunction 704 | 705 | execute "set =\[200~" 706 | execute "set =\[201~" 707 | map XTermPasteBegin("i") 708 | imap XTermPasteBegin("") 709 | vmap XTermPasteBegin("c") 710 | cmap 711 | cmap 712 | 713 | " # FIXME: add copy-paste for Xorg 714 | 715 | " CTRL-C does copy in visual mode only (can also do xnoremap) 716 | "vnoremap "+y 717 | " CTRL-X does cut in visual mode only 718 | ""vnoremap "+x 719 | " cut not to the default y/p buffer but to wl-copy 720 | "vnoremap :w !wl-copy 721 | " this can't work in range mode as :w doesn't support it 722 | "vnoremap :'<,'> w !wl-copy 723 | " silent version in line mode, without flashing enter 724 | "vnoremap :silent w !wl-copy 725 | " this requires pressing y first 726 | "vnoremap :call system("wl-copy", @") 727 | " so declare a function 728 | function! WLCopy() 729 | " Save the unnamed register and its type. 730 | let last_yank = getreg() 731 | " Copy the selection. 732 | execute "normal! y" 733 | " Send it as-is, without --trim-newline 734 | call system("wl-copy", @") 735 | endfunction 736 | function! WLCut() 737 | " Save the unnamed register and its type. 738 | let last_yank = getreg() 739 | " Copy the selection. 740 | execute "normal! d" 741 | call system("wl-copy", @") 742 | endfunction 743 | 744 | " Make Ctrl-C copy what's currently selected 745 | vnoremap call WLCopy() 746 | " Make Ctrl-X cut what's currently selected (instead of default decrement) 747 | vnoremap call WLCut() 748 | 749 | " CTRL-V does Paste from wl-paste automatically 750 | "nnoremap :r !wl-paste 751 | " so keep that for the console 752 | nnoremap P 753 | 754 | " Separate the terminal copy-paste from vim own 755 | "map "+gP 756 | "cmap + 757 | 758 | " Separate wayland cut-paste from vim: Ctrl-Insert paste and Shift-Delete cut 759 | vnoremap "+y 760 | "vnoremap call WLCut() 761 | vnoremap "+x 762 | 763 | " #### APPEARANCE AND INTERACTION 764 | 765 | " ## MAIN WINDOW LOOKS 766 | 767 | " Redraw the whole screen as needed, helps on android when not displaying 768 | "if match ($LD_PRELOAD, "com.termux") != 0 769 | set ttyfast 770 | "endif 771 | 772 | " No beeps 773 | set noerrorbells 774 | set visualbell 775 | set t_vb= 776 | 777 | " Show line numbers, disable with :se nu! 778 | set number 779 | 780 | " Show relative number for inactive lines 781 | set relativenumber 782 | 783 | " Hilight the current line (and the line numbers) 784 | set cursorline 785 | 786 | " Show matching parenthesis 787 | set showmatch 788 | 789 | " always keep 2 lines of context at the bottom of screen 790 | set scrolloff=2 791 | 792 | " Disable line warping 793 | set nowrapscan 794 | 795 | " Make the text wrap to the next line when it is X letters from the end 796 | "set wrapmargin=8 797 | 798 | " Always limit the width of text 799 | "set tw=72 800 | 801 | " ## EDITION 802 | 803 | " Insert two spaces after a period with every joining of lines 804 | "set joinspaces 805 | 806 | " Do not jump to first character with page commands 807 | set nostartofline 808 | 809 | " Moving left/right ignores the beginning/end of line to continue 810 | set whichwrap=<,>,h,l,[,] 811 | 812 | " Add the dash ('-'), the dot ('.'), and the '@' as "letters" to "words". 813 | set iskeyword=@,48-57,_,192-255,-,.,@-@ 814 | 815 | " Options for the "text format" command ("gq") 816 | " j will remove the comment leader when merging lines 817 | set formatoptions=cqrtoj 818 | 819 | " ## SHOW COMMENTS IN ITALICS 820 | 821 | " If Vim doesn't know the escape codes to switch to italic 822 | let &t_ZH="\e[3m" 823 | let &t_ZR="\e[23m" 824 | " Italics pseudo-auto toggle: force italics if we recognize it's supported from TERM 825 | if match($TERM, "xterm-256color-italic")==0 826 | highlight Comment cterm=italic 827 | " For Windows-Terminal which supports italic, nothing is needed anymore even if not in TERM 828 | "elseif match($TERM, "xterm-256color")==0 829 | " highlight Comment cterm=italic gui=italic 830 | elseif match($TERM, "tmux-sixel")==0 831 | highlight Comment cterm=italic 832 | elseif match($TERM, "mintty")==0 833 | highlight Comment cterm=italic 834 | endif 835 | 836 | " ### AT THE TOP OF THE SCREEN: TABLINE 837 | 838 | " Show on the left the timestamp + encoding, on the right the positions and format 839 | "%{len(getbufinfo({'buflisted': 1}))}:%a 840 | set tabline=%{g:gitbranch}%t%a\ %{FileData()}\ \%{&fenc==\"\"?&enc:&fenc}(%{&bomb})\ %{&ff==\"dos\"?\"CRLF\":\"LF\"}%=%{mode()}\ @(x:%03c/%03{virtcol('$')},y:%04l/%0L)\ =0x%02B\ @%08O\ %P 841 | " Show the tabline; can hide it with: :set showtabline=0 842 | set showtabline=2 843 | " The tabline need an autocommand to be dynamic 844 | if has("autocmd") 845 | autocmd CursorMoved * :redrawtabline 846 | " redraw it in insert mode too 847 | autocmd CursorMovedI * redrawtabline 848 | endif 849 | 850 | " ## GET INFORMATION ABOUT THE FILE FOR THE TABLINE 851 | " Function to show the file name, creation date and git branch 852 | function! FileData() 853 | " get the epoch 854 | let ftime=getftime(expand("%")) 855 | if ftime>0 856 | let msg=strftime("@%Y-%m-%d %H:%M:%S",ftime) 857 | else " if ftime 858 | " epoch<0 means the file doesn't exist 859 | let msg="(UNSAVED NEW FILE)" 860 | endif " if ftime 861 | return msg 862 | endfunction 863 | 864 | " ## READ THE GIT DATA MANUALLY 865 | " Function to read git data manually directly (not recursive like gitbranch) 866 | " TODO: consider making it recursive? 867 | function! GetGitBranch() 868 | let fpath=expand("%:p:h") 869 | if filereadable(fpath . '/.git/HEAD') 870 | " silent! 871 | let branch = get(readfile(fpath . '/.git/HEAD'), 0, '') 872 | if branch =~# '^ref: ' 873 | let branchname= substitute(branch, '^ref: \%(refs/\%(heads/\|remotes/\|tags/\)\=\)\=', '', '') 874 | elseif branch =~# '^\x\{20\}' 875 | let branchname= branch[:6] 876 | endif " if branch 877 | if (strlen(branchname)>0) 878 | return "⎇ " . branchname . ":" 879 | endif " if strlen 880 | endif " if filereadable 881 | " Default to an empty string instead of the integer 0 882 | return "" 883 | endfunction 884 | 885 | " ## BUT READ THE GIT INFO JUST ONCE WHEN ENTERING THE BUFFER 886 | " Call this function when entering a buffer to set a global variable 887 | if has("autocmd") 888 | autocmd BufEnter * let g:gitbranch=GetGitBranch() 889 | endif 890 | 891 | " ### AT THE BOTTOM OF THE SCREEN: MINIMAL COMMANDLINE (NO STATUSLINE) 892 | 893 | " Statusline with colors and display of options 894 | " at the bottom of the screen? 895 | "set statusline=%{FileData()}\ %{&fenc==\"\"?&enc:&fenc},%{&bomb}\%a%=\ %8l,%c%V/%L\ %{&ff==\"dos\"?\"CRLF\":\"LF\"}\ %P\ %08O:%02B 896 | 897 | " Make command line two lines high 898 | " set ch=2 899 | " Always show status line, even for only one buffer. 900 | "set laststatus=2 901 | " Don't show anything and hide the line too 902 | set laststatus=0 903 | " Don't show the position of the cursor already show in the tabline 904 | set noruler 905 | "set ruler 906 | " Don't show the mode either 907 | set noshowmode 908 | "set showmode 909 | " Don't show the current uncompleted command either 910 | set noshowcmd 911 | "set showcmd 912 | 913 | " Don't use the included file as a source of autocomplete 914 | set complete-=i 915 | " can still use k for 1 or more dictionary files 916 | "set complete+=k 917 | " Manually curated list of plain text words that are considered valid 918 | set dictionary=$HOME."/.vim/words" 919 | " Completed by a hash file: use zg to add a word, zw to remove a word 920 | " Should install aspell, can specify en_US or en_GB instead of en.multi 921 | "set spellfile=/usr/lib/aspell-0.60/en.multi,/usr/lib/aspell-0.60/es.multi 922 | 923 | " Can still use t for tags generated by cscope or exuberant ctags 924 | "set complete+=t 925 | 926 | " Don't suppose numbers starting with 0 are octal: treat them as decimal 927 | " otherwise 07 Ctrl-A (if mapped to increment) because 10 928 | set nrformats-=octal 929 | 930 | " Show commandline completion 931 | set wildmenu 932 | 933 | " Complete longest common string, then each full match like bash 934 | "set wildmode=longest,full 935 | 936 | " Hilight : 8b,db,es,hs,mb,Mn,nu,rs,sr,tb,vr,ws 937 | "set highlight=8r,db,es,hs,mb,Mr,nu,rs,sr,tb,vr,ws 938 | 939 | " Use magic patterns (extended regular expressions) 940 | set magic 941 | 942 | " The char used for "expansion" on the command line 943 | set wildchar= 944 | 945 | " ### LIGHT OR DARK MODE 946 | 947 | " ## CHOSE THE DEFAULT MODE BASED ON $TERM 948 | " Leave the background and style autodetects on 949 | if has('gui_running') 950 | set background=dark 951 | let g:solarized_style="dark" 952 | " set guifont=Menlo\ Regular:h24 953 | set guifont=Monospace\ 13 954 | else 955 | " for solarized, 256 color is better than nothing (ex: xterm-256color) 956 | " and avoids tweaking with the standard colors assignations 957 | " but worse than replacing the palette + can kill italics/bold/underline 958 | if match($TERM, "rxvt-unicode-256color")==0 959 | set background=dark 960 | " set background=light 961 | " let g:solarized_style="light" 962 | " Tweakings are required on Linux, but are better than 256 color fallback 963 | " let g:solarized_termcolors=256 964 | let g:solarized_termtrans = 1 965 | let g:solarized_termcolors=16 966 | elseif match($TERM, "rxvt-unicode")==0 967 | " set background=light 968 | set background=dark 969 | " let g:solarized_style="light" 970 | let g:solarized_termcolors=16 971 | elseif match($TERM, "xterm-256color-italic")==0 972 | " if used with mintty, need tweaking as the 256 colors fallback looks better 973 | set background=light 974 | let g:solarized_style="light" 975 | let g:solarized_termcolors=256 976 | " Using 256 colors kills italics without that 977 | let g:solarized_italic=1 978 | let g:solarized_bold=1 979 | let g:solarized_underline=1 980 | " when showing EOL with :set list 981 | let g:solarized_visibility="low" 982 | let g:solarized_hitrail=0 983 | elseif match($TERM, "xterm-256color")==0 984 | " This is the new TERM for Windows-Terminal 985 | " No tweakings required except the 256 color fallback to looks better: 986 | " it now answers to xterm send sequence attributes (send secondary DA) 987 | " https://github.com/microsoft/terminal/issues/5836 988 | " May also extend to vt240 extras with sixel support, cf current status 989 | " https://terminalnuget.blob.core.windows.net/packages/TerminalSequences.html 990 | " FIXME: should read current theme 991 | " ideally from a variable like https://github.com/microsoft/terminal/issues/4566 992 | " or using Get-WTTheme with PSWinTerminal.psd1 993 | set background=dark 994 | let g:solarized_style="dark" 995 | " set background=dark 996 | " let g:solarized_style="dark" 997 | let g:solarized_termcolors=256 998 | " when showing EOL with :set list 999 | let g:solarized_visibility="low" 1000 | let g:solarized_hitrail=1 1001 | elseif match($TERM, "xterm")==0 1002 | " This is a wildcard match for xterm* 1003 | set background=dark 1004 | let g:solarized_style="dark" 1005 | let g:solarized_termtrans = 1 1006 | let g:solarized_termcolors=16 1007 | elseif match($TERM, "screen")==0 1008 | " This is for GNU screen 1009 | let g:solarized_termtrans = 1 1010 | let g:solarized_termcolors=16 1011 | set background=dark 1012 | elseif match($TERM, "sixel-tmux")==0 1013 | " This is for sixel-tmux (with sixel derasterize) 1014 | set background=light 1015 | let g:solarized_style="light" 1016 | let g:solarized_termcolors=256 1017 | let g:solarized_italic=1 1018 | let g:solarized_underline=1 1019 | let g:solarized_visibility="low" 1020 | let g:solarized_hitrail=1 1021 | elseif match($TERM, "mintty")==0 1022 | " This is mintty default 1023 | set background=light 1024 | let g:solarized_style="light" 1025 | let g:solarized_termcolors=256 1026 | let g:solarized_bold=1 1027 | let g:solarized_underline=1 1028 | let g:solarized_visibility="low" 1029 | let g:solarized_hitrail=1 1030 | elseif match($TERM, "cygwin")==0 1031 | " This was the old TERM for Windows-Terminal 1032 | set background=dark 1033 | let g:solarized_style="dark" 1034 | let g:solarized_termcolors=16 1035 | let g:solarized_bold=1 1036 | let g:solarized_underline=1 1037 | let g:solarized_visibility="low" 1038 | let g:solarized_hitrail=1 1039 | elseif match($TERM, "foot")==0 1040 | " This is for the foot terminal 1041 | set background=light 1042 | let g:solarized_style="lightdark" 1043 | let g:solarized_termcolors=256 1044 | let g:solarized_bold=1 1045 | let g:solarized_underline=1 1046 | let g:solarized_visibility="low" 1047 | let g:solarized_hitrail=1 1048 | endif " if match $TERM 1049 | endif " if has('guirunning 1050 | 1051 | " ## OVERRIDE THE DEFAULT MODE WITH OTHER ENVIRONMENT VARIABLES 1052 | "if match ($WEZTERM_CONFIG_FILE, "/home/$USER/.config/wezterm/wezterm.lua")==0 1053 | " set background=dark 1054 | " let g:solarized_style="dark" 1055 | " let g:solarized_termcolors=256 1056 | " " when showing EOL with :set list 1057 | " let g:solarized_visibility="low" 1058 | " let g:solarized_hitrail=1 1059 | " set t_ti= 1060 | " set t_te= 1061 | "endif 1062 | " Can override the default color by WT profile UUID 1063 | if match ($WT_PROFILE_ID, "{b9261ded-f302-4538-889e-665aef724946}")==0 1064 | set background=light 1065 | let g:solarized_style="light" 1066 | let g:solarized_termcolors=256 1067 | " when showing EOL with :set list 1068 | let g:solarized_visibility="low" 1069 | let g:solarized_hitrail=1 1070 | set t_ti= 1071 | set t_te= 1072 | endif 1073 | if match ($WT_PROFILE_ID, "{2c4de342-38b7-51cf-b940-2309a097f518}")==0 1074 | set background=dark 1075 | let g:solarized_style="dark" 1076 | let g:solarized_termcolors=256 1077 | " when showing EOL with :set list 1078 | let g:solarized_visibility="low" 1079 | let g:solarized_hitrail=1 1080 | "set t_ti= 1081 | "set t_te= 1082 | endif 1083 | 1084 | " ### COLOR SETTINGS AND FUNCTIONS 1085 | 1086 | if has("terminfo") 1087 | " set t_Co=8 1088 | set t_Sf=[3%p1%dm 1089 | set t_Sb=[4%p1%dm 1090 | else 1091 | " set t_Co=8 1092 | set t_Sf=[3%dm 1093 | set t_Sb=[4%dm 1094 | endif 1095 | 1096 | " Color interacts with set nolist matching below 1097 | if &t_Co > 1 1098 | syntax on 1099 | endif 1100 | 1101 | " ## FUNCTION TO HIGHLIGHT CSV FILES 1102 | 1103 | " Hilight the nths column in csv text, 0=switch off 1104 | function! CSVHighlight(colnr) 1105 | if a:colnr > 1 1106 | let n = a:colnr - 1 1107 | execute 'match Keyword /^\([^,]*,\)\{'.n.'}\zs[^,]*/' 1108 | execute 'normal! 0'.n.'f,' 1109 | elseif a:colnr == 1 1110 | match Keyword /^[^,]*/ 1111 | normal! 0 1112 | else 1113 | match 1114 | endif " if a:colnr 1115 | endfunction 1116 | command! -nargs=1 CsvHighlight :call CSVHighlight() 1117 | 1118 | " ## FUNCTION TO CREATE A 'RAINBOW' INDENT (COLORED ONLY IN LIGHT MODE) 1119 | 1120 | " use 256-colors.sh to pick, here we have shades of black + the usual rainbow 1121 | if !exists("g:rainbow_colors_black") 1122 | let g:rainbow_colors_black= [ 234, 235, 236, 237, 238, 239 ] 1123 | endif 1124 | if !exists("g:rainbow_colors_color") 1125 | let g:rainbow_colors_color= [226, 192, 195, 189, 225, 221] 1126 | endif 1127 | 1128 | " use one of these unless specified otherwise 1129 | function! Rainbow_Enable() abort 1130 | if !exists("w:ms") 1131 | let w:ms=[] 1132 | endif 1133 | let g:rainbow_colors = ( &background == "dark"? g:rainbow_colors_black : g:rainbow_colors_color ) 1134 | if len(w:ms) == 0 1135 | let groups = [] 1136 | for color in g:rainbow_colors 1137 | let group = "colorgroup_".color 1138 | execute "hi ".group." ctermbg=".color 1139 | call add(groups, group) 1140 | endfor 1141 | let level = 0 1142 | let maxlevel = 40 1143 | let tab_pat = "\\zs\t\\ze" 1144 | let tab_seq = "" 1145 | let spc_in_tab = "" 1146 | let spc_left = &tabstop 1147 | while spc_left > 0 1148 | let spc_in_tab = spc_in_tab . " " 1149 | let spc_left = spc_left - 1 1150 | endwhile 1151 | let spc_pat = "\\zs" . spc_in_tab . "\\ze" 1152 | let spc_seq = "" 1153 | while level <= maxlevel 1154 | let gridx = level % len(groups) 1155 | " echom s:grs[gridx] . " ^" . tabseq . pat 1156 | let mtab = matchadd( groups[gridx] , "^" . tab_seq . tab_pat ) 1157 | call add(w:ms, mtab) 1158 | let mspc = matchadd( groups[gridx] , "^" . spc_seq . spc_pat ) 1159 | call add(w:ms, mspc) 1160 | let tab_seq = tab_seq . "\t" 1161 | let spc_seq = spc_seq . spc_in_tab 1162 | let level = level + 1 1163 | endwhile 1164 | endif 1165 | endfunction 1166 | 1167 | function! Rainbow_Disable() abort 1168 | if !exists("w:ms") 1169 | let w:ms=[] 1170 | endif 1171 | if len(w:ms) != 0 1172 | for m in w:ms 1173 | call matchdelete(m) 1174 | endfor 1175 | let w:ms = [] 1176 | endif 1177 | endfunction 1178 | 1179 | function! Rainbow_Toggle() abort 1180 | if !exists("w:ms") 1181 | let w:ms=[] 1182 | endif 1183 | if len(w:ms) == 0 1184 | call Rainbow_Enable() 1185 | else 1186 | call Rainbow_Disable() 1187 | endif 1188 | endfunction 1189 | 1190 | " ## FUNCTIONS TO ALTER THE COLOR SCHEME 1191 | 1192 | " on OLED screens, replace the ugly darkgrey with pitchblack 1193 | function! OLED_Black() 1194 | " override the grey of solarized dark to OLED black with: 1195 | if match (&background, "dark")==0 1196 | hi Normal ctermbg=16 1197 | hi LineNr ctermbg=16 1198 | hi CursorLine ctermbg=16 1199 | hi TabLineFill ctermbg=16 ctermfg=244 1200 | " and use a very visible color for mouse selection 1201 | hi Visual ctermbg=9 1202 | else 1203 | set background=light 1204 | let g:solarized_style="light" 1205 | " let g:solarized_termcolors=256 1206 | " Using 256 colors kills italics without the following: 1207 | let g:solarized_italic=1 1208 | let g:solarized_bold=1 1209 | let g:solarized_underline=1 1210 | " let g:solarized_visibility="high" 1211 | let g:solarized_hitrail=1 1212 | endif " if match (&background 1213 | endfunction 1214 | 1215 | " Start with the rainbow and OLED black 1216 | if has("autocmd") 1217 | autocmd ColorScheme * call OLED_Black() 1218 | autocmd ColorScheme * call Rainbow_Enable() 1219 | endif 1220 | 1221 | " ## FUNCTIONS TO HILIGHTS CHARACTERS 1222 | 1223 | " Show space errors and hilight invisible characters 1224 | function! Hilight_HiddenChars_Syntax() 1225 | " supports: ada, c, chill, csc, forth, groovy, icon, java, lpc, mel, nqc, nroff, ora, pascal, plm, plsql, python and ruby 1226 | let c_space_errors = 1 1227 | let python_space_errors = 1 1228 | 1229 | " WARNING: SpecialKey highlighting overrules syntax highlighting 1230 | " So if not using syntax, can better show hidden characters using different colors: 1231 | " this is a tab a space a tab then h: h 1232 | " this is a tab a space a tab: 1233 | " this is a tab: 1234 | " this is a trailing space: 1235 | " this is a control-F:  1236 | " this is a control-F then space an control-M:  1237 | 1238 | syn match TabChar /\t/ containedin=ALL 1239 | syn match TrailingSpaceChar " *$" containedin=ALL 1240 | syn match NonBreakingSpaceChar "\%u00a0" containedin=ALL 1241 | syn match ExtraWhitespace / \+\ze\t/ containedin=ALL 1242 | " syn match NonPrintableASCII /[^\x00-\x7F]/ containedin=ALL 1243 | syn match NonPrintableASCII /[\x0C\x0E-\x1F\x7F-\x9F]/ containedin=ALL 1244 | syn match ControlChars /[\x00-\x08]/ containedin=ALL 1245 | syn match ControlChars /[\x00-\x08]/ containedin=ALL 1246 | endfunction 1247 | 1248 | function! Hilight_HiddenChars_Color() 1249 | if match(&background,"light") ==0 1250 | highlight TabChar ctermbg=grey guibg=grey 1251 | highlight TrailingSpaceChar ctermbg=grey guibg=grey 1252 | else 1253 | highlight TabChar ctermbg=8 guibg=grey 1254 | highlight TrailingSpaceChar ctermbg=8 guibg=grey 1255 | endif 1256 | highlight NonBreakingSpaceChar ctermbg=red guibg=red 1257 | highlight ExtraWhitespace ctermbg=red guibg=red 1258 | highlight NonPrintableASCII ctermbg=red guibg=red 1259 | highlight ControlChars ctermbg=blue guibg=blue 1260 | highlight ControlChars ctermbg=blue guibg=blue 1261 | endfunction 1262 | 1263 | " Automatically call these functions with autocmd 1264 | " (when toggling syntax with `:syntax off` or changing colors with :colorscheme) 1265 | if has("autocmd") 1266 | autocmd Syntax * call Hilight_HiddenChars_Syntax() 1267 | autocmd ColorScheme * call Hilight_HiddenChars_Color() 1268 | endif 1269 | 1270 | " Avoid performance issue due to memory leaks as BufWinEnter commands are executed every time a buffer is displayed 1271 | " ie whenever loading files 1272 | if version >= 702 1273 | autocmd BufWinLeave * call clearmatches() 1274 | endif 1275 | 1276 | " ## F8 SHORTCUT TO TOGGLE LISTCHARS 1277 | 1278 | " Default is off, `se list` to turn on and `se nolist` to turn off 1279 | " Traditional: 1280 | "set listchars=tab:»·space:_,trail:·,eol:¶ 1281 | " Or cute with unicodes: 1282 | set listchars=tab:↹⇥,space:_,nbsp:␣,trail:•,extends:⟩,precedes:⟨,eol:↲ 1283 | set showbreak=↪ 1284 | inoremap :set list! 1285 | noremap :set list! 1286 | 1287 | " ## F9 SHORTCUT TO TOGGLE COLOR SCHEME 1288 | 1289 | " Apply one of the packed default colorschemes at startup 1290 | "colorscheme slate 1291 | "colorscheme desert 1292 | "colorscheme wildcharm 1293 | "colorscheme habamax 1294 | " Or use the packed solarized color scheme 1295 | colorscheme solarized 1296 | 1297 | function! Cycle_Colorscheme() 1298 | if (strlen(g:colors_name)>0) 1299 | if g:colors_name== "habamax" 1300 | " set background=light 1301 | " let g:solarized_style="light" 1302 | set background=dark 1303 | let g:solarized_style="dark" 1304 | " let g:solarized_termcolors=256 1305 | " Using 256 colors kills italics without the following: 1306 | let g:solarized_italic=1 1307 | let g:solarized_bold=1 1308 | let g:solarized_underline=1 1309 | " let g:solarized_visibility="high" 1310 | " let g:solarized_visibility="low" 1311 | " let g:solarized_hitrail=1 1312 | colorscheme solarized 1313 | elseif g:colors_name== "solarized" 1314 | set background=light 1315 | colorscheme quiet 1316 | syntax on 1317 | call Hilight_HiddenChars_Syntax() 1318 | call Hilight_HiddenChars_Color() 1319 | " elseif g:colors_name== "solarized" 1320 | else 1321 | set background=dark 1322 | colorscheme habamax 1323 | syntax on 1324 | call Hilight_HiddenChars_Syntax() 1325 | call Hilight_HiddenChars_Color() 1326 | endif " if g:colors_name 1327 | endif " if strlen 1328 | endfunction 1329 | 1330 | " Hotkey to cycle through themes 1331 | inoremap :call Cycle_Colorscheme() 1332 | noremap :call Cycle_Colorscheme() 1333 | 1334 | " ## F10 SHORTCUT TO TOGGLE RAINBOW INDENT 1335 | inoremap :call Rainbow_Toggle() 1336 | noremap :call Rainbow_Toggle() 1337 | 1338 | " #### INSERT MODE SHORTCUTS 1339 | 1340 | " ### ABBREVIATIONS AS Y 1341 | 1342 | " Yruler : A "ruler" - nice for counting the length of words 1343 | iab Yruler 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 1344 | 1345 | " Date 1346 | iab Ydate =strftime("%Y-%m-%d %H:%M") 1347 | 1348 | " ### FUNCTIONS AS , 1349 | 1350 | " ,cel = "clear empty lines", but don't delete the lines 1351 | " delete the *contents* of all lines which contain only whitespace. 1352 | map ,cel :%s/^\s\+$// 1353 | 1354 | " ,del = "delete 'empty' lines", don't don't delete empty lines 1355 | " delete all lines which contain only whitespace 1356 | map ,del :g/^\s\+$/d 1357 | 1358 | " ,ksr = "kill space runs" to substitute >2 spaces by just 1 space 1359 | nmap ,ksr :%s/ \+/ /g 1360 | vmap ,ksr :s/ \+/ /g 1361 | 1362 | " ,Sel = "squeeze empty lines" to merge multiple purely empty lines in just 1 1363 | map ,Sel :g/^$/,/./-j 1364 | 1365 | " ,Sbl = "squeeze blank lines" to merge empty lines (with spaces) into just 1 1366 | map ,Sbl :g/^\s*$/,/\S/-j 1367 | 1368 | 1369 | " ## DEFAULTS BY FILETYPE 1370 | 1371 | augroup python 1372 | au! 1373 | autocmd BufNewFile,BufReadPre,FileReadPre *.py set tabstop=4 1374 | autocmd BufNewFile,BufReadPre,FileReadPre *.py set softtabstop=4 1375 | autocmd BufNewFile,BufReadPre,FileReadPre *.py set shiftwidth=4 1376 | autocmd BufNewFile,BufReadPre,FileReadPre *.py set expandtab 1377 | autocmd BufNewFile,BufReadPre,FileReadPre *.py set autoindent 1378 | autocmd BufNewFile,BufReadPre,FileReadPre *.py set autoindent 1379 | autocmd BufNewFile,BufReadPre,FileReadPre *.py set fileformat=unix 1380 | " Not doing set textwidth=79 1381 | " autocmd WinEnter,VimEnter *.py :call rainbow#enable() 1382 | augroup END 1383 | 1384 | augroup gzip 1385 | au! 1386 | autocmd BufReadPre,FileReadPre *.gz set bin 1387 | autocmd BufReadPost,FileReadPost *.gz '[,']!gunzip 1388 | autocmd BufReadPost,FileReadPost *.gz set nobin 1389 | autocmd BufReadPost,FileReadPost *.gz execute ":doautocmd BufReadPost " . expand("%:r") 1390 | " autocmd BufWritePost,FileWritePost *.gz !mv :r 1391 | " autocmd BufWritePost,FileWritePost *.gz !gzip :r 1392 | autocmd FileAppendPre *.gz !gunzip 1393 | autocmd FileAppendPre *.gz !mv :r 1394 | autocmd FileAppendPost *.gz !mv :r 1395 | autocmd FileAppendPost *.gz !gzip :r 1396 | augroup END 1397 | 1398 | augroup bzip 1399 | au! 1400 | autocmd BufReadPre,FileReadPre *.bz2 set bin 1401 | autocmd BufReadPost,FileReadPost *.bz2 '[,']!bunzip2 1402 | autocmd BufReadPost,FileReadPost *.bz2 set nobin 1403 | autocmd BufReadPost,FileReadPost *.bz2 execute ":doautocmd BufReadPost " . expand("%:r") 1404 | autocmd BufWritePost,FileWritePost *.bz2 !mv :r 1405 | autocmd BufWritePost,FileWritePost *.bz2 !bzip2 :r 1406 | autocmd FileAppendPre *.bz2 !bunzip2 1407 | autocmd FileAppendPre *.bz2 !mv :r 1408 | autocmd FileAppendPost *.bz2 !mv :r 1409 | autocmd FileAppendPost *.bz2 !bzip2 :r 1410 | augroup END 1411 | 1412 | augroup html 1413 | " autocmd BufWritePost *.html :!firefox -remote "reload()" 1414 | autocmd BufEnter *.html :noremap :!firefox -remote "openURL(file:%)"^M^M 1415 | autocmd BufEnter *.html :inoremap ^[^[:!firefox -remote "openURL(file:%)"^M^Ma 1416 | " autocmd BufWritePost *.css :!firefox -remote "reload()" 1417 | autocmd BufEnter *.css :noremap :!firefox -remote "reload()"^M^M 1418 | autocmd BufEnter *.css :inoremap ^[^[:!firefox -remote "reload()"^M^Ma 1419 | 1420 | augroup END 1421 | 1422 | augroup cprog 1423 | au! 1424 | " autocmd BufRead * set formatoptions=tcql nocindent comments& 1425 | autocmd BufRead *.c,*.h set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,:// 1426 | augroup END 1427 | 1428 | endif " has("autocmd") 1429 | --------------------------------------------------------------------------------