Vim shortchuts


REQUISITES and dependencies

cambiar variables que apuntan a versiones de java al lugar correcto. verificar version de java que ejecuta cmd (tiene que ser > 17)


shada file error

go to nvim-data shada folder and delete it's contents

syntax highlighting



LSP and null-ls



the svelte language server comes with linting and formatting out the box


so the mson-null-ls plugin installs and sets up eslint_d AND prettier (sets paths idk) so all I have to do to get formatting and linting is adding the .prettierrc and .eslintrc.* file. see eslint and prettier config files. initializing a svelte project with npm create svelte@latest <app_name> also generates these files automatically for svelte projects
after this, extend null-ls filetypes to attach to .svelte files. (this might override the autoconfig set by mason-null-ls, comment stuff out as needed for working with svelte or other types of projects)

I could also install eslint and prettier globally (npm install -g eslint prettier) and set null-ls source 'manually' or I could install eslint and prettier with Mason and manually add to $PATH the location of the mason generated scripts that execute the programs

or I could use eslint-lsp (installed on Mason and auto sets up) which doesn't require having a .eslintrc file in the directory as it most likely has some default config saved somewhere, the other 2 do require the file



:w :q :q! :wq save, quit, quit without save
ZZ = :xa
:w new_file_name save the file under a new name and continue editing original
:sav save file under a new name and continue editing the new copy
:nmap  _       gives me all mappings on whatever mode I'm in
:vsp and :terminal   quit terminal with ctrl+\ + ctrl + n
:so refresh lua source

y+ copies to system clipboard  and _x means that deletes but doesn't yank, copy the value deleted (remap aclaration)

ctrl + + zoom in
ctrl + - zoom out

keys Description
esc / ctrl+z / ctrl+[ go to normal mode
hjkl left down up right
_ / 0 / home place cursor at start of line
$ / End place cursor at end of line
b B go back word by word.
ge go back to end of word.
w W go forward by start of word
e E go forward by end of words
shift [,] jump over blocks
( { [ or % to go to matching closing
* or # find next/previous occurence of word under cursor
gg, G go to beginning/end of file
2G go to line 2
keys description
f F move to next/previous char in line. Then use ';' and ',' to go back and forth finds
t T move to but not on the char in line (like f)

[t [b [q [l     go to previous tab, buffer, q?, l?         with shift go to first/last

]t ]b ...
]m go to next method
[ + delimiter [,{,( go to start of block
]+ delimiter ],},) go to end of block

leap navigation

<>h leap forward
<>H leap backwards
<>hw leap across windows

marks and `

m_         set a mark named with any letter/number. Upper case letters are global marks (project wide?
`_            go to a set mark named with any letter/number.
`` go to position before jump
`. go to position when last edited
:marks         see marks
mx              Set mark x
m,              Set the next available alphabetical (lowercase) mark
m;              Toggle the next available mark at the current line
dmx             Delete mark x
dm-             Delete all marks on the current line
dm <space>       Delete all marks in the current buffer
m]              Move to next mark
m[              Move to previous mark
m:              Preview mark. This will prompt you for a specific mark to
preview; press <cr> to preview the next mark.
m[0-9]          Add a bookmark from bookmark group[0-9].
dm[0-9]         Delete all bookmarks from bookmark group[0-9].
m}              Move to the next bookmark having the same type as the bookmark under the cursor. Works across buffers.
m{              Move to the previous bookmark having the same type as the bookmark under the cursor. Works across buffers.
dm=             Delete the bookmark under the cursor.


i I insert mode. Insert mode at start of line
a A insert mode after cursor. insert at end of line
ctrl+w        insert mode delete previous word.
J gJ merge next line with current line.
~ switch case
r replace letter under cursor
R replace 'mode'.
y    copy
d delete command
c     cut
p    paste


q+_             the next key after key is where the macro is saved
record key presses
press q again
@_                execute the macro stored at _


x X delete letter under cursor
D delete(cut) to end of line
C deletes (cut) the rest of the line to insert

d delete (cut). can be combined with movement (like hjkl, web). also copies content and can be pasted with p

dd delete (cut) entire line
S delete (cut) current line, to insert mode

p P paste before/after cursor
o O inserts new line below/above and stars insert mode
oo OO insert without entering insert mode
<>o insert new line above and below current line and enter insert mode

. repeat previous command
u undo
ctrl R redo

HIGHLIGHTING and selecting mutliple character

v highlighting mode.
V highlight entire line/block
ctrl+v vertical edit, combine with I to insert at start of every line
o toggle jump cursor to end of selected text
v > u U change to lower/upper case
yy copy current line
/ is like ctrl f, then press 'n' and 'N' to find next/previous occurrences
:noh remove highlighting of seaerch matches
:%        refer to current buffer. I can combine with 'y' or 'd'        delete entire page
highlight some area > ':s/myvar/yourvar'        substitue mode


Ctrl + b – move back one full screen
Ctrl + f – move forward one full screen
Ctrl + d – move forward 1/2 a screen
Ctrl + u – move back 1/2 a screen
Ctrl + e – move screen down one line (without moving the cursor)
Ctrl + y – move screen up one line (without moving the cursor)
Ctrl + o – move backward through the jump history
Ctrl + i – move forward through the jump history

H – move to the top of the screen (H=high)
M – move to the middle of the screen (M=middle)
L – move to the bottom of the screen (L=low)


za ZA     Toggle a fold under cursor
zM Close all open folds
zm Increase the foldlevel by one
zR Decrease the foldlevel to zero—all folds will be open
zr Decrease the foldlevel by one
zo Open a fold at the cursor
zO Open all folds at the cursor
zc Close a fold under cursor

zf#j Create a fold from the cursor down # lines
zf/ String creates a fold from the cursor to string
zj Move the cursor to the next fold
zk Move the cursor to the previous fold
zd Delete the fold at the cursor
zE Delete all folds
[z Move to start of open fold
]z Move to end of open fold


<< or >> indent one shift
<>f, f4 format file
highlight and press +


:%s/old/new/g - replace all old with new throughout file
:%s/old/new/gc - replace all old with new throughout file with confirmations
<>s                     replace all instaces of current word under cursor


<>tx        close current tab
gt < >tn move to the next tab
gT  < >tp move to the previous tab
#gt move to tab number #
:tabo[nly] - close all tabs except for the current one

:tabdo command - run the command on all tabs (e.g. :tabdo q - closes all opened tabs)

< >to or  :tabnew {page.words.file} open a file in a new tab


Ctrl + T open current window in a tab
Ctrl + h - move cursor to the left window (vertical split)
Ctrl + l - move cursor to the right window (vertical split)
Ctrl + j - move cursor to the window below (horizontal split)
Ctrl + k - move cursor to the window above (horizontal split)
ctrl arrow keys resize the windows

:e[dit] file - edit a file in a new buffer
:bn[ext] - go to the next buffer
:bp[revious] - go to the previous buffer
:bd[elete] - delete a buffer (close a file)
:b[uffer] file - go to a buffer by file
:ls or :buffers - list all open buffers
:sp[lit] file - open a file in a new buffer and split window
:vs[plit] file - open a file in a new buffer and vertically split window
:tab ba[ll] - edit all buffers as tabs
Ctrl + wT - move the current split window into its own tab
Ctrl + wt - duplicate current buffer in new tab
Ctrl + ws - split window
Ctrl + wv - split window vertically
Ctrl + ww - switch windows
Ctrl + wq - quit a window
ctrl + wc        - close windows
ctrl + c close window (global, works for all/ most plugins)
Ctrl + wx - exchange current window with next one
Ctrl + w= - make all windows equal height & width
Ctrl + wH - make current window full height at far left (leftmost vertical window)
Ctrl + wL - make current window full height at far right (rightmost vertical window)
Ctrl + wJ - make current window full width at the very bottom (bottommost horizontal window)
Ctrl + wK - make current window full width at the very top (topmost horizontal window)
Ctrl + wo - make current window the only open window


highlight + S + whatever          surround highlighted with whatever and surround it with whatever
ys = surround
ds = delete surround
cs = chage surround
yss = surround entire line
ysiw            surround inside word
ds(        delete surrounding () dst delete surrounding tags
cs'(        change surrounding '' for ()
cst"        change TAGS for ""

cs]{        when changing for enclosing using open and closing adds or doesnt' add indentation/spaces


"" some text         if I press alt+e in this case the " will travel thro every word
alt+p        toggle plugin itself


<>u                         undo tree
<leader>nh", ":nohl<CR>"
vJ / K         .move line up and down. first enter visual mode.
<>m toggle treesitter join: joins blocks of code like arrays, and maps. collapse, expand.


harpoon is a plugin that marks files (4) for quick access
<>ss open ui
<>sa mark file
<>su,i,o,p go to file 1,2,3,4


< >ff   fuzy find files by name
<>fg     git files finder
<>fs        grep all files
<>ft         open telescope
<>fp search past yanks on clipboard
<>fq search recorded macros
? fuzzy find current buffer
ctrl-u/d    scroll up/down preview
ctrl j/k    selec next/prev file
n, j/k delect next/prev file
tab/S-tab select/deselect file
ctrl s        open vertical split
alt s        open horizontal spli
ctrl t            open tab
ctrl c            close
:Telescope git_    view git related things like branches
, ? help keymaps

<>fb open buffers
delete/close buffer


f5, <>du        UI toggles
<>b,      toggle breakpoint
<>B,      set conditional breakpoint
f9, <>dc       launch debugger / continue
f10, <>dj     step out
f11, <>dl      step over
f12, <>dk       step in
f6         ui eval()
f7, <>dh        ui evaluate expression. trigger again to go to window
f8, <>dr        repl toggle
<>da attach debugger
<>ds variable scopes window
<>db breakpoints window
<>dw watches window
<>dt stacks window

on DAP-ui on the breakpoints window I can press o to go the breakpoint or t to toggle it on and off.
I can also insert what variables to watch with i on the watch window and repl


<>tm, "Run" },
<>tM, "Run with DAP" },
<>tf , "Run File" },
<>tF, "Run File with DAP" },
<>ts, "Summary" },
<>tw "Watch" },


< >gs open lazy git within floaterm


:G any git command
< >g           open fugitive. Git
'-'  and s       stages a file change
=   or dv     shows diffs. dq to quit
u        unstage file
X         delete changes
cc commit pane
zzz stash changes
]] move between changes
]c         jump to next tongue(conflict) ?
[c         jump to prev change
o O     see changes in a split or new tab
coo checkout commit

in a file with merge conflicts I can :Gvdiffsplit!.
left: current change, mid: conflict, right branch I want to merge with
gf, d2o    choose from left window
gj, d3o    choose from right window
if doesn't work use difget
:help fugitive

:Gvdiffsplit  (branch-name)      see changes of curr file compared to last commit
:G difftool -y         see changes of all files open in different tabs
:Gedit main:file2.js            see the contents of a file
Gread main:file1.js            == git reset     replace current buffer
:Gwrite        =git add <filename> changes the entire file and stages it for commit

:git revert is for reverting commits, reset resets changes
:G restore     restore file changes to last commit

git signs

git info in buffers
<>g with which key
<>gb checkout branch
<>gc checkout commit
<>gd Git Diff
<>gj next hunk
<>gk prev hunk
<>gl blame
... many more

Git Worktrees

<>gn create work tree
<>gt             open worktree. telescope
(believe don't have to do this with the create worktree command)
couldn't get the plugin to work but I could still use git commands to do this.
git clone --bare URL git-worktree.nvim
git worktree add <branch_name>

git signs

td     toggle to see inline git change
tb     toggle git blame

more bindings for staging hunks (only committing certain parts of a file instead of the entire thing)

![image.png](/img/user/00-09 System/09 resources/image-3.png)


< >sa                         add file to harpoon
< >u,i,o,p                    go to files 1,2,3,4
<>ss                       open marked files


alt t    toggle floating terminal


<>xq  open trouble, window showing all problems on the file/ project?
<>xa workspace troubles
<>x     document diagnostics
<>xx trouble toggle


:Mason package manager for LSP, DAP (debugger protocols), linters and formatters
navigate to package and:
u updates
X deletes
i installs

lsp autocomplete

normal mode
(normal) K, (insert) C-h      hover info, documentation
gd     go to definition
gD    go to declaration
gr    go to references
gi     go to implementations
go jumps to definition of the type of symbol under cursor
gs buffer symbols
gS workspace symbols
<>r, f2  rename/replace all ocurrences
<>a, f4 code actions
gl line diagnostics
[d ,]d prev/next diagnostic
<>ws view workspace symbol (queries and finds all instances of a symbol, i.e classes functions, etc...)
<>wa add workspace folder
<>wr remove workspace folder

in insert mode
C-h show signature.
ctrl e        toggle cmp
ctrl n trigger autocomplete suggestions
tab            show suggestions even inside words. next/prev suggestion
ctrl < > starts completion
ctrl p/n previous and next option
ctrl u/f            scroll up and down in items documentation.
ctrl j/k        go to next/prev placeholder in snippet
ctrl y confirm

java lsp
normal mode
:Jdt_ commands
:JdtSetRuntime change java runtime, must refresh dap settings after.
<>ji organize_imports
<>jt test class
<>jn test nearest_method
(v,n)<>je extract_variables
<>je extract_variable
<>jea extract_variable and replace all ocurrences
<>jc extract_constant
<>jm extract_method


<>re :Refactor extract ")
<>rf :Refactor extract_to_file ")
<>rv :Refactor extract_var ")
<>ri :Refactor inline_var")
<>rI :Refactor inline_func")
<>rb :Refactor extract_block")
<>rbf :Refactor extract_block_to_file")


gcc toggle comment current line
gc toggle comment highlited text
gb toggle comment blockwise
gc navigation toggle commenting navigation input

neotree FILE TREE

? help?
< >e open file tree
<>eb open buffer list
<>eg open git status files
<, > switch source
s,, , S        open vertical/half
bd         delete buffer
a new file
A                new dir
d delete file
P             preview
Y copy file path options
y copy file
x cut file
p paste from clipboard


neovim-sesssion-manager plugin. saves session on a per folder basis
Pasted image 20230727003321.png