Some functions that I think should exist or re-implementations of existing functions with modified behaviour.
Check if a list contains an item or not, returns a boolean.
Typically the index()
function is used to do this. However as it
In an effort to consolidate my focus in Vim I wondered what it would be like if I limited myself to a single window. This notion came about because I knew I wasn't utilizing things like tags, jumps, and the quickfix list as effectively could be done.
It's important to remember that no configuration is a substitute for discipline when learning to change. This is simply a journey I went on and sharing what I learnt about Vim along the way.
Use of a language map is needed to cover things like f
and r
, see :help language-mapping
.
set iminsert=1
for mode in ['n', 'x', 'c', 'l']
execute mode . 'noremap : ;'
execute mode . 'noremap ; :'
endfor
#!/bin/sh | |
# Caps as Ctrl | |
setxkbmap -option ctrl:nocaps | |
# Ctrl as Esc when not chorded | |
xcape -e 'Control_L=Escape' | |
# Swap semi-colon and colon | |
xmodmap -e 'keycode 47 = colon semicolon' |
Performs reverse incremental history search provided the current command-line is empty.
Started out by tweaking ctrlr.vim but ended up being a total re-write. Functionally it's largely the same, differs as follows.
<C-R>
behaviour rather than having to re-implement it.filter()
rather than an explicit loop.Vim will move the cursor to the beginning of an object after invoking operator upon it. From an interactive editing perspective this may be considered annoying however it is the consistent choice as operators can be destructive. As such restoring the cursor to its prior position after invoking an operator on an object may not make sense.
There are many ways possible to alter this behaviour to your preference with mappings and/or scripting. But with custom operator mappings this can be particularly ugly.
In lieu of a set verymagic
option in Vim we need to have plethora of
mappings to insert \v
.
The AutoVeryMagic()
function / command-line mapping is the main item
of interest here. It should only insert \v
where needed.
augroup AutoVeryMagic
autocmd!
autocmd CmdlineEnter /,\? if empty(getcmdline()) | call feedkeys('\v', 'n') | endif
A simplified variant of vim-addon-qf-layout.
grep -H
|
function! QuickFixFormat()
let qflist = map(getqflist(),
\ "extend(v:val, {'filename' : bufname(v:val.bufnr)})")
Show the git object for the current line or selection. Different from git log -L
as I'm only interested in the current text (also I don't deem line based ancerstory particularly intersting).
Commit hashes are pulled from git blame
. We need to pass -f
and --show-email
to ensure the time is always shown as the forth field. This is considered important as I want to sort upon the time to ensure the commits passed to git show
are in chronological order.
I "prime" less
with a search pattern to allow me to quickly page though the interesting bits of the output. I do this along with passing the -R
flag via the LESS
environment variable as to override other options that may be set there that could potentially interfere, such as -F
.
The use of a UNIX pipeline is a little ugly but it is far more concise than the equivalent Vim script.
function! Gshow() range
A modified version of Romain's gist.
See prior revisions for functionality closer to the original. This is now a simplification that aims only to provide prompts that would typically follow basic commands.
function! ExpandCommand(pattern) abort
let aliases =
\ { 'cn' : 'cnext'