linux editor
Vim
→ Install neovim
#this to be run at each release
snap install neovim
sudo update-alternatives --install /usr/bin/editor editor /usr/bin/vim 1
sudo update-alternatives --config
Add those into .bashrc:
export EDITOR=/usr/bin/vim
export VISUAL=/usr/bin/vim
→ Install plugins
curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
cat ~/.config/nvim/init.vim
set encoding=utf-8
colo murphy
set hlsearch
set nonu
call plug#begin()
Plug 'https://github.com/ryvnf/readline.vim.git'
Plug 'https://github.com/tpope/vim-surround.git'
call plug#end()
" in order to keep terminal cursor after vim quit
set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50
\,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor
\,sm:block-blinkwait175-blinkoff150-blinkon175
Plugin install/update:
:PlugInstall
:UpdateRemotePlugins
→ Regexp
→ Gready / non Gready
In vim, .\{-}
is equivalent to .*?
for non gready operators:
:%s/jim.\{-}//g
→ Delete blank lines
:g/^$/d
→ No format on paste
:set paste
#Note: it breaks vim-readline
→ No numbering
:set nonu
→ Vim Surround
Add surround:
- Visual a word, part of text
S"
-> "surround"S(
-> (surround)
Replace surround:
- On a "word" press
cs"'
to change to 'word' - On a "word" press
cs")
to change to (word)
Delete surround:
- On a "word" press
ds"
to change to word
→ Open multiple files in tabs
vim file1.md file2.md
#then in vim this will turn buffers into tabs
:tab all
:qa # quit all
→ Re-use sessions
#8will save the session in a Session.vim (overrite with !)
:mksession!
#or
:mks!
#later on this will back to the state save
vim -S
→ Spelling
→ Plugins
- snake case movement
- git blame
- magit equivalent
- tests
- nvim-treesitter-context for method context
- python import
- nvim gradle
- better readline ?
→ image
- GitHub - kjuq/sixelview.nvim: View images on Neovim via Sixel
- use
swayimg
from neotree by pressingO
which will open the default xdg application
→ lazy vim
- nvim snap install has the last stable version
- nvim apt has an old version
- to keep both vim and nvim available, snap for nvim is a good approach since debian package mask vim
- lazyvim book
- lazyvim blue book
- disable builtin plugin
→ install nerd fonts
- note: snap apps cannot access
.local/share/fonts
#!/bin/bash
declare -a fonts=(
JetBrainsMono
)
version='3.2.1'
fonts_dir="${HOME}/.fonts"
if [[ ! -d "$fonts_dir" ]]; then
mkdir -p "$fonts_dir"
fi
for font in "${fonts[@]}"; do
zip_file="${font}.zip"
download_url="https://github.com/ryanoasis/nerd-fonts/releases/download/v${version}/${zip_file}"
echo "Downloading $download_url"
wget "$download_url"
unzip "$zip_file" -d "$fonts_dir"
rm "$zip_file"
done
find "$fonts_dir" -name '*Windows Compatible*' -delete
fc-cache -fv
→ git
- show git history for a given file:
:DiffviewFileHistory %
in a given file buffer - mergetool by running :DiffviewOpen
- understand diff
- git in file
<space>gs
; show all the modified files in telescope<space>ghs
; stage hunk<space>ghr
; reset hunk<space>ghu
; unstage hunk<space>ghp
; preview hunk<space>ghd
; diff mode that file
In DiffView:
dp ; stage the hunk - aka do push
do ; discard the hunk - aka do optain
]c/[c ; next/previous hunk
; to save a given merged file, save the diff buffer (in the bottom)
→ gh code review
- install and configure login for gh cli (use ssh-key + gh token)
- see workflow
<space> gp ; list pull requests
:Octo review
[q ]q ; change file
<space> ca ; add comment
<space> sa ; add suggestion
:Octo review submit ; to submit the pr
→ terminal
<C-/> ; show/hide a terminal
<C-\><C-n> ; quit terminal mode (allow to scroll, copy/paste...)
→ keybindings
You can:
- get a list of all active mappings with :help maplist(),
- get details about a specific mapping with :help maparg(),
- check if a mapping exists with :help mapcheck(),
- check if a mapping to a specific command exists with :help has_mapto().
If you want a list of all normal mode commands, see :help normal-index.
"+y ; copy to os clipboard
:LspRestart ; restart code server
:map ; show all key bindings and source
<c-h> ; will show the current file in the tree
<ctrl> i ; next cursor place
<ctrl> o ; previous cursor place
<shift> h ; previous buffer
<shift> l ; next buffer
<space> / ; search within files
<space> bd ; close current buffer
<space> ca ; code actions
<space> e : show/hide left panel
<space> ff ; search files names
<space> ft ; open terminal
<space> ul ; hide numbering
<space> w (hjkl) ; navigate on panels, with multidirectional keys
<space> / ;in neotree, type to live grep+args in current node
<space>cs ; show outlines or code functions / methods
<space>gb ; will show git blame popup
<space>qq ; quit and save session
<space>sW ; grep search current selected word
[d, [w, [e, ]d, ]w, and ]e ; go to next error/warn/diagnose
[h and ]h ;next git hunk
[t and ]t ; next todo
s ; ar startup restore session
<Space>w< ; resize
<Space>wm ; maximize
<c-t> ; trouble view
<c-q> ; revert trouble
<Space>cs ; show outlines
→ Tricks
Cancel search
vim.keymap.set('n', '<Esc>', function()
vim.cmd.nohlsearch()
vim.cmd.diffupdate()
vim.cmd.mode()
end, { desc = 'Clear search' })
- neotree copy absolute patch
- more versatile aproach
- neotree fuzzy_search in given folder: set_root with
.
then/
. To restore root path,q
→ Java
:JdtWipeDataAndRestart
: allows to restart the lsp; apparently needed when adding depts into gradle (not maven)
→ logs message
:mess
:lua Snacks.notifier.show_history()
:noice
→ markdown
- ignore lint
<!-- markdownlint-disable -->
or enable - had to run this: run npm install in this folder
~/.local/share/nvim/lazy/markdown-preview.nvim/app
→ Marks
This page was last modified: