Today I Learned



Favorite colorschemes





After installing the python-coc make sure you run: CocCommand <CR> and select python.setInterpreter

Xdebug with Vim and Docker

mandatory settings:

in the vdebug.vim

in the xdebug.ini

  1. Settings for vdebug.vim:

     let g:vdebug_options = {
         \ "continuous_mode" : 0,
         \ "port" : 10000,
         \ "server" : '',
         \ "timeout" : 20,
         \ "on_close" : 'detach',
         \ "break_on_open" : 0,
         \ "ide_key" : '',
         \ "debug_window_level" : 0,
         \ "debug_file_level" : 0,
         \ "debug_file" : "~/vdebug.log",
         \ "watch_window_style" : 'expanded',
         \ "marker_default" : '⬦',
         \ "marker_closed_tree" : '▸',
         \ "marker_open_tree" : '▾',
         \ "path_maps" : {'/var/www/html': '/home/marius/Templates/FSPlaza/FSPlaza'}
         \ }
  2. Settings in xdebug.ini:

     xdebug.remote_enable = 1
     xdebug.remote_autostart = 1
     ;remote_host IP is your local machine IP, the one running vim
     xdebug.remote_host =
     ;xdebug.remote_connect_back = 1
     xdebug.idekey = PHPDOCKER
     xdebug.remote_log = /var/log/xdebug_remote.log

What does not work:

Close all other

Close all other windows/splits



Close all other tabs :tabonly

Zoom on one window

If in vertical split mode: Ctrl+w | If in horizontal split mode: Ctrl+w _ Reload the initial split structure: Ctrl+w =

Spellcheck in vim

While on a misspelled word use z= to list all variations. If you want to bring up only the dictionary omnicomplete do a <C-x><C-k>.

Running selected code

Beacause the ! is actually a pipe, we can visually select a block of code phpinfo(); and then, in ex mode, run the command: :'<,'>!php -a or with sqlite3:

    f1 [varchar](varchar)(30) primary key,
    f2 text,
    f3 real

and then, in ex mode, run the command: :'<,'>!sqlite3 nameof.db and will create the table inside sqlite db.


Open a file and go to specific line

$ nvim +10 or if you already are inside vim: :e +10



The command for Insert mode abbreviations looks like this:

:iabbrev [<expr>] [<buffer>] {abbreviation} {expansion}

    <expr> - stands for Vimscript expression to create the expansion.
    <buffer> - means that it only applies to the current buffer.
    {abbreviation} - is the thing you type, or your “trigger”
    {expansion} - is your final outcome

Anything that’s inside a [] is optional.

Run this command in your Vim: :iabbrev teh the. Now enter the Insert mode and type teh end. As soon as you hit Space after typing the teh, Vim will replace it with the. Of course, you can store all of your abbreviations in your .vimrc file. Other examples

iabbrev @@
iabbrev <expr> ddd strftime('%c')
iabbrev cc /*<CR><CR>/<Up>

Let’s say we want to make one abbreviation for printing a string in Python and Java.

autocmd Filetype python :iabbrev ppp print("");<left><left><left>
autocmd FileType java :iabbrev ppp System.out.println("");<left><left><left>



Common git tasks

:Gwrite - git add current file :Gread - git checkout current file (revert to last checked in version) :Gmove - git move/rename the current file

Merge conflicts with Gdiff

(master)$ git merge feature

target(HEAD/master) working copy merge (feature)
builds: builds: builds:
main: main: main:
env: env: env:
———- -SOMEENV=true ——-
——– ===== —–
—– -CGO_ENABLED=0 ——
—- -OTHERNEV=off —-
—– »»>master —–
binary: fed binary: fed binary: fed

TIP: The arrows of the diff syntax point to the specific window of the split («<HEAD left window (//2), »>master right window(//3))

:diffget 2 fetch hunk from the target parent (left) :diffget 3 fetch hunk from the merge parent (right) :Gwrite! write/stage the current file to the index

Or use :diffput and put the hunk from the current window (target/merge) to the working copy. Using it like this, the :diffput command requiers no argument, so the shorthand :dp command can be used.

Tip in a 2-way diff, the diffget command require no argument so the shorthand :do command can be used.

[c jump to previous hunk ]c jump to nex hunk src

Automated file templates

autocmd BufNewFile 0r ~/skeletons/
autocmd BufNewFile *.sh 0r ~/skeletons/

The path

To add directories to path just use :set path= Common cases: set path=.,** - add current file and all directories relative to current working directory set path=.,app/** - add current file and all children relative to ./app folder