1. Tamas Kovacs
  2. slimv

Commits

kovi...@gmail.com  committed 744f7d1

Raising s-expressions now support [] and {}

  • Participants
  • Parent commits aa4f2d7
  • Branches default

Comments (0)

Files changed (1)

File plugin/paredit.vim

View file
 " Raise: replace containing form with the current symbol or sub-form
 function! PareditRaise()
     let isk_save = s:SetKeyword()
-    if getline('.')[col('.')-1] =~ b:any_openclose_char
-        " Raise sub-form and re-indent
-        normal! y%d%dab
-        normal! "0P=%
+    let ch = getline('.')[col('.')-1]
+    if ch =~ b:any_openclose_char
+        " Jump to the closing char in order to find the outer
+        " closing char.
+        if ch =~ b:any_opening_char
+            normal! %
+        endif
+
+        let [p, l, c] = s:FindClosing()
+        if p =~ b:any_closing_char
+            " Raise sub-form and re-indent
+            exe "normal! y%d%da" . p
+            if getline('.')[col('.')-1] == ' '
+              normal! "0p=%
+            else
+              normal! "0P=%
+            endif
+        elseif ch =~ b:any_opening_char
+            " Restore position if there is no appropriate
+            " closing char.
+            normal! %
+        endif
     else
-        " Raise symbol
-        normal! yiwdab
-        normal! "0Pb
+        let [p, l, c] = s:FindClosing()
+        if p =~ b:any_closing_char
+            " Raise symbol
+            exe "normal! yiwda" . p
+            normal! "0Pb
+        endif
     endif
     let &iskeyword = isk_save
 endfunction