Add :LStrip command to strip whitespace on the left
This commit is contained in:
		
							parent
							
								
									14709a12a7
								
							
						
					
					
						commit
						946d1e7b4a
					
				@ -1,4 +1,4 @@
 | 
			
		||||
-- :RStrip strip white psace from right of all lines, ranges supported
 | 
			
		||||
-- :RStrip strip white space from right of all lines, ranges supported
 | 
			
		||||
vim.api.nvim_create_user_command('RStrip', function(opts)
 | 
			
		||||
  local pos = vim.fn.getcurpos(vim.api.nvim_get_current_win())
 | 
			
		||||
  local range = opts.line1 .. ',' .. opts.line2
 | 
			
		||||
@ -7,6 +7,15 @@ vim.api.nvim_create_user_command('RStrip', function(opts)
 | 
			
		||||
  vim.fn.setpos('.', pos)
 | 
			
		||||
end, { range = '%' })
 | 
			
		||||
 | 
			
		||||
-- :LStrip strip white space from left of all lines, ranges supported
 | 
			
		||||
vim.api.nvim_create_user_command('LStrip', function(opts)
 | 
			
		||||
  local pos = vim.fn.getcurpos(vim.api.nvim_get_current_win())
 | 
			
		||||
  local range = opts.line1 .. ',' .. opts.line2
 | 
			
		||||
  vim.cmd.execute("'" .. range .. 's/^\\s\\+//e' .. "'")
 | 
			
		||||
  vim.cmd.nohlsearch()
 | 
			
		||||
  vim.fn.setpos('.', pos)
 | 
			
		||||
end, { range = '%' })
 | 
			
		||||
 | 
			
		||||
-- :TabWidth set the tab width for the current buffer
 | 
			
		||||
vim.api.nvim_create_user_command('TabWidth', function(opts)
 | 
			
		||||
  -- Set the tab width for the current filetype
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user