Nvim

on mac setup works
on windows I'll start installing and using nvim on wsl.

todo

Installing and dependencies

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

troubleshooting

shada file error

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

syntax highlighting

debugging

debugging in nvim

java

svelte

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

KEYMAPS and COMMANDS

commands

: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.

editing

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

MACROS

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

DELETE

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

MOVING BY SCREENS

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)

FOLDING

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

INDENTATION

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

find and replace

finding
apart from / and ? searching that I already know there is also * and # that look for next/previous instance of the current word I'm on. I tend to just use brackets for symbol finding with lsp.

replacing
lsp renaming has done a good job for me for renaming symbols even across multiple files. but in the cases that what I want to find and replace is not a symbol I could do the following:

options:

what about global project wide?

TABS

<>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

WORKING WITH MULTIPLE FILES

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

buffers

:e[dit] file - edit a file in a new buffer
:bn[ext], ]b - go to the next buffer
:bp[revious], [b - 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, <M-s> - open a file in a new buffer and split window
:vs[plit] file , <C-s> - open a file in a new buffer and vertically split window
:tab ba[ll] - edit all buffers as tabs
Ctrl-6 - toggle between last 2 buffers

tags

tags are ...
gb - pop tag, go back to previous tag
Ctrl-o - go back prev tag

Ctrl + wt - duplicate current buffer in new tab
Ctrl + wT - move the current split window into its own 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

SURROUND

Add surrounding with sa (in visual mode or on motion).
Delete surrounding with sd.
Replace surrounding with sr.
Find surrounding with sf or sF (move cursor right or left).
Highlight surrounding with sh.
Change number of neighbor lines with sn (see :h MiniSurround-algorithm).
Surrounding is identified by a single character as both "input" (in delete and replace start, find, and highlight) and "output" (in add and replace end):
'f' - function call (string of alphanumeric symbols or '' or '.' followed by balanced '()'). In "input" finds function call, in "output" prompts user to enter function name.
't' - tag. In "input" finds tag with same identifier, in "output" prompts user to enter tag name.
All symbols in brackets '()', '[]', '{}', '<>". In "input' represents balanced brackets (open - with whitespace pad, close - without), in "output" - left and right parts of brackets.
'?' - interactive. Prompts user to enter left and right parts.
All other single character identifiers (supported by getcharstr()) represent surrounding with identical left and right parts.

AUTO PAIRS

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

CUSTOM

<>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.

Telescope

< >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

DEBUGGING

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

GIT

fugitive

: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

conflicts

https://www.reddit.com/r/vim/comments/leo0ji/comment/gmhqbj9/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
in a file with merge conflicts I can :Gvdiffsplit!.
left: cu
gf, d2o    choose from left window
gj, d3o    choose from right window
if doesn't work use diffget
: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

view file history diff

with fugitive
:Gdiff :0 current file and index
:Gdiff [revision] current file and some other revision
:Gdiff ~3 current file file 3 commits ago.
:Glog behaves different from git log
git log shows a list of commit msgs for the entire project, Glog loads all previous revisions of current file into quickfix list.
https://stackoverflow.com/a/28916959/14318987

with diffview:

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)

HARPOON

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

TOGGLETERM

alt t    toggle floating terminal

Troubles

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

MASON

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

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
<>rn  rename/replace all ocurrences
<>ca 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
Tab, S-Tab snippet forward/backwards
C-k, C-h signature help

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 h/l        go to next/prev placeholder in snippet
ctrl k open signature help.
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

COMMENTING

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

sessions

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

GITHUB COPILOT