Improve vimrc - abbreviation fix, some leader stuff
This commit is contained in:
		
							parent
							
								
									589abb9e46
								
							
						
					
					
						commit
						a529cd6560
					
				
							
								
								
									
										51
									
								
								vimrc
									
									
									
									
									
								
							
							
						
						
									
										51
									
								
								vimrc
									
									
									
									
									
								
							| 
						 | 
					@ -570,7 +570,7 @@ augroup END
 | 
				
			||||||
" Suspend vim process and return to the shell. Can return to vim with `fg`.
 | 
					" Suspend vim process and return to the shell. Can return to vim with `fg`.
 | 
				
			||||||
nnoremap <leader>z <c-z>
 | 
					nnoremap <leader>z <c-z>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
" edit a file
 | 
					" Edit a file
 | 
				
			||||||
nnoremap <leader>e :e
 | 
					nnoremap <leader>e :e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
" Open the vimrc file for editing / reload vimrc file.
 | 
					" Open the vimrc file for editing / reload vimrc file.
 | 
				
			||||||
| 
						 | 
					@ -614,8 +614,22 @@ noremap <c-h> <c-w><Left>
 | 
				
			||||||
noremap <leader>m :vsplit<cr>
 | 
					noremap <leader>m :vsplit<cr>
 | 
				
			||||||
noremap <leader>mm :split<cr>
 | 
					noremap <leader>mm :split<cr>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
" Forward delete and replace a word.
 | 
					" Faster way to activate the 'a' register. This is useful for putting different
 | 
				
			||||||
noremap <leader>d ciw
 | 
					" lines of text into the 'a' register and then pasting it as a group.
 | 
				
			||||||
 | 
					" You need to first use `<leader>a` and then subsequent use is <leader>A.
 | 
				
			||||||
 | 
					" The paste command will use this content until you do something with a
 | 
				
			||||||
 | 
					" different register. You can later paste the 'a' contents using `<leader>a p`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					" This overwrites the contents of a.
 | 
				
			||||||
 | 
					noremap <leader>a "a
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					" This appends to a.
 | 
				
			||||||
 | 
					noremap <leader>aa "A
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					" Backward replace word including cursor character.
 | 
				
			||||||
 | 
					noremap <leader>d cvb
 | 
				
			||||||
 | 
					" Forward replace word.
 | 
				
			||||||
 | 
					noremap <leader>e cw
 | 
				
			||||||
 | 
					
 | 
				
			||||||
" Allow fast pasting by accessing the system clipboard register.
 | 
					" Allow fast pasting by accessing the system clipboard register.
 | 
				
			||||||
noremap <leader>p "+p
 | 
					noremap <leader>p "+p
 | 
				
			||||||
| 
						 | 
					@ -728,26 +742,35 @@ function! WriteAllModifiedFilesAndCreateCtags()
 | 
				
			||||||
    call CreateCtags()
 | 
					    call CreateCtags()
 | 
				
			||||||
endfunction
 | 
					endfunction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cnoreabbrev w  :call WriteCurrentFileAndCreateCtags()
 | 
					" Create a command abbreviation that only applies when it's at the beginning
 | 
				
			||||||
cnoreabbrev W  :call WriteCurrentFileAndCreateCtags()
 | 
					" of a ex command. If you were to do a normal cnoreabbrev or cabbrev then the
 | 
				
			||||||
cnoreabbrev wa :call WriteAllModifiedFilesAndCreateCtags()
 | 
					" subsitution can happen anywhere in the command line. It was mostly affecting
 | 
				
			||||||
cnoreabbrev Wa :call WriteAllModifiedFilesAndCreateCtags()
 | 
					" my text search; I'd type '/w' and it would be replaced with the call to save
 | 
				
			||||||
cnoreabbrev WA :call WriteAllModifiedFilesAndCreateCtags()
 | 
					" and create ctags.
 | 
				
			||||||
cnoreabbrev wq :call WriteCurrentFileAndCreateCtagsThenQuit()
 | 
					function! Cabbrev(key, value)
 | 
				
			||||||
cnoreabbrev Wq :call WriteCurrentFileAndCreateCtagsThenQuit()
 | 
					  exe printf('cabbrev <expr> %s (getcmdtype() == ":" && getcmdpos() <= %d) ? %s : %s',
 | 
				
			||||||
cnoreabbrev WQ :call WriteCurrentFileAndCreateCtagsThenQuit()
 | 
					    \ a:key, len(a:key)+1, string(a:value), string(a:key))
 | 
				
			||||||
 | 
					endfunction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					call Cabbrev('w',  'call WriteCurrentFileAndCreateCtags()')
 | 
				
			||||||
 | 
					call Cabbrev('W',  'call WriteCurrentFileAndCreateCtags()')
 | 
				
			||||||
 | 
					call Cabbrev('wa', 'call WriteAllModifiedFilesAndCreateCtags()')
 | 
				
			||||||
 | 
					call Cabbrev('Wa', 'call WriteAllModifiedFilesAndCreateCtags()')
 | 
				
			||||||
 | 
					call Cabbrev('WA', 'call WriteAllModifiedFilesAndCreateCtags()')
 | 
				
			||||||
 | 
					call Cabbrev('wq', 'call WriteCurrentFileAndCreateCtagsThenQuit()')
 | 
				
			||||||
 | 
					call Cabbrev('Wq', 'call WriteCurrentFileAndCreateCtagsThenQuit()')
 | 
				
			||||||
 | 
					call Cabbrev('WQ', 'call WriteCurrentFileAndCreateCtagsThenQuit()')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
nnoremap <leader>w :call WriteCurrentFileAndCreateCtags()<cr>
 | 
					nnoremap <leader>w :call WriteCurrentFileAndCreateCtags()<cr>
 | 
				
			||||||
nnoremap <leader>x :call WriteCurrentFileAndCreateCtagsThenQuit()<cr>
 | 
					nnoremap <leader>x :call WriteCurrentFileAndCreateCtagsThenQuit()<cr>
 | 
				
			||||||
nnoremap <leader>q :q<cr>
 | 
					nnoremap <leader>q :q<cr>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cnoreabbrev Q q
 | 
					call Cabbrev('Q', 'q')
 | 
				
			||||||
cnoreabbrev Qa qa
 | 
					call Cabbrev('Qa', 'qa')
 | 
				
			||||||
command! Qa qall
 | 
					command! Qa qall
 | 
				
			||||||
" Disable Ex mode.
 | 
					" Disable Ex mode.
 | 
				
			||||||
noremap Q <Nop>
 | 
					noremap Q <Nop>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
"##################################################################################
 | 
					"##################################################################################
 | 
				
			||||||
" MULTIPURPOSE TAB KEY
 | 
					" MULTIPURPOSE TAB KEY
 | 
				
			||||||
"##################################################################################
 | 
					"##################################################################################
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user