Here I want to minify my code:
let s:next_col = getline('.')[col('.') - 1]
if s:next_col is# "'" || s:next_col is# '"' || s:next_col is# '`' || ')' || s:next_col is# ']' || s:next_col is# '}' || s:next_col is# '>'
return "\<right>"
endif
The above code work as expected. But when I try convert it to this:
let s:next_col = getline('.')[col('.') - 1]
" I also try to add / before \V, not sure if its correct but that also won't work
if s:next_col is# '\V\("\|`\|)\|]\|}\|>\)' || s:next_col is# "'"
return "\<right>"
endif
Now, the only it work will be if the next column is '.
I wonder how I can grouping these character ' " ) ] } > and check if one of those matching with my variable?
is and its variants are only useful for comparing lists or dictionaries. If you want to compare strings, then the right operators would be ==, !=, =~, !~ and their case variants.
Here, you can simply use =~ to compare with a regular expression pattern and, since punctuation marks don't have casing, there is no need for # or ?:
let s:next_col = getline('.')[col('.') - 1]
if s:next_col =~ "['\"`)\\]}>]"
return "\<right>"
endif
[...] is a collection. See :help /[].
', `, ), }, and > are all used as-is because they have no special meaning in Vim's regex dialect.
" is escaped with a \ because double quotes are used for quoting the pattern.
] is escaped once because ] closes the collection, which makes it special in Vim's regex dialect, and a second time because \ is special in double quotes. See :help expr-".
:ls
1 h "~/Documents/trash/practical-vim" line 1
3 h "LICENSE.txt" line 1
4 h "auto_complete/sea-shells.txt" line 1
5 h "files/a.txt" line 1
6 h "files/b.txt" line 1
output of ls command, you can use :b3 to switch to buffer 3, what I want is the same output for :args command, but what I get:
:args
[auto_complete/webapp/public/index.html] ex_mode/practical-vim.html files/mvc/index.html global/episodes.html
i.e. arglist params are printed in one line, which makes usage of :argument3 (to switch to third file in arglist) basically impossible if amount of files is huge. I want these files to be printed on new line with number by which I can access these files like in :ls command.
I tried to write a simple command for this scenario:
command! Args
\ :let var_args = argv()
\ :let var_args_size = len(var_args)
\ :if var_args_size > 0 | let var_args_size = var_args_size - 1 | endif
\ :for i in range(0, var_args_size) | echo printf("%3d %s", i + 1, var_args[i]) | endfor
But:
E15: Invalid expression: argv() :let var_args_size = len(var_args) :if var_args_size > 0 | let var_args_size = var_args_size - 1 | endif
:for i in range(0, var_args_size) | echo printf("%3d %s", i + 1, var_args[i]) | endfor
I kindly request assistance either with my command or some other way to print arglist like this:
:args
1 auto_complete/webapp/public/index.html
2 ex_mode/practical-vim.html
3 files/mvc/index.html
4 global/episodes.html
so i can execute :argument3 and switch to files/mvc/index.html without counting.
You are way beyond the point at which nifty one-liners become liabilities.
Using a function is much cleaner:
function! Args()
let var_args = argv()
let var_args_size = len(var_args)
if var_args_size > 0
let var_args_size = var_args_size - 1
endif
for i in range(0, var_args_size)
echo printf("%3d %s", i + 1, var_args[i])
endfor
endfunction
command! Args call Args()
How about a more interactive approach?
function! Args()
let prompt = 'Select an argument:'
let arg_list = map(argv(), 'v:key + 1 . ". " . v:val')
let chosen_arg = inputlist([prompt] + arg_list))
if chosen_arg
execute 'argument ' . chosen_arg
endif
endfunction
command! Args call Args()
See :help map(), :help inputlist().
Just one line
command! -bar Args echo join(map(argv(), {_, v -> printf("%3d\t%s", bufnr(v), v)}), "\n")
It shows buffer number instead of argument index, so :bX to switch buffer.
It's like I have an nmap to np and one to n and it's waiting to see if I press the p or not before actually searching, but there are no mappings in my vim.rc for that.
Other questions said that the output of :map is helpful, but I can't see anything that helps me.
I think it might be a plugin causing this behaviour.
What could be causing this?
Here is the output of my :map
n y<C-G> *#:call setreg(v:register, <SNR>64_recall())<CR>
n <C-E> :CtrlP<CR>
n <C-H> * <C-W>h
x <Tab> <Plug>snipMateVisual
s <Tab> <Plug>snipMateNextOrTrigger
n <Tab> :SyntasticReset<CR>
n <NL> * <C-W>j
n <C-K> * <C-W>k
n <C-L> * <C-W>l
n <C-N> * :bnext<CR>
n <C-P> * :bprev<CR>
n <C-S> :w <CR> :SyntasticCheck<CR>
n <C-W> :w<CR>
v <C-_>9 <Plug>TComment_<C-_>9
no <C-_>9 <Plug>TComment_<C-_>9
v <C-_>8 <Plug>TComment_<C-_>8
no <C-_>8 <Plug>TComment_<C-_>8
v <C-_>7 <Plug>TComment_<C-_>7
no <C-_>7 <Plug>TComment_<C-_>7
v <C-_>6 <Plug>TComment_<C-_>6
no <C-_>6 <Plug>TComment_<C-_>6
v <C-_>5 <Plug>TComment_<C-_>5
no <C-_>5 <Plug>TComment_<C-_>5
v <C-_>4 <Plug>TComment_<C-_>4
no <C-_>4 <Plug>TComment_<C-_>4
v <C-_>3 <Plug>TComment_<C-_>3
no <C-_>3 <Plug>TComment_<C-_>3
v <C-_>2 <Plug>TComment_<C-_>2
no <C-_>2 <Plug>TComment_<C-_>2
v <C-_>1 <Plug>TComment_<C-_>1
no <C-_>1 <Plug>TComment_<C-_>1
<C-_>ca <Plug>TComment_<C-_>ca
<C-_>cc <Plug>TComment_<C-_>cc
<C-_>s <Plug>TComment_<C-_>s
<C-_>n <Plug>TComment_<C-_>n
<C-_>a <Plug>TComment_<C-_>a
<C-_>b <Plug>TComment_<C-_>b
<C-_>i <Plug>TComment_<C-_>i
<C-_>r <Plug>TComment_<C-_>r
<C-_><Space> <Plug>TComment_<C-_><Space>
<C-_>p <Plug>TComment_<C-_>p
v <C-_><C-_> <Plug>TComment_<C-_><C-_>
no <C-_><C-_> <Plug>TComment_<C-_><C-_>
o % * v:<C-U>call <SNR>68_Match_wrapper('',1,'o') <CR>
v % * :<C-U>call <SNR>68_Match_wrapper('',1,'v') <CR>m'gv``
n % * :<C-U>call <SNR>68_Match_wrapper('',1,'n') <CR>
,_s <Plug>TComment_,_s
,_n <Plug>TComment_,_n
,_a <Plug>TComment_,_a
,_b <Plug>TComment_,_b
,_r <Plug>TComment_,_r
x ,_i <Plug>TComment_,_i
,_<Space> <Plug>TComment_,_<Space>
,_p <Plug>TComment_,_p
x ,__ <Plug>TComment_,__
nos,__ <Plug>TComment_,__
n ,ff :%s/.\/src\/app/\./g<CR>
n ,js :set ft=javascript<CR>
n ,u :e #<CR>
n ,R :%s/console\.log/\/\/ console\.log/g <CR>
n ,C :%s/\/\/ console\.log/console\.log/g <CR>
n ,pu :PluginUpdate<CR>
n ,pc :PluginClean<CR>
n ,pi :PluginInstall<CR>
,g * :!!<CR>
n ,pa "*p
n ,gg :qa<CR>
n ,gc :bw<CR>
n ,sh :set ft=sh<CR>
n ,bl :ls<CR>
n ,. zt
n ,W :StripWhitespace<CR>
n ,w :ToggleWhitespace<CR>
n ,p "*p
n ,d :NERDTreeToggle<CR>
n ,ss :Ng build<CR>
n ,hs :SStylesheet<CR>
n ,hc :SComponent<CR>
n ,ht :STemplate<CR>
n ,vs :VStylesheet<CR>
n ,vc :VComponent<CR>
n ,vt :VTemplate<CR>
n ,es :EStylesheet<CR>
n ,ec :EComponent<CR>
n ,et :ETemplate<CR>
n ; * :
x S <Plug>VSurround
o [% * v:<C-U>call <SNR>68_MultiMatch("bW", "o") <CR>
v [% <Esc>[%m'gv``
n [% * :<C-U>call <SNR>68_MultiMatch("bW", "n") <CR>
o ]% * v:<C-U>call <SNR>68_MultiMatch("W", "o") <CR>
v ]% <Esc>]%m'gv``
n ]% * :<C-U>call <SNR>68_MultiMatch("W", "n") <CR>
v a% <Esc>[%v]%
n cS <Plug>CSurround
n cs <Plug>Csurround
n ds <Plug>Dsurround
v gx <Plug>NetrwBrowseXVis
n gx <Plug>NetrwBrowseX
x gS <Plug>VgSurround
o g% * v:<C-U>call <SNR>68_Match_wrapper('',0,'o') <CR>
v g% * :<C-U>call <SNR>68_Match_wrapper('',0,'v') <CR>m'gv``
n g% * :<C-U>call <SNR>68_Match_wrapper('',0,'n') <CR>
x g> <Plug>TComment_Comment
n g>b <Plug>TComment_Commentb
n g>c <Plug>TComment_Commentc
n g> <Plug>TComment_Comment
x g< <Plug>TComment_Uncomment
n g<b <Plug>TComment_Uncommentb
n g<c <Plug>TComment_Uncommentc
n g< <Plug>TComment_Uncomment
x gc <Plug>TComment_gc
n gcb <Plug>TComment_gcb
n gcc <Plug>TComment_gcc
n gc9c <Plug>TComment_gc9c
n gc9 <Plug>TComment_gc9
n gc8c <Plug>TComment_gc8c
n gc8 <Plug>TComment_gc8
n gc7c <Plug>TComment_gc7c
n gc7 <Plug>TComment_gc7
n gc6c <Plug>TComment_gc6c
n gc6 <Plug>TComment_gc6
n gc5c <Plug>TComment_gc5c
n gc5 <Plug>TComment_gc5
n gc4c <Plug>TComment_gc4c
n gc4 <Plug>TComment_gc4
n gc3c <Plug>TComment_gc3c
n gc3 <Plug>TComment_gc3
n gc2c <Plug>TComment_gc2c
n gc2 <Plug>TComment_gc2
n gc1c <Plug>TComment_gc1c
n gc1 <Plug>TComment_gc1
n gc <Plug>TComment_gc
o ic <Plug>TComment_ic
v ic <Plug>TComment_ic
null <Plug>(ctrlp)
n ySS <Plug>YSsurround
n ySs <Plug>YSsurround
n yss <Plug>Yssurround
n yS <Plug>YSurround
n ys <Plug>Ysurround
s <S-Tab> <Plug>snipMateBack
v <Plug>NetrwBrowseXVis * :<C-U>call netrw#BrowseXVis()<CR>
n <Plug>NetrwBrowseX * :call netrw#BrowseX(expand((exists("g:netrw_gx")? g:netrw_gx : '<cfile>')),netrw#CheckIfRemote())<CR>
v <Plug>VgSurround * :<C-U>call <SNR>72_opfunc(visualmode(),visualmode() ==# 'V' ? 0 : 1)<CR>
v <Plug>VSurround * :<C-U>call <SNR>72_opfunc(visualmode(),visualmode() ==# 'V' ? 1 : 0)<CR>
n <Plug>YSurround * :<C-U>set opfunc=<SNR>72_opfunc2<CR>g#
n <Plug>Ysurround * :<C-U>set opfunc=<SNR>72_opfunc<CR>g#
n <Plug>YSsurround * :<C-U>call <SNR>72_opfunc2(v:count1)<CR>
n <Plug>Yssurround * :<C-U>call <SNR>72_opfunc(v:count1)<CR>
n <Plug>CSurround * :<C-U>call <SNR>72_changesurround(1)<CR>
n <Plug>Csurround * :<C-U>call <SNR>72_changesurround()<CR>
n <Plug>Dsurround * :<C-U>call <SNR>72_dosurround(<SNR>72_inputtarget())<CR>
n <Plug>SurroundRepeat * .
x <Plug>snipMateVisual * :<C-U>call <SNR>69_grab_visual()<CR>gv"_c
s <Plug>snipMateBack * <Esc>a<C-R>=snipMate#BackwardsSnippet()<CR>
s <Plug>snipMateNextOrTrigger * <Esc>a<C-R>=snipMate#TriggerSnippet()<CR>
n <SNR>64_: * :<C-U><C-R>=v:count ? v:count : ''<CR>
<Plug>BufTabLine.Go(10) * :exe 'b'.get(buftabline#user_buffers(),9,'')<CR>
<Plug>BufTabLine.Go(9) * :exe 'b'.get(buftabline#user_buffers(),8,'')<CR>
<Plug>BufTabLine.Go(8) * :exe 'b'.get(buftabline#user_buffers(),7,'')<CR>
<Plug>BufTabLine.Go(7) * :exe 'b'.get(buftabline#user_buffers(),6,'')<CR>
<Plug>BufTabLine.Go(6) * :exe 'b'.get(buftabline#user_buffers(),5,'')<CR>
<Plug>BufTabLine.Go(5) * :exe 'b'.get(buftabline#user_buffers(),4,'')<CR>
<Plug>BufTabLine.Go(4) * :exe 'b'.get(buftabline#user_buffers(),3,'')<CR>
<Plug>BufTabLine.Go(3) * :exe 'b'.get(buftabline#user_buffers(),2,'')<CR>
<Plug>BufTabLine.Go(2) * :exe 'b'.get(buftabline#user_buffers(),1,'')<CR>
<Plug>BufTabLine.Go(1) * :exe 'b'.get(buftabline#user_buffers(),0,'')<CR>
n <Plug>TComment_gc9c * :<C-U>call tcomment#ResetOption() | if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | let w:tcommentPos = getpos(".") |set opfunc=TCommentOpFunc_gc9c<CR>g#
n <Plug>TComment_gc8c * :<C-U>call tcomment#ResetOption() | if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | let w:tcommentPos = getpos(".") |set opfunc=TCommentOpFunc_gc8c<CR>g#
n <Plug>TComment_gc7c * :<C-U>call tcomment#ResetOption() | if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | let w:tcommentPos = getpos(".") |set opfunc=TCommentOpFunc_gc7c<CR>g#
n <Plug>TComment_gc6c * :<C-U>call tcomment#ResetOption() | if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | let w:tcommentPos = getpos(".") |set opfunc=TCommentOpFunc_gc6c<CR>g#
n <Plug>TComment_gc5c * :<C-U>call tcomment#ResetOption() | if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | let w:tcommentPos = getpos(".") |set opfunc=TCommentOpFunc_gc5c<CR>g#
n <Plug>TComment_gc4c * :<C-U>call tcomment#ResetOption() | if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | let w:tcommentPos = getpos(".") |set opfunc=TCommentOpFunc_gc4c<CR>g#
n <Plug>TComment_gc3c * :<C-U>call tcomment#ResetOption() | if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | let w:tcommentPos = getpos(".") |set opfunc=TCommentOpFunc_gc3c<CR>g#
n <Plug>TComment_gc2c * :<C-U>call tcomment#ResetOption() | if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | let w:tcommentPos = getpos(".") |set opfunc=TCommentOpFunc_gc2c<CR>g#
n <Plug>TComment_gc1c * :<C-U>call tcomment#ResetOption() | if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | let w:tcommentPos = getpos(".") |set opfunc=TCommentOpFunc_gc1c<CR>g#
v <Plug>TComment_<C-_>9 * :call tcomment#SetOption("count", 9)<CR>
no <Plug>TComment_<C-_>9 * :call tcomment#SetOption("count", 9)<CR>
v <Plug>TComment_<C-_>8 * :call tcomment#SetOption("count", 8)<CR>
no <Plug>TComment_<C-_>8 * :call tcomment#SetOption("count", 8)<CR>
v <Plug>TComment_<C-_>7 * :call tcomment#SetOption("count", 7)<CR>
no <Plug>TComment_<C-_>7 * :call tcomment#SetOption("count", 7)<CR>
v <Plug>TComment_<C-_>6 * :call tcomment#SetOption("count", 6)<CR>
no <Plug>TComment_<C-_>6 * :call tcomment#SetOption("count", 6)<CR>
v <Plug>TComment_<C-_>5 * :call tcomment#SetOption("count", 5)<CR>
no <Plug>TComment_<C-_>5 * :call tcomment#SetOption("count", 5)<CR>
v <Plug>TComment_<C-_>4 * :call tcomment#SetOption("count", 4)<CR>
no <Plug>TComment_<C-_>4 * :call tcomment#SetOption("count", 4)<CR>
v <Plug>TComment_<C-_>3 * :call tcomment#SetOption("count", 3)<CR>
no <Plug>TComment_<C-_>3 * :call tcomment#SetOption("count", 3)<CR>
v <Plug>TComment_<C-_>2 * :call tcomment#SetOption("count", 2)<CR>
no <Plug>TComment_<C-_>2 * :call tcomment#SetOption("count", 2)<CR>
v <Plug>TComment_<C-_>1 * :call tcomment#SetOption("count", 1)<CR>
no <Plug>TComment_<C-_>1 * :call tcomment#SetOption("count", 1)<CR>
n <Plug>TComment_gC * :<C-U>call tcomment#ResetOption() | if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | let w:tcommentPos = getpos(".") |set opfunc=TCommentOpFunc_gC<CR>g#
n <Plug>TComment_gc * :<C-U>call tcomment#ResetOption() | if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | let w:tcommentPos = getpos(".") |set opfunc=TCommentOpFunc_gc<CR>g#
x <Plug>TComment_gc * :TCommentMaybeInline<CR>
n <Plug>TComment_gcb * :<C-U>call tcomment#ResetOption() | if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | let w:tcommentPos = getpos(".") |set opfunc=TCommentOpFunc_gcb<CR>g#
n <Plug>TComment_gcc * :<C-U>call tcomment#ResetOption() | if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | let w:tcommentPos = getpos(".") |set opfunc=TCommentOpFunc_gcc<CR>g#$
<Plug>TComment_ic * :<C-U>call tcomment#TextObjectInlineComment()<CR>
x <Plug>TComment_Comment * :<C-U>if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | '<,'>TCommentMaybeInline!<CR>
n <Plug>TComment_Commentb * :<C-U>call tcomment#ResetOption() | if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | let w:tcommentPos = getpos(".") |set opfunc=TCommentOpFunc_Commentb<CR>g#
n <Plug>TComment_Commentc * :<C-U>call tcomment#ResetOption() | if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | let w:tcommentPos = getpos(".") |set opfunc=TCommentOpFunc_Commentc<CR>g#$
n <Plug>TComment_Commentl * :<C-U>call tcomment#ResetOption() | if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | let w:tcommentPos = getpos(".") |set opfunc=TCommentOpFunc_Commentl<CR>g#$
n <Plug>TComment_Comment * :<C-U>call tcomment#ResetOption() | if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | let w:tcommentPos = getpos(".") |set opfunc=TCommentOpFunc_Comment<CR>g#
x <Plug>TComment_Uncomment * :<C-U>if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | call tcomment#SetOption("mode_extra", "U") | '<,'>TCommentMaybeInline<CR>
n <Plug>TComment_Uncommentb * :<C-U>call tcomment#ResetOption() | if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | let w:tcommentPos = getpos(".") |set opfunc=TCommentOpFunc_Uncommentb<CR>g#
n <Plug>TComment_Uncommentc * :<C-U>call tcomment#ResetOption() | if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | let w:tcommentPos = getpos(".") |set opfunc=TCommentOpFunc_Uncommentc<CR>g#$
n <Plug>TComment_Uncomment * :<C-U>call tcomment#ResetOption() | if v:count > 0 | call tcomment#SetOption("count", v:count) | endif | let w:tcommentPos = getpos(".") |set opfunc=TCommentOpFunc_Uncomment<CR>g#
<Plug>TComment_,_s * :TCommentAs <C-R>=&ft<CR>_
<Plug>TComment_,_n * :TCommentAs <C-R>=&ft<CR><Space>
<Plug>TComment_,_a * :TCommentAs<Space>
<Plug>TComment_,_b * :TCommentBlock<CR>
<Plug>TComment_,_r * :TCommentRight<CR>
x <Plug>TComment_,_i * :TCommentInline<CR>
<Plug>TComment_,_<Space> * :TComment<Space>
<Plug>TComment_,_p * vip:TComment<CR>
x <Plug>TComment_,__ * :TCommentMaybeInline<CR>
nos<Plug>TComment_,__ * :TComment<CR>
<Plug>TComment_<C-_>ca * :<C-U>call tcomment#SetOption("as", input("Comment as: ", &filetype, "customlist,tcomment#Complete"))<CR>
<Plug>TComment_<C-_>cc * :<C-U>call tcomment#SetOption("count", v:count1)<CR>
<Plug>TComment_<C-_>s * :TCommentAs <C-R>=&ft<CR>_
<Plug>TComment_<C-_>n * :TCommentAs <C-R>=&ft<CR><Space>
<Plug>TComment_<C-_>a * :TCommentAs<Space>
<Plug>TComment_<C-_>b * :TCommentBlock<CR>
<Plug>TComment_<C-_>i * v:TCommentInline mode=I#<CR>
<Plug>TComment_<C-_>r * :TCommentRight<CR>
<Plug>TComment_<C-_><Space> * :TComment<Space>
<Plug>TComment_<C-_>p * m`vip:TComment<CR>``
v <Plug>TComment_<C-_><C-_> * :TCommentMaybeInline<CR>
no <Plug>TComment_<C-_><C-_> * :TComment<CR>
n <Plug>(ctrlp) * :<C-U>CtrlP<CR>
<F2> :echo 'Current time is ' . strftime('%c')<CR>
<F10> :tabm +1<CR>
<F9> :tabm -1<CR>
« * :
© * :
ª * :
ò * :
ã * :
ç * :
î * :
ô * :
è * :
í * :
This mapping is active (also) in normal mode and makes Vim wait for additional characters after n (to check whether you actually wanted the null mapping):
null <Plug>(ctrlp)
As you've already commented, this is caused by the following, presumably an attempt to disable the CtrlP mappings:
let g:ctrlp_map = 'null'
To do this correctly, configure a dummy mapping that starts with <Plug> as these will never match typed characters (cp. :help <Plug>):
let g:ctrlp_map = '<Plug>DisabledCtrlP'
I've discovered this great command from the documentation:
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
So I've come up with this:
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis | wincmd p
map <Leader>do :DiffOrig<cr>
map <leader>dc :q<cr>:diffoff!<cr>
The problem is, when I se \dc, it will jump back to the beginning of the file, not where I left it prior to issuing \do. How to fix this?
Please try this yourself, see what the problems are and how to fix them. And tell me how to fix them too :-)
You could try:
command DiffOrig let g:diffline = line('.') | vert new | set bt=nofile | r # | 0d_ | diffthis | :exe "norm! ".g:diffline."G" | wincmd p | diffthis | wincmd p
nnoremap <Leader>do :DiffOrig<cr>
nnoremap <leader>dc :q<cr>:diffoff<cr>:exe "norm! ".g:diffline."G"<cr>
You can :q in the window you want to close, and then :diffoff to turn off the diff formatting in the remaining window. Not sure if it can be done in one command.
To close the diff windows and go back to the file you were editing, you could try adding this to your .vimrc file:
if !exists(":DiffOff")
command DiffOff diffoff <bar> only
endif
Then enter :DiffOff to close the diff windows.