-- My personal mappings for this thingie. -- Window size vim.keymap.set('n','++','10+', {desc = 'Do 10 bigger in vertical size'}) vim.keymap.set('n','--','10-', {desc = 'Do 10 smaller in vertical size'}) vim.keymap.set('n','>>','10>', {desc = 'Do 10 bigger in horizontal size'}) vim.keymap.set('n','<<','10<', {desc = 'Do 10 bigger in horizontal size'}) -- "In command line mode, and are more intelligent that and -- ", because they remember the start of the command: that is -- ":echo will go to commands that started with echo, instead of just the -- "previous. -- This should work, I don't understand why it doesn't. -- Lua does not have ternary operator ?, so the idiom is a and b or c for the corresponding -- c a ? b or c, because and has more priority than or. vim.keymap.set('c','', function() return vim.fn.wildmenumode() == 1 and '' or '' end, {expr = true, desc = 'If wildmenu then do down instead of c-n'}) vim.keymap.set('c','', function() return vim.fn.wildmenumode() == 1 and '' or '' end, {expr = true, desc = 'If wildmenu then do up instead of c-p'}) -- vim.keymap.set('c','','', {desc = 'If wildmenu then do down instead of c-n'}) -- vim.keymap.set('c','','', {desc = 'If wildmenu then do up instead of c-p'}) -- redraws the screen in normal mode, this redraws and eliminates highlight vim.keymap.set('n','',':nohlsearch:diffupdate:syntax sync fromstart', {desc = 'Redraw and remove highlight'}) -- Save file vim.keymap.set('n','wf',':w', {desc = 'Save file'}) -- Escape from insert mode with kj -- Do not do this in visual mode (interferes with selection) -- or command mode (doesn't allow searching for kj) vim.keymap.set('i','kj',':w', {desc = 'Save file'}) -- Open help in vertical split in the Right -- Combine vertical[vert] and botright[bo] commands vim.keymap.set('n','vh',':vertical botright help', {desc = 'Vertical help'}) -- Syntax name for current word -- nnoremap :echo "hightlight<" . synIDattr(synID(line("."),col("."),1),"name") . '> transparent<' -- \ . synIDattr(synID(line("."),col("."),0),"name") . "> SyntaxId<" -- \ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" -- nnoremap fe /\\|\ -- nnoremap st :Startify -- Switch horizontal split to vertical -- Add R to rotate it at the end vim.keymap.set('n','htv','tHR', {desc = 'Change horizontal split to vertical'}) -- Switch vertical split to horizontal vim.keymap.set('n','vth','tKR', {desc = 'Change vertical split to horizontal'}) -- nnoremap mm :make -- nnoremap ma :AsyncRun :make -- nnoremap :AsyncRun cd\ $EMV_HOME\ &&\ bms\ build\ -b\ &&\ bms\ test -- Select inner word. vim.keymap.set('n','','viw', {desc = 'Select inner word'}) -- #Seleccionar e indentar. vim.keymap.set('n', '', 'vi{=', {desc = 'indent inside braces'}) -- Buffers vim.keymap.set('n','bn',':bn', {desc = 'Next buffer'}) vim.keymap.set('n','bp',':bp', {desc = 'Previous buffer'}) vim.keymap.set('n','bf',':bf', {desc = 'First buffer'}) vim.keymap.set('n','bl',':bl', {desc = 'Last buffer'}) vim.keymap.set('n','bd',':bd', {desc = 'Delete buffer'}) -- Quickfix list vim.keymap.set('n','cn',':cn', {desc = 'Next result'}) vim.keymap.set('n','cp',':cp', {desc = 'Previous result'}) vim.keymap.set('n','cf',':cfirst', {desc = 'First result'}) vim.keymap.set('n','cl',':clast', {desc = 'Last result'}) vim.keymap.set('n','co',':copen', {desc = 'Open quicfix list'}) vim.keymap.set('n','cq',':cclose', {desc = 'Close quickfix list'}) -- Location list -- vim.keymap.set('n','ln',':lne', {desc = 'Change vertical split to horizontal'}) -- vim.keymap.set('n','lp',':lp', {desc = 'Change vertical split to horizontal'}) -- Edit and source vimrc vim.keymap.set('n','sv',':source $MYVIMRC', {desc = 'Source vimrc file'}) vim.keymap.set('n','ev',':e $MYVIMRC', {desc = 'Change vimrc file'}) -- Make and recover default session. vim.keymap.set('n','',': mksession! /home/$USER/.vim/files/nacho_vim_session', {desc = 'Make the default session'}) vim.keymap.set('n','',': source! /home/$USER/.vim/files/nacho_vim_session', {desc = 'Source the default session'}) #Go only to matches in this file, does the same with both mappings -- nnoremap ]g :execute "g/\\<" . expand("") . "\\>":let nr = input("Which one: ")exe "normal " . nr ."G" -- nnoremap [g :execute "g/\\<" . expand("") . "\\>" vim.keymap.set('n', ']g', "g/\\<" . expand("") . "\\>":let nr = input("Which one: ")exe "normal " . nr ."G", { expr = true, desc = 'find this word in file'})