Skip to content

Instantly share code, notes, and snippets.

View dojoteef's full-sized avatar

Nader Akoury dojoteef

View GitHub Profile
@dojoteef
dojoteef / softwrap.kak
Last active September 14, 2023 17:31
Enable softwrap in kakoune and fix associated movement issues
# Softwrap long lines (and correct for improper kakoune movement behavior)
add-highlighter global/softwrap wrap -word -indent
define-command goto-center -docstring 'Jump to the center of the view' %{
execute-keys %sh{
echo $kak_window_range $kak_cursor_line | (
read y x h w l
num_lines=$((l-y-(h+1)/2))
if [ $num_lines -lt 0 ]; then
echo "${num_lines##-}j"
elif [ $num_lines -gt 0 ]; then
@dojoteef
dojoteef / vimtab.kak
Last active April 8, 2022 02:08
Replicate Vim's expandtab and softtabstop behavior in kakoune
# Replicate expandtab from vim.
declare-option -docstring "Expand <tab> to spaces based on tabstop." bool expandtab yes
# Replicate softtabstop from vim.
declare-option -docstring "Make tabstop number of spaces feel like a <tab> when pressing <tab> or <backspace> in insert mode." int softtabstop 4
# Helper function for inserting a <tab>
def softtabstop-insert-tab -hidden %{
evaluate-commands -no-hooks -draft -itersel %{
try %sh{
@dojoteef
dojoteef / profile.py
Last active June 5, 2023 11:44
A CUDA memory profiler for pytorch
'''
Memory profiling utilities
'''
import gc
import inspect
import linecache
import os.path
import sys
import time
import threading