Difference between revisions of "VIM"

From HyperSecurity Wiki
Jump to: navigation, search
 
(7 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
  vi /etc/vim/vimrc.local
 
  vi /etc/vim/vimrc.local
 +
<pre>
 +
" Prevent the defaults from being loaded again later, if the user doesn't                                                                                                                   
 +
" have a local vimrc (~/.vimrc)                                                                                                                                                             
 +
let skip_defaults_vim = 1                                                                                                                                                                   
  
" This file loads the default vim options at the beginning and prevents
+
" Set more options (overwrites settings from /usr/share/vim/vim80/defaults.vim)                                                                                                              
" that they are being loaded again later. All other options that will be set,
+
" Add as many options as you wish                                                                                                                                                            
" are added, or overwrite the default settings. Add as many options as you
+
" Set the mouse mode to 'r'                                                                                                                                                                  
" wish at the end of this file.
+
if has('mouse')                                                                                                                                                                              
+
set mouse=r                                                                                                                                                                                
" Load the defaults
+
endif                                                                                                                                                                                        
source /usr/share/vim/vim80/defaults.vim
+
 
+
" Toggle paste/nopaste automatically when copy/paste with right click in insert mode:                                                                                                        
" Prevent the defaults from being loaded again later, if the user doesn't
+
let &t_SI .= "\<Esc>[?2004h"                                                                                                                                                                
" have a local vimrc (~/.vimrc)
+
let &t_EI .= "\<Esc>[?2004l"                                                                                                                                                                
let skip_defaults_vim = 1
+
 
 
+
inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()                                                                                                                                      
" Set more options (overwrites settings from /usr/share/vim/vim80/defaults.vim)
+
 
" Add as many options as you wish
+
function! XTermPasteBegin()                                                                                                                                                                  
+
set pastetoggle=<Esc>[201~                                                                                                                                                                  
" Set the mouse mode to 'r'
+
set paste                                                                                                                                                                                  
if has('mouse')
+
return ""                                                                                                                                                                                  
  set mouse=r
+
endfunction  
endif
+
</pre>
+
 
" Toggle paste/nopaste automatically when copy/paste with right click in insert mode:
+
== Commands: ==
let &t_SI .= "\<Esc>[?2004h"
+
 
let &t_EI .= "\<Esc>[?2004l"
+
Add string to the beginning of each line:
+
:%s/^/string/
inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()
+
 
+
Add string to the end of each line:
function! XTermPasteBegin()
+
:%s/$/\string/g
  set pastetoggle=<Esc>[201~
+
 
  set paste
+
Delete all text:
  return ""
+
:%d
  endfunction
 

Latest revision as of 04:48, 2 October 2025

Create the /etc/vim/vimrc.local:

vi /etc/vim/vimrc.local
" Prevent the defaults from being loaded again later, if the user doesn't                                                                                                                     
" have a local vimrc (~/.vimrc)                                                                                                                                                               
let skip_defaults_vim = 1                                                                                                                                                                     

" Set more options (overwrites settings from /usr/share/vim/vim80/defaults.vim)                                                                                                               
" Add as many options as you wish                                                                                                                                                             
" Set the mouse mode to 'r'                                                                                                                                                                   
if has('mouse')                                                                                                                                                                               
 set mouse=r                                                                                                                                                                                  
endif                                                                                                                                                                                         

" Toggle paste/nopaste automatically when copy/paste with right click in insert mode:                                                                                                         
let &t_SI .= "\<Esc>[?2004h"                                                                                                                                                                  
let &t_EI .= "\<Esc>[?2004l"                                                                                                                                                                  

inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()                                                                                                                                        

function! XTermPasteBegin()                                                                                                                                                                   
 set pastetoggle=<Esc>[201~                                                                                                                                                                   
 set paste                                                                                                                                                                                    
 return ""                                                                                                                                                                                    
endfunction  

Commands:

Add string to the beginning of each line:

:%s/^/string/

Add string to the end of each line:

:%s/$/\string/g

Delete all text:

:%d