Customise vim-surround for markdown link syntax
This commit is contained in:
		
							parent
							
								
									edce545a0e
								
							
						
					
					
						commit
						9c4caee646
					
				| @ -1,6 +1,39 @@ | |||||||
|  | " Enable spelling except in Windows terminal vim. | ||||||
| if !has("win32") || has("gui_running") | if !has("win32") || has("gui_running") | ||||||
|   setlocal spell |   setlocal spell | ||||||
| endif | endif | ||||||
|  | 
 | ||||||
|  | " Max 80 chars wide. | ||||||
| setlocal textwidth=80 | setlocal textwidth=80 | ||||||
| " Use tabwidth of 4 to be markdown complient | " Use tabwidth of 4 to be markdown complient. | ||||||
| setlocal tabstop=4 shiftwidth=4 softtabstop=4 | setlocal tabstop=4 shiftwidth=4 softtabstop=4 | ||||||
|  | 
 | ||||||
|  | " Custom surround for markdown link syntax. | ||||||
|  | " "ys{motion}[" makes link out of "word" -> "[word]()" | ||||||
|  | autocmd FileType markdown let b:surround_91 = "[\r]()" | ||||||
|  | " "ys{motion}]" makes link out of "url" -> "[](url)" | ||||||
|  | autocmd FileType markdown let b:surround_93 = "[](\r)" | ||||||
|  | 
 | ||||||
|  | finish " Experiment functionality (disabled). {{{ | ||||||
|  | 
 | ||||||
|  | nnoremap yh :<C-U>set opfunc=<SID>yh<CR>g@ | ||||||
|  | function! <SID>yh(type, ...) | ||||||
|  |   let save_reg_h = getreg('h') | ||||||
|  |   " Mark positions | ||||||
|  |   let begin = getpos("'[")[1:2] | ||||||
|  |   let end = getpos("']")[1:2] | ||||||
|  |   " Append after the end mark. | ||||||
|  |   call cursor(end) | ||||||
|  |   call setreg('h', ']()') | ||||||
|  |   normal "hp | ||||||
|  |   " Prepend before the begin mark. | ||||||
|  |   call cursor(begin) | ||||||
|  |   call setreg('h', '[') | ||||||
|  |   normal "hP | ||||||
|  |   " Place cursor at final ) | ||||||
|  |   call cursor(end) | ||||||
|  |   normal f) | ||||||
|  |   call setreg('h', save_reg_h) | ||||||
|  | endfunction | ||||||
|  | 
 | ||||||
|  | " }}} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user